diff --git a/eng/native/configurecompiler.cmake b/eng/native/configurecompiler.cmake index 8decaa84fe9ad..0fb801dbc8eef 100644 --- a/eng/native/configurecompiler.cmake +++ b/eng/native/configurecompiler.cmake @@ -15,6 +15,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) include(CheckCCompilerFlag) include(CheckCXXCompilerFlag) include(CheckLinkerFlag) +include(CheckIPOSupported) # "configureoptimization.cmake" must be included after CLR_CMAKE_HOST_UNIX has been set. include(${CMAKE_CURRENT_LIST_DIR}/configureoptimization.cmake) @@ -152,6 +153,17 @@ elseif (CLR_CMAKE_HOST_UNIX) endif() endif(MSVC) +check_ipo_supported(RESULT result OUTPUT output) +if(result AND NOT CLR_CMAKE_TARGET_APPLE) + # Apple does not properly support IPO and need more involved + # way on how to support this. For now, disable it for Apple. + set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON) + set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_DEBUG OFF) + set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_CHECKED OFF) +else() + message(WARNING "IPO is not supported") +endif() + if (CLR_CMAKE_ENABLE_SANITIZERS) set (CLR_CMAKE_BUILD_SANITIZERS "") set (CLR_CMAKE_SANITIZER_RUNTIMES "") @@ -889,10 +901,6 @@ if (MSVC) add_compile_options($<$:/Gz>) endif (CLR_CMAKE_HOST_ARCH_I386) - set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON) - set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_DEBUG OFF) - set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_CHECKED OFF) - if (CLR_CMAKE_HOST_ARCH_AMD64) # The generator expression in the following command means that the /homeparams option is added only for debug builds for C and C++ source files add_compile_options($<$,$>:/homeparams>) # Force parameters passed in registers to be written to the stack diff --git a/src/coreclr/debug/runtimeinfo/CMakeLists.txt b/src/coreclr/debug/runtimeinfo/CMakeLists.txt index 77ecf9a4dd9ba..0846199a0b1b8 100644 --- a/src/coreclr/debug/runtimeinfo/CMakeLists.txt +++ b/src/coreclr/debug/runtimeinfo/CMakeLists.txt @@ -61,6 +61,8 @@ else() target_include_directories(cdac_data_descriptor BEFORE PRIVATE ${VM_DIR}) target_include_directories(cdac_data_descriptor BEFORE PRIVATE ${VM_DIR}/${ARCH_SOURCES_DIR}) target_include_directories(cdac_data_descriptor PRIVATE ${CLR_DIR}/interop/inc) + # LTO not supported for cdac, so disable it + set_target_properties(cdac_data_descriptor PROPERTIES INTERPROCEDURAL_OPTIMIZATION OFF) set(GENERATED_CDAC_DESCRIPTOR_DIR "${CMAKE_CURRENT_BINARY_DIR}/cdac") set(CONTRACT_DESCRIPTOR_OUTPUT "${GENERATED_CDAC_DESCRIPTOR_DIR}/contract-descriptor.c") diff --git a/src/coreclr/nativeaot/CMakeLists.txt b/src/coreclr/nativeaot/CMakeLists.txt index 74ee982ab9805..9ef5898780dd3 100644 --- a/src/coreclr/nativeaot/CMakeLists.txt +++ b/src/coreclr/nativeaot/CMakeLists.txt @@ -7,13 +7,13 @@ if(MSVC) set_property(DIRECTORY PROPERTY CLR_EH_OPTION /EHa-s-) # Native AOT runtime does not use C++ exception handling set_property(DIRECTORY PROPERTY CLR_CONTROL_FLOW_GUARD OFF) - # The code generated by the Native AOT compiler doesn't work with Link Time Code Generation - set(CMAKE_INTERPROCEDURAL_OPTIMIZATION OFF) - # Sets the options that create the fastest code in the majority of cases add_compile_options($<$,$>:/O2>) endif (MSVC) +# The code generated by the Native AOT compiler doesn't work with Link Time Code Generation +set(CMAKE_INTERPROCEDURAL_OPTIMIZATION OFF) + if(CLR_CMAKE_HOST_UNIX) add_compile_options(-fno-exceptions) # Native AOT runtime doesn't use C++ exception handling add_compile_options(-fno-asynchronous-unwind-tables)