diff --git a/flang/lib/Decimal/CMakeLists.txt b/flang/lib/Decimal/CMakeLists.txt --- a/flang/lib/Decimal/CMakeLists.txt +++ b/flang/lib/Decimal/CMakeLists.txt @@ -36,6 +36,13 @@ ${FLANG_SOURCE_DIR}/include) endif() +check_cxx_compiler_flag(-fno-lto FLANG_RUNTIME_HAS_FNO_LTO_FLAG) +if (FLANG_RUNTIME_HAS_FNO_LTO_FLAG) + append("-fno-lto" CMAKE_CXX_FLAGS) +endif() + + + add_flang_library(FortranDecimal INSTALL_WITH_TOOLCHAIN binary-to-decimal.cpp decimal-to-binary.cpp diff --git a/flang/runtime/CMakeLists.txt b/flang/runtime/CMakeLists.txt --- a/flang/runtime/CMakeLists.txt +++ b/flang/runtime/CMakeLists.txt @@ -65,6 +65,13 @@ " HAVE_DECL_STRERROR_S) +check_cxx_compiler_flag(-fno-lto FLANG_RUNTIME_HAS_FNO_LTO_FLAG) +if (FLANG_RUNTIME_HAS_FNO_LTO_FLAG) + set(NO_LTO_FLAGS "-fno-lto") +else() + set(NO_LTO_FLAGS "") +endif() + if (NOT (HAVE_STRERROR OR HAVE_STRERROR_R OR HAVE_DECL_STRERROR_S)) message(FATAL_ERROR "None of strerror, strerror_r, strerror_s found.") endif() @@ -75,6 +82,9 @@ # with different names include_directories(AFTER ${CMAKE_CURRENT_BINARY_DIR}) +append(${NO_LTO_FLAGS} CMAKE_C_FLAGS) +append(${NO_LTO_FLAGS} CMAKE_CXX_FLAGS) + add_subdirectory(FortranMain) add_flang_library(FortranRuntime