File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -204,6 +204,9 @@ endif ()
204
204
# but some older versions of CMake don't define it for GCC itself.
205
205
check_cxx_compiler_flag ("-UTESTFLAG" FLANG_RT_SUPPORTS_UNDEFINE_FLAG )
206
206
207
+ # Check whether -fno-lto is supported.
208
+ check_cxx_compiler_flag (-fno-lto FLANG_RT_HAS_FNO_LTO_FLAG )
209
+
207
210
208
211
# function checks
209
212
find_package (Backtrace )
Original file line number Diff line number Diff line change @@ -126,6 +126,13 @@ function (add_flangrt_library name)
126
126
target_compile_options (${name} PUBLIC -U_LIBCPP_ENABLE_ASSERTIONS )
127
127
endif ()
128
128
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
+
129
136
# Flang/Clang (including clang-cl) -compiled programs targeting the MSVC ABI
130
137
# should only depend on msvcrt/ucrt. LLVM still emits libgcc/compiler-rt
131
138
# functions in some cases like 128-bit integer math (__udivti3, __modti3,
You can’t perform that action at this time.
0 commit comments