diff --git a/flang/lib/Decimal/CMakeLists.txt b/flang/lib/Decimal/CMakeLists.txt index f30614ee1f8a..47de6cd9a660 100644 --- a/flang/lib/Decimal/CMakeLists.txt +++ b/flang/lib/Decimal/CMakeLists.txt @@ -36,6 +36,13 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) ${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 index 8ce03274e8c8..174c8dbaa649 100644 --- a/flang/runtime/CMakeLists.txt +++ b/flang/runtime/CMakeLists.txt @@ -65,6 +65,13 @@ check_cxx_source_compiles( " 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 @@ configure_file(config.h.cmake config.h) # 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