Skip to content

Commit 19fe1a3

Browse files
committed
Disable LTO
Apply https://reviews.llvm.org/D140016 to LLVM_ENABLE_RUNTIMES=flang-rt
1 parent 6391795 commit 19fe1a3

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

flang-rt/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,9 @@ endif ()
204204
# but some older versions of CMake don't define it for GCC itself.
205205
check_cxx_compiler_flag("-UTESTFLAG" FLANG_RT_SUPPORTS_UNDEFINE_FLAG)
206206

207+
# Check whether -fno-lto is supported.
208+
check_cxx_compiler_flag(-fno-lto FLANG_RT_HAS_FNO_LTO_FLAG)
209+
207210

208211
# function checks
209212
find_package(Backtrace)

flang-rt/cmake/modules/AddFlangRT.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,13 @@ function (add_flangrt_library name)
126126
target_compile_options(${name} PUBLIC -U_LIBCPP_ENABLE_ASSERTIONS)
127127
endif ()
128128

129+
# When building the flang runtime if LTO is enabled the archive file
130+
# contains LLVM IR rather than object code. Currently flang is not
131+
# LTO aware so cannot link this file to compiled Fortran code.
132+
if (FLANG_RT_HAS_FNO_LTO_FLAG)
133+
target_compile_options(${name} PRIVATE -fno-lto)
134+
endif ()
135+
129136
# Flang/Clang (including clang-cl) -compiled programs targeting the MSVC ABI
130137
# should only depend on msvcrt/ucrt. LLVM still emits libgcc/compiler-rt
131138
# functions in some cases like 128-bit integer math (__udivti3, __modti3,

0 commit comments

Comments
 (0)