Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable LTCG for brotli and zlibng. #111805

Merged
merged 4 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions eng/native/configurecompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,13 @@ if (MSVC)
add_linker_flag(/OPT:NOICF CHECKED)

# Release build specific flags
add_linker_flag(/LTCG RELEASE)
add_linker_flag(/OPT:REF RELEASE)
add_linker_flag(/OPT:ICF RELEASE)
add_linker_flag(/INCREMENTAL:NO RELEASE)
set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "${CMAKE_STATIC_LINKER_FLAGS_RELEASE} /LTCG")

# ReleaseWithDebugInfo build specific flags
add_linker_flag(/LTCG RELWITHDEBINFO)
add_linker_flag(/OPT:REF RELWITHDEBINFO)
add_linker_flag(/OPT:ICF RELWITHDEBINFO)
set(CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO} /LTCG")

elseif (CLR_CMAKE_HOST_UNIX)
# Set the values to display when interactively configuring CMAKE_BUILD_TYPE
Expand Down
4 changes: 3 additions & 1 deletion src/coreclr/debug/runtimeinfo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ else()
# turn off whole program optimization:
# 1. it creates object files that cdac-build-tool can't read
# 2. we never link cdac_data_descriptor into the final product - it's only job is to be scraped
target_compile_options(cdac_data_descriptor PRIVATE /GL-)
set_target_properties(cdac_data_descriptor PROPERTIES
INTERPROCEDURAL_OPTIMIZATION_RELEASE OFF
INTERPROCEDURAL_OPTIMIZATION_RELWITHDEBINFO OFF)
endif()
target_include_directories(cdac_data_descriptor BEFORE PRIVATE ${VM_DIR})
target_include_directories(cdac_data_descriptor BEFORE PRIVATE ${VM_DIR}/${ARCH_SOURCES_DIR})
Expand Down
6 changes: 0 additions & 6 deletions src/coreclr/dlls/clretwrc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
include_directories(${CMAKE_CURRENT_BINARY_DIR})

if(CLR_CMAKE_HOST_WIN32)
# remove /ltcg from resource-only libraries
string(REPLACE "/LTCG" "" CMAKE_SHARED_LINKER_FLAGS_RELEASE ${CMAKE_SHARED_LINKER_FLAGS_RELEASE})
string(REPLACE "/LTCG" "" CMAKE_STATIC_LINKER_FLAGS_RELEASE ${CMAKE_STATIC_LINKER_FLAGS_RELEASE})
string(REPLACE "/LTCG" "" CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO ${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO})
string(REPLACE "/LTCG" "" CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO ${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO})

# remove /guard:cf, /guard:ehcont, and /CETCOMPAT from resource-only libraries
set_property(DIRECTORY PROPERTY CLR_CONTROL_FLOW_GUARD OFF)

Expand Down
3 changes: 0 additions & 3 deletions src/coreclr/dlls/mscorrc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ add_definitions(-DFX_VER_INTERNALNAME_STR=mscorrc.dll)

if(CLR_CMAKE_HOST_WIN32)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /NOENTRY")
# remove /ltcg from resource-only libraries
string(REPLACE "/LTCG" "" CMAKE_SHARED_LINKER_FLAGS_RELEASE ${CMAKE_SHARED_LINKER_FLAGS_RELEASE})
string(REPLACE "/LTCG" "" CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO ${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO})

# remove /guard:cf, /guard:ehcont, and /CETCOMPAT from resource-only libraries
set_property(DIRECTORY PROPERTY CLR_CONTROL_FLOW_GUARD OFF)
Expand Down
2 changes: 1 addition & 1 deletion src/native/corehost/apphost/static/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ include_directories(${CLR_ARTIFACTS_OBJ_DIR}) # Generated version files
add_subdirectory(../../hostmisc hostmisc)

configure_file(${CLR_SRC_NATIVE_DIR}/corehost/configure.h.in ${GENERATED_INCLUDE_DIR}/corehost/configure.h)
target_include_directories(hostmisc PUBLIC ${GENERATED_INCLUDE_DIR}/corehost)
target_include_directories(hostmisc_interface INTERFACE ${GENERATED_INCLUDE_DIR}/corehost)

if ((NOT DEFINED CLR_CMAKE_USE_SYSTEM_RAPIDJSON) OR (NOT CLR_CMAKE_USE_SYSTEM_RAPIDJSON))
include_directories(${CLR_SRC_NATIVE_DIR}/external/)
Expand Down
5 changes: 1 addition & 4 deletions src/native/corehost/fxr/staticlib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ if (MSVC)
# LTCG must be disabled to ensure that non-MSVC toolchains can work with it.

set_target_properties(libhostfxr PROPERTIES INTERPROCEDURAL_OPTIMIZATION OFF)

string(REPLACE "/LTCG" "" CMAKE_STATIC_LINKER_FLAGS_RELEASE ${CMAKE_STATIC_LINKER_FLAGS_RELEASE})
string(REPLACE "/LTCG" "" CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO ${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO})
endif()

# Only Windows creates a symbols file for static libs.
Expand All @@ -52,4 +49,4 @@ else()
install(TARGETS libhostfxr DESTINATION corehost)
endif(WIN32)

target_link_libraries(libhostfxr PRIVATE hostmisc)
target_link_libraries(libhostfxr PRIVATE hostmisc::public)
25 changes: 18 additions & 7 deletions src/native/corehost/hostmisc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,34 @@ endif()

# hostmisc must be an "object library" as we want to build it once
# and embed the objects into static libraries we ship (like libnethost).
add_library(hostmisc OBJECT ${SOURCES})

target_include_directories(hostmisc PUBLIC
add_library(hostmisc_interface INTERFACE)
target_include_directories(hostmisc_interface INTERFACE
${CMAKE_CURRENT_BINARY_DIR}
${CLR_SRC_NATIVE_DIR}
${CMAKE_CURRENT_LIST_DIR})

if (MSVC)
target_sources(hostmisc PRIVATE ${HEADERS})
target_link_libraries(hostmisc PUBLIC advapi32)
target_link_libraries(hostmisc_interface INTERFACE advapi32)
endif()

target_link_libraries(hostmisc PUBLIC
target_link_libraries(hostmisc_interface INTERFACE
${CMAKE_DL_LIBS}
$<$<BOOL:${PTHREAD_LIB}>:${PTHREAD_LIB}>)

if(CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_ARCH_ARMV6)
target_link_libraries(hostmisc PUBLIC
target_link_libraries(hostmisc_interface INTERFACE
$<$<BOOL:${ATOMIC_SUPPORT_LIB}>:${ATOMIC_SUPPORT_LIB}>)
endif()


add_library(hostmisc STATIC ${SOURCES})
target_link_libraries(hostmisc PUBLIC hostmisc_interface)
if (MSVC)
target_sources(hostmisc PRIVATE ${HEADERS})
endif()

add_library(hostmisc_public OBJECT ${SOURCES})
target_link_libraries(hostmisc_public PUBLIC hostmisc_interface)
set_target_properties(hostmisc_public PROPERTIES INTERPROCEDURAL_OPTIMIZATION OFF)

add_library(hostmisc::public ALIAS hostmisc_public)
5 changes: 1 addition & 4 deletions src/native/corehost/nethost/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ if (WIN32)
endif(WIN32)

target_link_libraries(nethost PRIVATE hostmisc fxr_resolver)
target_link_libraries(libnethost PRIVATE hostmisc fxr_resolver)
target_link_libraries(libnethost PRIVATE hostmisc::public fxr_resolver)
target_compile_definitions(nethost PRIVATE FEATURE_LIBHOST NETHOST_EXPORT)
target_compile_definitions(libnethost PRIVATE FEATURE_LIBHOST NETHOST_EXPORT)

Expand All @@ -55,9 +55,6 @@ if (MSVC)
# LTCG must be disabled to ensure that non-MSVC toolchains can work with it.

set_target_properties(libnethost PROPERTIES INTERPROCEDURAL_OPTIMIZATION OFF)

string(REPLACE "/LTCG" "" CMAKE_STATIC_LINKER_FLAGS_RELEASE ${CMAKE_STATIC_LINKER_FLAGS_RELEASE})
string(REPLACE "/LTCG" "" CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO ${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO})
endif()

# Only Windows creates a symbols file for static libs.
Expand Down
10 changes: 10 additions & 0 deletions src/native/libs/System.IO.Compression.Native/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ else()
include(${CLR_SRC_NATIVE_DIR}/external/brotli.cmake)
endif()

if (STATIC_LIBS_ONLY)
# For every vendored library that we're actually vendoring (and not referencing the system one)
# mark it as "no interprocedural optimization" so that it's compatible with our NativeAOT shipping story.
foreach(VENDORED_LIB IN LISTS BROTLI_LIBRARIES ITEMS zlib)
if (TARGET ${VENDORED_LIB})
set_target_properties(${VENDORED_LIB} PROPERTIES INTERPROCEDURAL_OPTIMIZATION OFF)
endif()
endforeach()
endif()

configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/../Common/pal_config.h.in
${CMAKE_CURRENT_BINARY_DIR}/pal_config.h)
Expand Down
Loading