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 @@ -234,6 +234,9 @@ endif ()
234
234
# but some older versions of CMake don't define it for GCC itself.
235
235
check_cxx_compiler_flag ("-UTESTFLAG" FLANG_RT_SUPPORTS_UNDEFINE_FLAG )
236
236
237
+ # Check whether -fno-lto is supported.
238
+ check_cxx_compiler_flag (-fno-lto FLANG_RT_HAS_FNO_LTO_FLAG )
239
+
237
240
238
241
# function checks
239
242
find_package (Backtrace )
Original file line number Diff line number Diff line change @@ -237,6 +237,13 @@ function (add_flangrt_library name)
237
237
target_compile_options (${tgtname} PUBLIC -U_LIBCPP_ENABLE_ASSERTIONS )
238
238
endif ()
239
239
240
+ # When building the flang runtime if LTO is enabled the archive file
241
+ # contains LLVM IR rather than object code. Currently flang is not
242
+ # LTO aware so cannot link this file to compiled Fortran code.
243
+ if (FLANG_RT_HAS_FNO_LTO_FLAG )
244
+ target_compile_options (${tgtname} PRIVATE -fno-lto )
245
+ endif ()
246
+
240
247
# Flang/Clang (including clang-cl) -compiled programs targeting the MSVC ABI
241
248
# should only depend on msvcrt/ucrt. LLVM still emits libgcc/compiler-rt
242
249
# functions in some cases like 128-bit integer math (__udivti3, __modti3,
You can’t perform that action at this time.
0 commit comments