Skip to content

Commit 8edaf74

Browse files
authored
Disable LTCG for brotli and zlibng. (#111805)
1 parent fa0f65c commit 8edaf74

File tree

9 files changed

+34
-30
lines changed

9 files changed

+34
-30
lines changed

eng/native/configurecompiler.cmake

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,17 +127,13 @@ if (MSVC)
127127
add_linker_flag(/OPT:NOICF CHECKED)
128128

129129
# Release build specific flags
130-
add_linker_flag(/LTCG RELEASE)
131130
add_linker_flag(/OPT:REF RELEASE)
132131
add_linker_flag(/OPT:ICF RELEASE)
133132
add_linker_flag(/INCREMENTAL:NO RELEASE)
134-
set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "${CMAKE_STATIC_LINKER_FLAGS_RELEASE} /LTCG")
135133

136134
# ReleaseWithDebugInfo build specific flags
137-
add_linker_flag(/LTCG RELWITHDEBINFO)
138135
add_linker_flag(/OPT:REF RELWITHDEBINFO)
139136
add_linker_flag(/OPT:ICF RELWITHDEBINFO)
140-
set(CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO} /LTCG")
141137

142138
elseif (CLR_CMAKE_HOST_UNIX)
143139
# Set the values to display when interactively configuring CMAKE_BUILD_TYPE

src/coreclr/debug/runtimeinfo/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ else()
5656
# turn off whole program optimization:
5757
# 1. it creates object files that cdac-build-tool can't read
5858
# 2. we never link cdac_data_descriptor into the final product - it's only job is to be scraped
59-
target_compile_options(cdac_data_descriptor PRIVATE /GL-)
59+
set_target_properties(cdac_data_descriptor PROPERTIES
60+
INTERPROCEDURAL_OPTIMIZATION_RELEASE OFF
61+
INTERPROCEDURAL_OPTIMIZATION_RELWITHDEBINFO OFF)
6062
endif()
6163
target_include_directories(cdac_data_descriptor BEFORE PRIVATE ${VM_DIR})
6264
target_include_directories(cdac_data_descriptor BEFORE PRIVATE ${VM_DIR}/${ARCH_SOURCES_DIR})

src/coreclr/dlls/clretwrc/CMakeLists.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
include_directories(${CMAKE_CURRENT_BINARY_DIR})
22

33
if(CLR_CMAKE_HOST_WIN32)
4-
# remove /ltcg from resource-only libraries
5-
string(REPLACE "/LTCG" "" CMAKE_SHARED_LINKER_FLAGS_RELEASE ${CMAKE_SHARED_LINKER_FLAGS_RELEASE})
6-
string(REPLACE "/LTCG" "" CMAKE_STATIC_LINKER_FLAGS_RELEASE ${CMAKE_STATIC_LINKER_FLAGS_RELEASE})
7-
string(REPLACE "/LTCG" "" CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO ${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO})
8-
string(REPLACE "/LTCG" "" CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO ${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO})
9-
104
# remove /guard:cf, /guard:ehcont, and /CETCOMPAT from resource-only libraries
115
set_property(DIRECTORY PROPERTY CLR_CONTROL_FLOW_GUARD OFF)
126

src/coreclr/dlls/mscorrc/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ add_definitions(-DFX_VER_INTERNALNAME_STR=mscorrc.dll)
44

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

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

src/native/corehost/apphost/static/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ include_directories(${CLR_ARTIFACTS_OBJ_DIR}) # Generated version files
2525
add_subdirectory(../../hostmisc hostmisc)
2626

2727
configure_file(${CLR_SRC_NATIVE_DIR}/corehost/configure.h.in ${GENERATED_INCLUDE_DIR}/corehost/configure.h)
28-
target_include_directories(hostmisc PUBLIC ${GENERATED_INCLUDE_DIR}/corehost)
28+
target_include_directories(hostmisc_interface INTERFACE ${GENERATED_INCLUDE_DIR}/corehost)
2929

3030
if ((NOT DEFINED CLR_CMAKE_USE_SYSTEM_RAPIDJSON) OR (NOT CLR_CMAKE_USE_SYSTEM_RAPIDJSON))
3131
include_directories(${CLR_SRC_NATIVE_DIR}/external/)

src/native/corehost/fxr/staticlib/CMakeLists.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ if (MSVC)
4040
# LTCG must be disabled to ensure that non-MSVC toolchains can work with it.
4141

4242
set_target_properties(libhostfxr PROPERTIES INTERPROCEDURAL_OPTIMIZATION OFF)
43-
44-
string(REPLACE "/LTCG" "" CMAKE_STATIC_LINKER_FLAGS_RELEASE ${CMAKE_STATIC_LINKER_FLAGS_RELEASE})
45-
string(REPLACE "/LTCG" "" CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO ${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO})
4643
endif()
4744

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

55-
target_link_libraries(libhostfxr PRIVATE hostmisc)
52+
target_link_libraries(libhostfxr PRIVATE hostmisc::public)

src/native/corehost/hostmisc/CMakeLists.txt

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,34 @@ endif()
3131

3232
# hostmisc must be an "object library" as we want to build it once
3333
# and embed the objects into static libraries we ship (like libnethost).
34-
add_library(hostmisc OBJECT ${SOURCES})
35-
36-
target_include_directories(hostmisc PUBLIC
34+
add_library(hostmisc_interface INTERFACE)
35+
target_include_directories(hostmisc_interface INTERFACE
3736
${CMAKE_CURRENT_BINARY_DIR}
3837
${CLR_SRC_NATIVE_DIR}
3938
${CMAKE_CURRENT_LIST_DIR})
4039

4140
if (MSVC)
42-
target_sources(hostmisc PRIVATE ${HEADERS})
43-
target_link_libraries(hostmisc PUBLIC advapi32)
41+
target_link_libraries(hostmisc_interface INTERFACE advapi32)
4442
endif()
4543

46-
target_link_libraries(hostmisc PUBLIC
44+
target_link_libraries(hostmisc_interface INTERFACE
4745
${CMAKE_DL_LIBS}
4846
$<$<BOOL:${PTHREAD_LIB}>:${PTHREAD_LIB}>)
4947

5048
if(CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_ARCH_ARMV6)
51-
target_link_libraries(hostmisc PUBLIC
49+
target_link_libraries(hostmisc_interface INTERFACE
5250
$<$<BOOL:${ATOMIC_SUPPORT_LIB}>:${ATOMIC_SUPPORT_LIB}>)
5351
endif()
52+
53+
54+
add_library(hostmisc STATIC ${SOURCES})
55+
target_link_libraries(hostmisc PUBLIC hostmisc_interface)
56+
if (MSVC)
57+
target_sources(hostmisc PRIVATE ${HEADERS})
58+
endif()
59+
60+
add_library(hostmisc_public OBJECT ${SOURCES})
61+
target_link_libraries(hostmisc_public PUBLIC hostmisc_interface)
62+
set_target_properties(hostmisc_public PROPERTIES INTERPROCEDURAL_OPTIMIZATION OFF)
63+
64+
add_library(hostmisc::public ALIAS hostmisc_public)

src/native/corehost/nethost/CMakeLists.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ if (WIN32)
3434
endif(WIN32)
3535

3636
target_link_libraries(nethost PRIVATE hostmisc fxr_resolver)
37-
target_link_libraries(libnethost PRIVATE hostmisc fxr_resolver)
37+
target_link_libraries(libnethost PRIVATE hostmisc::public fxr_resolver)
3838
target_compile_definitions(nethost PRIVATE FEATURE_LIBHOST NETHOST_EXPORT)
3939
target_compile_definitions(libnethost PRIVATE FEATURE_LIBHOST NETHOST_EXPORT)
4040

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

5757
set_target_properties(libnethost PROPERTIES INTERPROCEDURAL_OPTIMIZATION OFF)
58-
59-
string(REPLACE "/LTCG" "" CMAKE_STATIC_LINKER_FLAGS_RELEASE ${CMAKE_STATIC_LINKER_FLAGS_RELEASE})
60-
string(REPLACE "/LTCG" "" CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO ${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO})
6158
endif()
6259

6360
# Only Windows creates a symbols file for static libs.

src/native/libs/System.IO.Compression.Native/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ else()
1818
include(${CLR_SRC_NATIVE_DIR}/external/brotli.cmake)
1919
endif()
2020

21+
if (STATIC_LIBS_ONLY)
22+
# For every vendored library that we're actually vendoring (and not referencing the system one)
23+
# mark it as "no interprocedural optimization" so that it's compatible with our NativeAOT shipping story.
24+
foreach(VENDORED_LIB IN LISTS BROTLI_LIBRARIES ITEMS zlib)
25+
if (TARGET ${VENDORED_LIB})
26+
set_target_properties(${VENDORED_LIB} PROPERTIES INTERPROCEDURAL_OPTIMIZATION OFF)
27+
endif()
28+
endforeach()
29+
endif()
30+
2131
configure_file(
2232
${CMAKE_CURRENT_SOURCE_DIR}/../Common/pal_config.h.in
2333
${CMAKE_CURRENT_BINARY_DIR}/pal_config.h)

0 commit comments

Comments
 (0)