From 27af8a48ed4dae7f6883009dc0fbd167090dab8a Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 25 Mar 2025 13:16:44 -0700 Subject: [PATCH 1/3] [9.0] Ensure libnethost isn't built with LTCG --- src/native/corehost/hostmisc/CMakeLists.txt | 25 +++++++++++++++------ src/native/corehost/nethost/CMakeLists.txt | 2 +- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/native/corehost/hostmisc/CMakeLists.txt b/src/native/corehost/hostmisc/CMakeLists.txt index f39b586590c62a..76669e902fa6ad 100644 --- a/src/native/corehost/hostmisc/CMakeLists.txt +++ b/src/native/corehost/hostmisc/CMakeLists.txt @@ -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} $<$:${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 $<$:${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) \ No newline at end of file diff --git a/src/native/corehost/nethost/CMakeLists.txt b/src/native/corehost/nethost/CMakeLists.txt index 38b103b7178bee..f9a3a5086ec77f 100644 --- a/src/native/corehost/nethost/CMakeLists.txt +++ b/src/native/corehost/nethost/CMakeLists.txt @@ -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) From 10c651f39f723534d4866e5ff63e42eae6b6af21 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 25 Mar 2025 13:49:05 -0700 Subject: [PATCH 2/3] Move configure include into the pal as that's the only place that uses it. --- src/native/corehost/hostmisc/pal.h | 2 -- src/native/corehost/hostmisc/pal.unix.cpp | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/native/corehost/hostmisc/pal.h b/src/native/corehost/hostmisc/pal.h index bde8446cc22cdf..219eaedfdc9c5d 100644 --- a/src/native/corehost/hostmisc/pal.h +++ b/src/native/corehost/hostmisc/pal.h @@ -58,8 +58,6 @@ #endif -#include "configure.h" - // When running on a platform that is not supported in RID fallback graph (because it was unknown // at the time the SharedFX in question was built), we need to use a reasonable fallback RID to allow // consuming the native assets. diff --git a/src/native/corehost/hostmisc/pal.unix.cpp b/src/native/corehost/hostmisc/pal.unix.cpp index 613902b5eaf3ac..14815dd1f5f9f7 100644 --- a/src/native/corehost/hostmisc/pal.unix.cpp +++ b/src/native/corehost/hostmisc/pal.unix.cpp @@ -5,6 +5,8 @@ #define _WITH_GETLINE #endif +#include "configure.h" + #include "pal.h" #include "utils.h" #include "trace.h" From 4aade22784bdf2849e2a047d0b9536771cd74bae Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 27 Mar 2025 13:11:45 -0700 Subject: [PATCH 3/3] It's the other configure file that was causing problems, fix how that one is set up. --- src/native/corehost/apphost/static/CMakeLists.txt | 2 +- src/native/corehost/hostmisc/pal.h | 2 ++ src/native/corehost/hostmisc/pal.unix.cpp | 2 -- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/native/corehost/apphost/static/CMakeLists.txt b/src/native/corehost/apphost/static/CMakeLists.txt index 3ea4d5d043ca3a..880510d06976b1 100644 --- a/src/native/corehost/apphost/static/CMakeLists.txt +++ b/src/native/corehost/apphost/static/CMakeLists.txt @@ -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/) diff --git a/src/native/corehost/hostmisc/pal.h b/src/native/corehost/hostmisc/pal.h index 219eaedfdc9c5d..bde8446cc22cdf 100644 --- a/src/native/corehost/hostmisc/pal.h +++ b/src/native/corehost/hostmisc/pal.h @@ -58,6 +58,8 @@ #endif +#include "configure.h" + // When running on a platform that is not supported in RID fallback graph (because it was unknown // at the time the SharedFX in question was built), we need to use a reasonable fallback RID to allow // consuming the native assets. diff --git a/src/native/corehost/hostmisc/pal.unix.cpp b/src/native/corehost/hostmisc/pal.unix.cpp index 14815dd1f5f9f7..613902b5eaf3ac 100644 --- a/src/native/corehost/hostmisc/pal.unix.cpp +++ b/src/native/corehost/hostmisc/pal.unix.cpp @@ -5,8 +5,6 @@ #define _WITH_GETLINE #endif -#include "configure.h" - #include "pal.h" #include "utils.h" #include "trace.h"