From 15a23ed436d413d5912a0535ee52095aa96462ca Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Mon, 20 May 2024 11:18:47 -0700 Subject: [PATCH 01/18] Change setup.cmake into a configure_file. Cleanup hostcommon Make hostmisc an interface target instead of an include. --- src/coreclr/CMakeLists.txt | 2 ++ src/native/corehost/CMakeLists.txt | 31 ++++++++++++++++ src/native/corehost/common.cmake | 13 ------- src/native/corehost/configure.h.in | 23 ++++++++++++ src/native/corehost/exe.cmake | 3 +- .../corehost/fxr/staticlib/CMakeLists.txt | 3 +- src/native/corehost/hostcommon/CMakeLists.txt | 20 ++++++++--- .../{hostmisc.cmake => CMakeLists.txt} | 21 ++++++++--- src/native/corehost/hostmisc/pal.h | 2 ++ src/native/corehost/lib.cmake | 3 +- src/native/corehost/nethost/CMakeLists.txt | 3 ++ src/native/corehost/setup.cmake | 36 ------------------- .../corehost/test/comsxs/CMakeLists.txt | 2 ++ .../corehost/test/fx_ver/CMakeLists.txt | 4 +-- .../corehost/test/nativehost/CMakeLists.txt | 4 +-- 15 files changed, 102 insertions(+), 68 deletions(-) create mode 100644 src/native/corehost/configure.h.in rename src/native/corehost/hostmisc/{hostmisc.cmake => CMakeLists.txt} (72%) delete mode 100644 src/native/corehost/setup.cmake diff --git a/src/coreclr/CMakeLists.txt b/src/coreclr/CMakeLists.txt index 7ed0d509212cc..b1951b3754943 100644 --- a/src/coreclr/CMakeLists.txt +++ b/src/coreclr/CMakeLists.txt @@ -61,7 +61,9 @@ include(components.cmake) #--------------------------- if(NOT CLR_CROSS_COMPONENTS_BUILD) set(CLR_SINGLE_FILE_HOST_ONLY 1) + configure_file(${CLR_SRC_NATIVE_DIR}/corehost/configure.h.in ${GENERATED_INCLUDE_DIR}/corehost/configure.h) add_subdirectory(${CLR_SRC_NATIVE_DIR}/corehost/apphost/static Corehost.Static) + target_include_directories(singlefilehost PRIVATE ${GENERATED_INCLUDE_DIR}/corehost) add_dependencies(runtime singlefilehost) endif() #------------------------- diff --git a/src/native/corehost/CMakeLists.txt b/src/native/corehost/CMakeLists.txt index 358b885724507..ea13460e6ffff 100644 --- a/src/native/corehost/CMakeLists.txt +++ b/src/native/corehost/CMakeLists.txt @@ -19,7 +19,38 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES GNU) add_compile_options($<$:-fno-use-cxa-atexit>) endif() +set(CMAKE_INCLUDE_CURRENT_DIR ON) +include_directories(${CMAKE_CURRENT_BINARY_DIR}) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) +include_directories(${CLR_ARTIFACTS_OBJ_DIR}) # Generated version files + +if (NOT ${CLR_SINGLE_FILE_HOST_ONLY}) + if("${CLI_CMAKE_PKG_RID}" STREQUAL "") + message(FATAL_ERROR "A minimum supported package rid is not specified (ex: win7-x86 or ubuntu.14.04-x64, osx.10.12-x64, rhel.7-x64)") + endif() + if("${CLI_CMAKE_COMMIT_HASH}" STREQUAL "") + message(FATAL_ERROR "Commit hash needs to be specified to build the host") + endif() +endif() + +if("${CLI_CMAKE_FALLBACK_OS}" STREQUAL "") + message(FATAL_ERROR "Fallback rid needs to be specified to build the host") +endif() + +if("${CLI_CMAKE_FALLBACK_OS}" STREQUAL "${CLR_CMAKE_TARGET_OS}") + add_definitions(-DFALLBACK_OS_IS_SAME_AS_TARGET_OS) +endif() + +configure_file(configure.h.in ${CMAKE_CURRENT_BINARY_DIR}/configure.h) + +# This is required to map a symbol reference to a matching definition local to the module (.so) +# containing the reference instead of using definitions from other modules. +if(CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_SUNOS) + add_link_options(LINKER:-Bsymbolic) +endif() + add_subdirectory(hostcommon) +add_subdirectory(hostmisc) add_subdirectory(fxr) add_subdirectory(hostpolicy) diff --git a/src/native/corehost/common.cmake b/src/native/corehost/common.cmake index 9a5e3a6686e07..501f5e095509b 100644 --- a/src/native/corehost/common.cmake +++ b/src/native/corehost/common.cmake @@ -3,17 +3,10 @@ project(${DOTNET_PROJECT_NAME}) -include(${CMAKE_CURRENT_LIST_DIR}/setup.cmake) - # Include directories if(CLR_CMAKE_TARGET_WIN32) include_directories("${CLI_CMAKE_RESOURCE_DIR}/${DOTNET_PROJECT_NAME}") endif() -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/) -include_directories(${CMAKE_CURRENT_LIST_DIR}/) -include_directories(${CMAKE_CURRENT_LIST_DIR}/../) -include_directories(${CMAKE_CURRENT_LIST_DIR}/hostmisc) -include_directories(${CLR_ARTIFACTS_OBJ_DIR}) # Generated version files set(RESOURCES) if (CLR_CMAKE_TARGET_WIN32) @@ -28,12 +21,6 @@ if(CLR_CMAKE_TARGET_WIN32) list(APPEND SOURCES ${HEADERS}) endif() -# This is required to map a symbol reference to a matching definition local to the module (.so) -# containing the reference instead of using definitions from other modules. -if(CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_SUNOS) - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Xlinker -Bsymbolic") -endif() - function(set_common_libs TargetType) # Libraries used for exe projects diff --git a/src/native/corehost/configure.h.in b/src/native/corehost/configure.h.in new file mode 100644 index 0000000000000..4ddf2e6cfa7b0 --- /dev/null +++ b/src/native/corehost/configure.h.in @@ -0,0 +1,23 @@ +#ifndef PAL_HOST_CONFIGURE_H_INCLUDED +#define PAL_HOST_CONFIGURE_H_INCLUDED + +#cmakedefine01 CLR_SINGLE_FILE_HOST_ONLY + +#ifdef CLR_SINGLE_FILE_HOST_ONLY +// When hosting components are all statically linked, +// the versioning information is irrelevant and may only come up in tracing. +// so we will use "static" +#define HOST_POLICY_PKG_NAME "static" +#define HOST_POLICY_PKG_REL_DIR "static" +#define REPO_COMMIT_HASH "static" +#else +#define HOST_POLICY_PKG_NAME "runtime.@CLI_CMAKE_PKG_RID@.Microsoft.NETCore.DotNetHostPolicy" +#define HOST_POLICY_PKG_REL_DIR "runtime.@CLI_CMAKE_PKG_RID@/native" +#define REPO_COMMIT_HASH "@CLI_CMAKE_COMMIT_HASH@" +#endif + +#define FALLBACK_HOST_OS "@CLI_CMAKE_FALLBACK_OS@" +#define CURRENT_OS_NAME "@CLR_CMAKE_TARGET_OS@" +#define CURRENT_ARCH_NAME "@CLR_CMAKE_TARGET_ARCH@" + +#endif // PAL_HOST_CONFIGURE_H_INCLUDED \ No newline at end of file diff --git a/src/native/corehost/exe.cmake b/src/native/corehost/exe.cmake index e4975923f1f23..d15c09a0d1fe6 100644 --- a/src/native/corehost/exe.cmake +++ b/src/native/corehost/exe.cmake @@ -4,7 +4,6 @@ project (${DOTNET_PROJECT_NAME}) include(${CMAKE_CURRENT_LIST_DIR}/common.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/hostmisc/hostmisc.cmake) # Include directories include_directories(${CMAKE_CURRENT_LIST_DIR}/fxr) @@ -20,6 +19,8 @@ list(APPEND HEADERS add_executable(${DOTNET_PROJECT_NAME} ${SOURCES} ${RESOURCES}) +target_link_libraries(${DOTNET_PROJECT_NAME} PRIVATE hostmisc) + add_sanitizer_runtime_support(${DOTNET_PROJECT_NAME}) if(NOT CLR_CMAKE_TARGET_WIN32) diff --git a/src/native/corehost/fxr/staticlib/CMakeLists.txt b/src/native/corehost/fxr/staticlib/CMakeLists.txt index 6ff3bc27f74c1..fdaa87c4b37ca 100644 --- a/src/native/corehost/fxr/staticlib/CMakeLists.txt +++ b/src/native/corehost/fxr/staticlib/CMakeLists.txt @@ -17,7 +17,6 @@ set(HEADERS include(../../hostcommon/files.cmake) include(../files.cmake) -include(../../hostmisc/hostmisc.cmake) include(../../lib_static.cmake) # Copy static lib PDB to the project output directory @@ -44,3 +43,5 @@ if (WIN32) else() install(TARGETS libhostfxr DESTINATION corehost) endif(WIN32) + +target_link_libraries(libhostfxr PRIVATE hostmisc) diff --git a/src/native/corehost/hostcommon/CMakeLists.txt b/src/native/corehost/hostcommon/CMakeLists.txt index 36b9d140cb95c..f9ab6b4a74d54 100644 --- a/src/native/corehost/hostcommon/CMakeLists.txt +++ b/src/native/corehost/hostcommon/CMakeLists.txt @@ -1,12 +1,22 @@ # Licensed to the .NET Foundation under one or more agreements. # The .NET Foundation licenses this file to you under the MIT license. -project(hostcommon) +include(files.cmake) -set(DOTNET_PROJECT_NAME "hostcommon") +add_library(libhostcommon STATIC ${SOURCES}) +target_compile_definitions(libhostcommon PUBLIC + _NO_ASYNCRTIMP + _NO_PPLXIMP) -include(files.cmake) +target_compile_definitions(libhostcommon PRIVATE EXPORT_SHARED_API) +set_target_properties(libhostcommon PROPERTIES MACOSX_RPATH TRUE) + +if (NOT CLR_CMAKE_TARGET_WIN32) + target_sources(libhostcommon PRIVATE ${VERSION_FILE_PATH}) +endif() -set(SKIP_VERSIONING 1) -include(../lib_static.cmake) +if (MSVC) + target_sources(libhostcommon PRIVATE ${HEADERS}) +endif() +target_link_libraries(libhostcommon PUBLIC hostmisc) diff --git a/src/native/corehost/hostmisc/hostmisc.cmake b/src/native/corehost/hostmisc/CMakeLists.txt similarity index 72% rename from src/native/corehost/hostmisc/hostmisc.cmake rename to src/native/corehost/hostmisc/CMakeLists.txt index 83233a9572ff4..4215d384a466d 100644 --- a/src/native/corehost/hostmisc/hostmisc.cmake +++ b/src/native/corehost/hostmisc/CMakeLists.txt @@ -1,18 +1,23 @@ # Licensed to the .NET Foundation under one or more agreements. # The .NET Foundation licenses this file to you under the MIT license. -include(${CMAKE_CURRENT_LIST_DIR}/configure.cmake) -include_directories(${CMAKE_CURRENT_BINARY_DIR}) -include_directories("${CLR_SRC_NATIVE_DIR}") +include(configure.cmake) + +add_library(hostmisc INTERFACE) + +target_include_directories(hostmisc INTERFACE + ${CMAKE_CURRENT_BINARY_DIR} + ${CLR_SRC_NATIVE_DIR} + ${CMAKE_CURRENT_LIST_DIR}) # CMake does not recommend using globbing since it messes with the freshness checks -list(APPEND SOURCES +set(SOURCES ${CMAKE_CURRENT_LIST_DIR}/trace.cpp ${CMAKE_CURRENT_LIST_DIR}/utils.cpp ${CMAKE_CURRENT_LIST_DIR}/../fxr/fx_ver.cpp ) -list(APPEND HEADERS +set(HEADERS ${CMAKE_CURRENT_LIST_DIR}/trace.h ${CMAKE_CURRENT_LIST_DIR}/utils.h ${CMAKE_CURRENT_LIST_DIR}/pal.h @@ -30,3 +35,9 @@ else() list(APPEND SOURCES ${CMAKE_CURRENT_LIST_DIR}/pal.unix.cpp) endif() + +target_sources(hostmisc INTERFACE ${SOURCES}) + +if (MSVC) + target_sources(hostmisc INTERFACE ${HEADERS}) +endif() \ No newline at end of file diff --git a/src/native/corehost/hostmisc/pal.h b/src/native/corehost/hostmisc/pal.h index f482b6df63456..02625a54f7621 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/lib.cmake b/src/native/corehost/lib.cmake index e61eb0a2b3900..e1be3da77c9d5 100644 --- a/src/native/corehost/lib.cmake +++ b/src/native/corehost/lib.cmake @@ -4,7 +4,6 @@ project(${DOTNET_PROJECT_NAME}) include(${CMAKE_CURRENT_LIST_DIR}/common.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/hostmisc/hostmisc.cmake) add_definitions(-D_NO_ASYNCRTIMP) add_definitions(-D_NO_PPLXIMP) @@ -12,6 +11,8 @@ add_definitions(-DEXPORT_SHARED_API=1) add_library(${DOTNET_PROJECT_NAME} SHARED ${SOURCES} ${RESOURCES}) +target_link_libraries(${DOTNET_PROJECT_NAME} PRIVATE hostmisc) + set_target_properties(${DOTNET_PROJECT_NAME} PROPERTIES MACOSX_RPATH TRUE) set_common_libs("lib") diff --git a/src/native/corehost/nethost/CMakeLists.txt b/src/native/corehost/nethost/CMakeLists.txt index 818ed9ced7fce..14dbf10010114 100644 --- a/src/native/corehost/nethost/CMakeLists.txt +++ b/src/native/corehost/nethost/CMakeLists.txt @@ -33,6 +33,9 @@ if (WIN32) ) endif(WIN32) +target_link_libraries(nethost PRIVATE hostmisc) +target_link_libraries(libnethost PRIVATE hostmisc) + install(FILES ../coreclr_delegates.h DESTINATION corehost) install(FILES ../hostfxr.h DESTINATION corehost) install(FILES nethost.h DESTINATION corehost) diff --git a/src/native/corehost/setup.cmake b/src/native/corehost/setup.cmake deleted file mode 100644 index 787d2ca775d3c..0000000000000 --- a/src/native/corehost/setup.cmake +++ /dev/null @@ -1,36 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. - -if(CLR_SINGLE_FILE_HOST_ONLY) - # CLR partition builds only the single file host where hosting components are all statically linked. - # the versioning information is irrelevant and may only come up in tracing. - # so we will use "static" - add_definitions(-DHOST_POLICY_PKG_NAME="static") - add_definitions(-DHOST_POLICY_PKG_REL_DIR="static") - add_definitions(-DREPO_COMMIT_HASH="static") -else() - if("${CLI_CMAKE_PKG_RID}" STREQUAL "") - message(FATAL_ERROR "A minimum supported package rid is not specified (ex: win7-x86 or ubuntu.14.04-x64, osx.10.12-x64, rhel.7-x64)") - else() - add_definitions(-DHOST_POLICY_PKG_NAME="runtime.${CLI_CMAKE_PKG_RID}.Microsoft.NETCore.DotNetHostPolicy") - add_definitions(-DHOST_POLICY_PKG_REL_DIR="runtimes/${CLI_CMAKE_PKG_RID}/native") - endif() - - if("${CLI_CMAKE_COMMIT_HASH}" STREQUAL "") - message(FATAL_ERROR "Commit hash needs to be specified to build the host") - else() - add_definitions(-DREPO_COMMIT_HASH="${CLI_CMAKE_COMMIT_HASH}") - endif() -endif() - -if("${CLI_CMAKE_FALLBACK_OS}" STREQUAL "") - message(FATAL_ERROR "Fallback rid needs to be specified to build the host") -else() - add_definitions(-DFALLBACK_HOST_OS="${CLI_CMAKE_FALLBACK_OS}") -endif() - -add_definitions(-DCURRENT_OS_NAME="${CLR_CMAKE_TARGET_OS}") -add_definitions(-DCURRENT_ARCH_NAME="${CLR_CMAKE_TARGET_ARCH}") -if("${CLI_CMAKE_FALLBACK_OS}" STREQUAL "${CLR_CMAKE_TARGET_OS}") - add_definitions(-DFALLBACK_OS_IS_SAME_AS_TARGET_OS) -endif() diff --git a/src/native/corehost/test/comsxs/CMakeLists.txt b/src/native/corehost/test/comsxs/CMakeLists.txt index 673e7f07bdde0..5d1ccbcdaaf14 100644 --- a/src/native/corehost/test/comsxs/CMakeLists.txt +++ b/src/native/corehost/test/comsxs/CMakeLists.txt @@ -13,6 +13,8 @@ set(SOURCES include(../testexe.cmake) +target_link_libraries(comsxs PRIVATE hostmisc) + target_link_libraries(comsxs PRIVATE ole32 oleaut32) install_with_stripped_symbols(comsxs TARGETS corehost_test) diff --git a/src/native/corehost/test/fx_ver/CMakeLists.txt b/src/native/corehost/test/fx_ver/CMakeLists.txt index ed39b965966c6..4de97d4ba6455 100644 --- a/src/native/corehost/test/fx_ver/CMakeLists.txt +++ b/src/native/corehost/test/fx_ver/CMakeLists.txt @@ -11,8 +11,6 @@ set(SOURCES test_fx_ver.cpp ) -include(${CMAKE_CURRENT_LIST_DIR}/../../hostmisc/hostmisc.cmake) - include(../testexe.cmake) -target_link_libraries(${DOTNET_PROJECT_NAME} PRIVATE libhostcommon) +target_link_libraries(${DOTNET_PROJECT_NAME} PRIVATE libhostcommon hostmisc) diff --git a/src/native/corehost/test/nativehost/CMakeLists.txt b/src/native/corehost/test/nativehost/CMakeLists.txt index 527ab578d3991..d41e2be549402 100644 --- a/src/native/corehost/test/nativehost/CMakeLists.txt +++ b/src/native/corehost/test/nativehost/CMakeLists.txt @@ -44,11 +44,9 @@ if(CLR_CMAKE_TARGET_WIN32) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DELAYLOAD:nethost.dll") endif() -include(../../hostmisc/hostmisc.cmake) - include(../testexe.cmake) -target_link_libraries(${DOTNET_PROJECT_NAME} PRIVATE nethost) +target_link_libraries(${DOTNET_PROJECT_NAME} PRIVATE nethost hostmisc) if (CLR_CMAKE_TARGET_WIN32) target_link_libraries(${DOTNET_PROJECT_NAME} PRIVATE delayimp.lib) From d5e23ce54d09e3d036a4c11196c6ee235f649b2b Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Mon, 20 May 2024 14:48:40 -0700 Subject: [PATCH 02/18] Move nethost away from the include(lib.cmake) model --- src/native/corehost/nethost/CMakeLists.txt | 39 +++++++++++++++++++--- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/src/native/corehost/nethost/CMakeLists.txt b/src/native/corehost/nethost/CMakeLists.txt index 14dbf10010114..d37cfee58a18d 100644 --- a/src/native/corehost/nethost/CMakeLists.txt +++ b/src/native/corehost/nethost/CMakeLists.txt @@ -19,22 +19,51 @@ if(CLR_CMAKE_TARGET_WIN32) Exports.def) endif() -include(../lib.cmake) -include(../lib_static.cmake) +if (CLR_CMAKE_TARGET_WIN32) + include_directories("${CLI_CMAKE_RESOURCE_DIR}/nethost") + list(APPEND SOURCES ../native.rc) +else() + list(APPEND SOURCES ${VERSION_FILE_PATH}) +endif() + +add_compile_definitions( + _NO_ASYNCRTIMP + _NO_PPLXIMP + EXPORT_SHARED_API + FEATURE_LIBHOST + NETHOST_EXPORT) + +add_library(nethost SHARED ${SOURCES}) +add_library(libnethost STATIC ${SOURCES}) -add_definitions(-DFEATURE_LIBHOST=1) -add_definitions(-DNETHOST_EXPORT) # Copy static lib PDB to the project output directory if (WIN32) set_target_properties(libnethost PROPERTIES COMPILE_PDB_NAME "libnethost" - COMPILE_PDB_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}" + COMPILE_PDB_OUTPUT_DIRECTORY "$" ) endif(WIN32) target_link_libraries(nethost PRIVATE hostmisc) target_link_libraries(libnethost PRIVATE hostmisc) +target_compile_definitions(nethost PRIVATE FEATURE_LIBHOST NETHOST_EXPORT) +target_compile_definitions(libnethost PRIVATE FEATURE_LIBHOST NETHOST_EXPORT) + +set_target_properties(nethost PROPERTIES MACOSX_RPATH TRUE) +set_target_properties(libnethost PROPERTIES MACOSX_RPATH TRUE) +set_target_properties(libnethost PROPERTIES PREFIX "") + +# Specify the import library to link against for Arm32 build since the default set is minimal +if (CLR_CMAKE_TARGET_ARCH_ARM) + if (CLR_CMAKE_TARGET_WIN32) + target_link_libraries(nethost PRIVATE shell32.lib advapi32.lib) + else() + target_link_libraries(nethost PRIVATE atomic.a) + endif() +endif() + +target_link_libraries (${DOTNET_PROJECT_NAME} PRIVATE ${CMAKE_DL_LIBS}) install(FILES ../coreclr_delegates.h DESTINATION corehost) install(FILES ../hostfxr.h DESTINATION corehost) From 224fe0bd964c0130ba073faefe0ce1cd8db7e994 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Mon, 20 May 2024 14:54:40 -0700 Subject: [PATCH 03/18] Move static hostfxr away from lib_static --- src/native/corehost/common.cmake | 19 +++++++---------- .../corehost/fxr/staticlib/CMakeLists.txt | 19 +++++++++++++++-- src/native/corehost/lib_static.cmake | 21 ------------------- 3 files changed, 25 insertions(+), 34 deletions(-) delete mode 100644 src/native/corehost/lib_static.cmake diff --git a/src/native/corehost/common.cmake b/src/native/corehost/common.cmake index 501f5e095509b..2f2dbb45a4e82 100644 --- a/src/native/corehost/common.cmake +++ b/src/native/corehost/common.cmake @@ -22,7 +22,6 @@ if(CLR_CMAKE_TARGET_WIN32) endif() function(set_common_libs TargetType) - # Libraries used for exe projects if (${TargetType} STREQUAL "exe") if((CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_FREEBSD) AND NOT CLR_CMAKE_TARGET_ANDROID) @@ -30,16 +29,14 @@ function(set_common_libs TargetType) endif() endif() - if (NOT ${TargetType} STREQUAL "lib-static") - # Specify the import library to link against for Arm32 build since the default set is minimal - if (CLR_CMAKE_TARGET_ARCH_ARM) - if (CLR_CMAKE_TARGET_WIN32) - target_link_libraries(${DOTNET_PROJECT_NAME} PRIVATE shell32.lib advapi32.lib) - else() - target_link_libraries(${DOTNET_PROJECT_NAME} PRIVATE atomic.a) - endif() + # Specify the import library to link against for Arm32 build since the default set is minimal + if (CLR_CMAKE_TARGET_ARCH_ARM) + if (CLR_CMAKE_TARGET_WIN32) + target_link_libraries(${DOTNET_PROJECT_NAME} PRIVATE shell32.lib advapi32.lib) + else() + target_link_libraries(${DOTNET_PROJECT_NAME} PRIVATE atomic.a) endif() - - target_link_libraries (${DOTNET_PROJECT_NAME} PRIVATE ${CMAKE_DL_LIBS}) endif() + + target_link_libraries (${DOTNET_PROJECT_NAME} PRIVATE ${CMAKE_DL_LIBS}) endfunction() diff --git a/src/native/corehost/fxr/staticlib/CMakeLists.txt b/src/native/corehost/fxr/staticlib/CMakeLists.txt index fdaa87c4b37ca..87adc9a1890ea 100644 --- a/src/native/corehost/fxr/staticlib/CMakeLists.txt +++ b/src/native/corehost/fxr/staticlib/CMakeLists.txt @@ -14,16 +14,31 @@ set(HEADERS ../hostpolicy_resolver.h ) +if (CLR_CMAKE_TARGET_WIN32) + include_directories("${CLI_CMAKE_RESOURCE_DIR}/hostfxr") + list(APPEND SOURCES ../../native.rc) +else() + list(APPEND SOURCES ${VERSION_FILE_PATH}) +endif() + +add_compile_definitions( + _NO_ASYNCRTIMP + _NO_PPLXIMP + EXPORT_SHARED_API) + include(../../hostcommon/files.cmake) include(../files.cmake) -include(../../lib_static.cmake) +add_library(libhostfxr STATIC ${SOURCES}) + +set_target_properties(libhostfxr PROPERTIES MACOSX_RPATH TRUE) +set_target_properties(libhostfxr PROPERTIES PREFIX "") # Copy static lib PDB to the project output directory if (WIN32) set_target_properties(libhostfxr PROPERTIES COMPILE_PDB_NAME "libhostfxr" - COMPILE_PDB_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}" + COMPILE_PDB_OUTPUT_DIRECTORY "$" ) endif(WIN32) diff --git a/src/native/corehost/lib_static.cmake b/src/native/corehost/lib_static.cmake deleted file mode 100644 index b6d8744e94e0e..0000000000000 --- a/src/native/corehost/lib_static.cmake +++ /dev/null @@ -1,21 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. - -project(lib${DOTNET_PROJECT_NAME}) - -include(${CMAKE_CURRENT_LIST_DIR}/common.cmake) - -add_definitions(-D_NO_ASYNCRTIMP) -add_definitions(-D_NO_PPLXIMP) -add_definitions(-DEXPORT_SHARED_API=1) - -if (BUILD_OBJECT_LIBRARY) - add_library(lib${DOTNET_PROJECT_NAME} OBJECT ${SOURCES} ${RESOURCES}) -else () - add_library(lib${DOTNET_PROJECT_NAME} STATIC ${SOURCES} ${RESOURCES}) -endif () - -set_target_properties(lib${DOTNET_PROJECT_NAME} PROPERTIES MACOSX_RPATH TRUE) -set_target_properties(lib${DOTNET_PROJECT_NAME} PROPERTIES PREFIX "") - -set_common_libs("lib-static") From e4f8259076a0b4601c6baa9aa9b8190942c3cc02 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Mon, 20 May 2024 15:04:12 -0700 Subject: [PATCH 04/18] Inline pal::initialize_create_dump to enable building the PAL once into an object library. --- src/native/corehost/corehost.cpp | 8 +++++++- src/native/corehost/hostmisc/pal.h | 2 -- src/native/corehost/hostmisc/pal.unix.cpp | 11 ----------- src/native/corehost/hostmisc/pal.windows.cpp | 4 ---- 4 files changed, 7 insertions(+), 18 deletions(-) diff --git a/src/native/corehost/corehost.cpp b/src/native/corehost/corehost.cpp index 5edc2fbf5d521..7cbc8790b03b2 100644 --- a/src/native/corehost/corehost.cpp +++ b/src/native/corehost/corehost.cpp @@ -97,9 +97,15 @@ void need_newer_framework_error(const pal::string_t& dotnet_root, const pal::str #if defined(CURHOST_EXE) +#if defined(FEATURE_STATIC_HOST) && (defined(TARGET_OSX) || defined(TARGET_LINUX)) && !defined(TARGET_X86) +extern void initialize_static_createdump(); +#endif + int exe_start(const int argc, const pal::char_t* argv[]) { - pal::initialize_createdump(); +#if defined(FEATURE_STATIC_HOST) && (defined(TARGET_OSX) || defined(TARGET_LINUX)) && !defined(TARGET_X86) + initialize_static_createdump(); +#endif pal::string_t host_path; if (!pal::get_own_executable_path(&host_path) || !pal::realpath(&host_path)) diff --git a/src/native/corehost/hostmisc/pal.h b/src/native/corehost/hostmisc/pal.h index 02625a54f7621..8aea41a2f07b4 100644 --- a/src/native/corehost/hostmisc/pal.h +++ b/src/native/corehost/hostmisc/pal.h @@ -348,8 +348,6 @@ namespace pal bool is_emulating_x64(); bool are_paths_equal_with_normalized_casing(const string_t& path1, const string_t& path2); - - void initialize_createdump(); } #endif // PAL_H diff --git a/src/native/corehost/hostmisc/pal.unix.cpp b/src/native/corehost/hostmisc/pal.unix.cpp index bdd8796c5d8e0..b690b1f100ae8 100644 --- a/src/native/corehost/hostmisc/pal.unix.cpp +++ b/src/native/corehost/hostmisc/pal.unix.cpp @@ -1121,14 +1121,3 @@ bool pal::are_paths_equal_with_normalized_casing(const string_t& path1, const st return path1 == path2; #endif } - -#if defined(FEATURE_STATIC_HOST) && (defined(TARGET_OSX) || defined(TARGET_LINUX)) && !defined(TARGET_X86) -extern void initialize_static_createdump(); -#endif - -void pal::initialize_createdump() -{ -#if defined(FEATURE_STATIC_HOST) && (defined(TARGET_OSX) || defined(TARGET_LINUX)) && !defined(TARGET_X86) - initialize_static_createdump(); -#endif -} diff --git a/src/native/corehost/hostmisc/pal.windows.cpp b/src/native/corehost/hostmisc/pal.windows.cpp index b11610492d321..966725dc93880 100644 --- a/src/native/corehost/hostmisc/pal.windows.cpp +++ b/src/native/corehost/hostmisc/pal.windows.cpp @@ -941,7 +941,3 @@ void pal::mutex_t::unlock() { ::LeaveCriticalSection(&_impl); } - -void pal::initialize_createdump() -{ -} From 1c6217d7b851ffce6049f6e3a0ae157c2be891e7 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Mon, 20 May 2024 16:05:29 -0700 Subject: [PATCH 05/18] Convert test libs to the new model --- src/native/corehost/CMakeLists.txt | 2 ++ src/native/corehost/common.cmake | 11 ----------- .../corehost/fxr/standalone/CMakeLists.txt | 2 +- src/native/corehost/hostmisc/CMakeLists.txt | 9 ++++++++- src/native/corehost/test/CMakeLists.txt | 3 +-- src/native/corehost/test/comsxs/CMakeLists.txt | 18 ++++-------------- src/native/corehost/test/ijw/CMakeLists.txt | 9 ++------- .../corehost/test/mockcoreclr/CMakeLists.txt | 14 +++++--------- .../test/mockhostfxr/2_2/CMakeLists.txt | 16 ---------------- .../test/mockhostfxr/5_0/CMakeLists.txt | 16 ---------------- .../corehost/test/mockhostfxr/CMakeLists.txt | 14 ++++++++++++++ .../test/mockhostpolicy/CMakeLists.txt | 10 +++------- src/native/corehost/test/testlib.cmake | 8 -------- 13 files changed, 40 insertions(+), 92 deletions(-) delete mode 100644 src/native/corehost/test/mockhostfxr/2_2/CMakeLists.txt delete mode 100644 src/native/corehost/test/mockhostfxr/5_0/CMakeLists.txt create mode 100644 src/native/corehost/test/mockhostfxr/CMakeLists.txt delete mode 100644 src/native/corehost/test/testlib.cmake diff --git a/src/native/corehost/CMakeLists.txt b/src/native/corehost/CMakeLists.txt index ea13460e6ffff..f323c3b978ded 100644 --- a/src/native/corehost/CMakeLists.txt +++ b/src/native/corehost/CMakeLists.txt @@ -4,6 +4,8 @@ project(corehost) include(../../../eng/native/configurepaths.cmake) include(${CLR_ENG_NATIVE_DIR}/configurecompiler.cmake) +set(COREHOST_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}") + if (MSVC) # Host components don't try to handle asynchronous exceptions set_property(DIRECTORY PROPERTY CLR_EH_OPTION /EHsc) diff --git a/src/native/corehost/common.cmake b/src/native/corehost/common.cmake index 2f2dbb45a4e82..58f5c4e6566e5 100644 --- a/src/native/corehost/common.cmake +++ b/src/native/corehost/common.cmake @@ -28,15 +28,4 @@ function(set_common_libs TargetType) target_link_libraries (${DOTNET_PROJECT_NAME} PRIVATE "pthread") endif() endif() - - # Specify the import library to link against for Arm32 build since the default set is minimal - if (CLR_CMAKE_TARGET_ARCH_ARM) - if (CLR_CMAKE_TARGET_WIN32) - target_link_libraries(${DOTNET_PROJECT_NAME} PRIVATE shell32.lib advapi32.lib) - else() - target_link_libraries(${DOTNET_PROJECT_NAME} PRIVATE atomic.a) - endif() - endif() - - target_link_libraries (${DOTNET_PROJECT_NAME} PRIVATE ${CMAKE_DL_LIBS}) endfunction() diff --git a/src/native/corehost/fxr/standalone/CMakeLists.txt b/src/native/corehost/fxr/standalone/CMakeLists.txt index a809a653cce18..74820e5b25123 100644 --- a/src/native/corehost/fxr/standalone/CMakeLists.txt +++ b/src/native/corehost/fxr/standalone/CMakeLists.txt @@ -42,5 +42,5 @@ install_with_stripped_symbols(hostfxr TARGETS corehost) target_link_libraries(hostfxr PRIVATE libhostcommon) if (CLR_CMAKE_TARGET_ARCH_ARMV6) - target_link_libraries(${DOTNET_PROJECT_NAME} PRIVATE atomic) + target_link_libraries(hostfxr PRIVATE atomic) endif() diff --git a/src/native/corehost/hostmisc/CMakeLists.txt b/src/native/corehost/hostmisc/CMakeLists.txt index 4215d384a466d..4ac5c11c59f9b 100644 --- a/src/native/corehost/hostmisc/CMakeLists.txt +++ b/src/native/corehost/hostmisc/CMakeLists.txt @@ -40,4 +40,11 @@ target_sources(hostmisc INTERFACE ${SOURCES}) if (MSVC) target_sources(hostmisc INTERFACE ${HEADERS}) -endif() \ No newline at end of file + target_link_libraries(hostmisc INTERFACE advapi32) +endif() + +if (CLR_CMAKE_TARGET_ARCH_ARM AND NOT CLR_CMAKE_TARGET_WIN32) + target_link_libraries(hostmisc INTERFACE atomic) +endif() + +target_link_libraries (hostmisc INTERFACE ${CMAKE_DL_LIBS}) \ No newline at end of file diff --git a/src/native/corehost/test/CMakeLists.txt b/src/native/corehost/test/CMakeLists.txt index fac7e76baf6a7..4310a0e8449b3 100644 --- a/src/native/corehost/test/CMakeLists.txt +++ b/src/native/corehost/test/CMakeLists.txt @@ -1,7 +1,6 @@ add_subdirectory(fx_ver) add_subdirectory(mockcoreclr) -add_subdirectory(mockhostfxr/2_2) -add_subdirectory(mockhostfxr/5_0) +add_subdirectory(mockhostfxr) add_subdirectory(mockhostpolicy) add_subdirectory(nativehost) if (NOT RUNTIME_FLAVOR STREQUAL Mono) diff --git a/src/native/corehost/test/comsxs/CMakeLists.txt b/src/native/corehost/test/comsxs/CMakeLists.txt index 5d1ccbcdaaf14..17aa0898be001 100644 --- a/src/native/corehost/test/comsxs/CMakeLists.txt +++ b/src/native/corehost/test/comsxs/CMakeLists.txt @@ -1,20 +1,10 @@ # Licensed to the .NET Foundation under one or more agreements. # The .NET Foundation licenses this file to you under the MIT license. -project(comsxs) +add_executable(comsxs + comsxs.cpp + App.manifest) -set(DOTNET_PROJECT_NAME "comsxs") - -set(SOURCES - ./comsxs.cpp - ./App.manifest -) - - -include(../testexe.cmake) - -target_link_libraries(comsxs PRIVATE hostmisc) - -target_link_libraries(comsxs PRIVATE ole32 oleaut32) +target_link_libraries(comsxs PRIVATE hostmisc ole32 oleaut32 shell32 advapi32) install_with_stripped_symbols(comsxs TARGETS corehost_test) diff --git a/src/native/corehost/test/ijw/CMakeLists.txt b/src/native/corehost/test/ijw/CMakeLists.txt index 9e90cfdcf069a..9fbd72412d4c8 100644 --- a/src/native/corehost/test/ijw/CMakeLists.txt +++ b/src/native/corehost/test/ijw/CMakeLists.txt @@ -1,15 +1,10 @@ # Licensed to the .NET Foundation under one or more agreements. # The .NET Foundation licenses this file to you under the MIT license. -project(ijw) - -set(SOURCES - ./ijw.cpp) - include(${CLR_ENG_NATIVE_DIR}/ijw/IJW.cmake) -add_library(ijw SHARED ${SOURCES}) -target_link_libraries(ijw PRIVATE ${LINK_LIBRARIES_ADDITIONAL}) +add_library(ijw SHARED ijw.cpp) +target_link_libraries(ijw PRIVATE ijwhost) remove_ijw_incompatible_target_options(ijw) add_ijw_msbuild_project_properties(ijw ijwhost) diff --git a/src/native/corehost/test/mockcoreclr/CMakeLists.txt b/src/native/corehost/test/mockcoreclr/CMakeLists.txt index f7e202fbc1dff..5d809d84b5d56 100644 --- a/src/native/corehost/test/mockcoreclr/CMakeLists.txt +++ b/src/native/corehost/test/mockcoreclr/CMakeLists.txt @@ -1,19 +1,15 @@ # Licensed to the .NET Foundation under one or more agreements. # The .NET Foundation licenses this file to you under the MIT license. -project(mockcoreclr) - -set(DOTNET_PROJECT_NAME "mockcoreclr") - -set(SOURCES - ./mockcoreclr.cpp -) +add_library(mockcoreclr SHARED mockcoreclr.cpp) if(CLR_CMAKE_TARGET_WIN32) - list(APPEND SOURCES + target_sources(mockcoreclr PRIVATE mockcoreclr.def) endif() -include(../testlib.cmake) +target_link_libraries(mockcoreclr PRIVATE hostmisc) + +target_compile_definitions(mockcoreclr PRIVATE EXPORT_SHARED_API) install_with_stripped_symbols(mockcoreclr TARGETS corehost_test) diff --git a/src/native/corehost/test/mockhostfxr/2_2/CMakeLists.txt b/src/native/corehost/test/mockhostfxr/2_2/CMakeLists.txt deleted file mode 100644 index 096c3631afbc8..0000000000000 --- a/src/native/corehost/test/mockhostfxr/2_2/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. - -project(mockhostfxr_2_2) - -set(DOTNET_PROJECT_NAME "mockhostfxr_2_2") - -add_definitions(-D_MOCKHOSTFXR_2_2) - -set(SOURCES - ./../mockhostfxr.cpp -) - -include(../../testlib.cmake) - -install_with_stripped_symbols(mockhostfxr_2_2 TARGETS corehost_test) diff --git a/src/native/corehost/test/mockhostfxr/5_0/CMakeLists.txt b/src/native/corehost/test/mockhostfxr/5_0/CMakeLists.txt deleted file mode 100644 index 5f9f36c71852a..0000000000000 --- a/src/native/corehost/test/mockhostfxr/5_0/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. - -project(mockhostfxr_5_0) - -set(DOTNET_PROJECT_NAME "mockhostfxr_5_0") - -add_definitions(-DMOCKHOSTFXR_5_0) - -set(SOURCES - ./../mockhostfxr.cpp -) - -include(../../testlib.cmake) - -install_with_stripped_symbols(mockhostfxr_5_0 TARGETS corehost_test) diff --git a/src/native/corehost/test/mockhostfxr/CMakeLists.txt b/src/native/corehost/test/mockhostfxr/CMakeLists.txt new file mode 100644 index 0000000000000..6820b27d84715 --- /dev/null +++ b/src/native/corehost/test/mockhostfxr/CMakeLists.txt @@ -0,0 +1,14 @@ +# Licensed to the .NET Foundation under one or more agreements. +# The .NET Foundation licenses this file to you under the MIT license. + +add_library(mockhostfxr_2_2 SHARED mockhostfxr.cpp) +add_library(mockhostfxr_5_0 SHARED mockhostfxr.cpp) + +target_link_libraries(mockhostfxr_2_2 PRIVATE libhostcommon) +target_link_libraries(mockhostfxr_5_0 PRIVATE libhostcommon) + +target_compile_definitions(mockhostfxr_2_2 PRIVATE MOCKHOSTFXR_2_2 EXPORT_SHARED_API) +target_compile_definitions(mockhostfxr_5_0 PRIVATE MOCKHOSTFXR_5_0 EXPORT_SHARED_API) + +install_with_stripped_symbols(mockhostfxr_2_2 TARGETS corehost_test) +install_with_stripped_symbols(mockhostfxr_5_0 TARGETS corehost_test) \ No newline at end of file diff --git a/src/native/corehost/test/mockhostpolicy/CMakeLists.txt b/src/native/corehost/test/mockhostpolicy/CMakeLists.txt index 146cf010e3fa6..d89c06d8d563d 100644 --- a/src/native/corehost/test/mockhostpolicy/CMakeLists.txt +++ b/src/native/corehost/test/mockhostpolicy/CMakeLists.txt @@ -1,14 +1,10 @@ # Licensed to the .NET Foundation under one or more agreements. # The .NET Foundation licenses this file to you under the MIT license. -project(mockhostpolicy) +add_library(mockhostpolicy SHARED mockhostpolicy.cpp) -set(DOTNET_PROJECT_NAME "mockhostpolicy") +target_link_libraries(mockhostpolicy PRIVATE hostmisc) -set(SOURCES - ./mockhostpolicy.cpp -) - -include(../testlib.cmake) +target_compile_definitions(mockhostpolicy PRIVATE EXPORT_SHARED_API) install_with_stripped_symbols(mockhostpolicy TARGETS corehost_test) \ No newline at end of file diff --git a/src/native/corehost/test/testlib.cmake b/src/native/corehost/test/testlib.cmake deleted file mode 100644 index 6031136fb9750..0000000000000 --- a/src/native/corehost/test/testlib.cmake +++ /dev/null @@ -1,8 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. - -project(${DOTNET_PROJECT_NAME}) - -set(SKIP_VERSIONING 1) - -include(${CMAKE_CURRENT_LIST_DIR}/../lib.cmake) From 836e7c841c145910149c6ce04d90e19a607cbbdb Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Mon, 20 May 2024 16:21:06 -0700 Subject: [PATCH 06/18] Remove usage of testexe.cmake --- src/native/corehost/hostmisc/CMakeLists.txt | 6 +++++- .../corehost/test/comsxs/CMakeLists.txt | 2 ++ .../corehost/test/fx_ver/CMakeLists.txt | 13 ++++++------ .../corehost/test/nativehost/CMakeLists.txt | 20 ++++++++++++------- src/native/corehost/test/testexe.cmake | 16 --------------- 5 files changed, 26 insertions(+), 31 deletions(-) delete mode 100644 src/native/corehost/test/testexe.cmake diff --git a/src/native/corehost/hostmisc/CMakeLists.txt b/src/native/corehost/hostmisc/CMakeLists.txt index 4ac5c11c59f9b..9f7b1ca13dacc 100644 --- a/src/native/corehost/hostmisc/CMakeLists.txt +++ b/src/native/corehost/hostmisc/CMakeLists.txt @@ -47,4 +47,8 @@ if (CLR_CMAKE_TARGET_ARCH_ARM AND NOT CLR_CMAKE_TARGET_WIN32) target_link_libraries(hostmisc INTERFACE atomic) endif() -target_link_libraries (hostmisc INTERFACE ${CMAKE_DL_LIBS}) \ No newline at end of file +target_link_libraries (hostmisc INTERFACE ${CMAKE_DL_LIBS}) + +if((CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_FREEBSD) AND NOT CLR_CMAKE_TARGET_ANDROID) + target_link_libraries (hostmisc INTERFACE pthread) +endif() \ No newline at end of file diff --git a/src/native/corehost/test/comsxs/CMakeLists.txt b/src/native/corehost/test/comsxs/CMakeLists.txt index 17aa0898be001..fe6ca24c47219 100644 --- a/src/native/corehost/test/comsxs/CMakeLists.txt +++ b/src/native/corehost/test/comsxs/CMakeLists.txt @@ -5,6 +5,8 @@ add_executable(comsxs comsxs.cpp App.manifest) +add_sanitizer_runtime_support(test_fx_ver) + target_link_libraries(comsxs PRIVATE hostmisc ole32 oleaut32 shell32 advapi32) install_with_stripped_symbols(comsxs TARGETS corehost_test) diff --git a/src/native/corehost/test/fx_ver/CMakeLists.txt b/src/native/corehost/test/fx_ver/CMakeLists.txt index 4de97d4ba6455..35935695648c3 100644 --- a/src/native/corehost/test/fx_ver/CMakeLists.txt +++ b/src/native/corehost/test/fx_ver/CMakeLists.txt @@ -1,16 +1,15 @@ # Copyright (c) .NET Foundation and contributors. All rights reserved. # Licensed under the MIT license. See LICENSE file in the project root for full license information. - -project(test_fx_ver) - -set(DOTNET_PROJECT_NAME "test_fx_ver") - include_directories(../../fxr) set(SOURCES test_fx_ver.cpp ) -include(../testexe.cmake) +add_executable(test_fx_ver test_fx_ver.cpp) + +add_sanitizer_runtime_support(test_fx_ver) + +target_link_libraries(test_fx_ver PRIVATE libhostcommon hostmisc) -target_link_libraries(${DOTNET_PROJECT_NAME} PRIVATE libhostcommon hostmisc) +install_with_stripped_symbols(test_fx_ver TARGETS corehost_test) diff --git a/src/native/corehost/test/nativehost/CMakeLists.txt b/src/native/corehost/test/nativehost/CMakeLists.txt index d41e2be549402..7ff27d495eabb 100644 --- a/src/native/corehost/test/nativehost/CMakeLists.txt +++ b/src/native/corehost/test/nativehost/CMakeLists.txt @@ -3,8 +3,6 @@ project(nativehost) -set(DOTNET_PROJECT_NAME "nativehost") - set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) set(MACOSX_RPATH ON) if (CLR_CMAKE_TARGET_OSX) @@ -44,19 +42,27 @@ if(CLR_CMAKE_TARGET_WIN32) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DELAYLOAD:nethost.dll") endif() -include(../testexe.cmake) +add_executable(nativehost ${SOURCES}) + +add_sanitizer_runtime_support(nativehost) + +install_with_stripped_symbols(nativehost TARGETS corehost_test) + +if((CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_FREEBSD) AND NOT CLR_CMAKE_TARGET_ANDROID) + target_link_libraries (nativehost PRIVATE pthread) +endif() -target_link_libraries(${DOTNET_PROJECT_NAME} PRIVATE nethost hostmisc) +target_link_libraries(nativehost PRIVATE nethost hostmisc) if (CLR_CMAKE_TARGET_WIN32) - target_link_libraries(${DOTNET_PROJECT_NAME} PRIVATE delayimp.lib) + target_link_libraries(nativehost PRIVATE delayimp.lib) endif() # Specify non-default Windows libs to be used for Arm/Arm64 builds if (CLR_CMAKE_TARGET_WIN32 AND (CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_ARCH_ARM64)) - target_link_libraries(${DOTNET_PROJECT_NAME} PRIVATE Ole32.lib OleAut32.lib) + target_link_libraries(nativehost PRIVATE ole32 oleaut32) endif() if (CLR_CMAKE_TARGET_ARCH_ARMV6) - target_link_libraries(${DOTNET_PROJECT_NAME} PRIVATE atomic) + target_link_libraries(nativehost PRIVATE atomic) endif() diff --git a/src/native/corehost/test/testexe.cmake b/src/native/corehost/test/testexe.cmake deleted file mode 100644 index 75538c7090a67..0000000000000 --- a/src/native/corehost/test/testexe.cmake +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. - -project(${DOTNET_PROJECT_NAME}) - -set(SKIP_VERSIONING 1) - -include(${CMAKE_CURRENT_LIST_DIR}/../common.cmake) - -add_executable(${DOTNET_PROJECT_NAME} ${SOURCES}) - -add_sanitizer_runtime_support(${DOTNET_PROJECT_NAME}) - -install_with_stripped_symbols(${DOTNET_PROJECT_NAME} TARGETS corehost_test) - -set_common_libs("exe") From 63c3e2ef03d280008f01c3cff05837fb821437c7 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Mon, 20 May 2024 16:30:13 -0700 Subject: [PATCH 07/18] Clean up nativehost --- src/native/corehost/nethost/CMakeLists.txt | 5 ++++- src/native/corehost/test/nativehost/CMakeLists.txt | 5 +---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/native/corehost/nethost/CMakeLists.txt b/src/native/corehost/nethost/CMakeLists.txt index d37cfee58a18d..e40ce5acf0250 100644 --- a/src/native/corehost/nethost/CMakeLists.txt +++ b/src/native/corehost/nethost/CMakeLists.txt @@ -36,6 +36,8 @@ add_compile_definitions( add_library(nethost SHARED ${SOURCES}) add_library(libnethost STATIC ${SOURCES}) +target_include_directories(nethost PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +target_include_directories(libnethost PUBLIC $) # Copy static lib PDB to the project output directory if (WIN32) @@ -63,7 +65,8 @@ if (CLR_CMAKE_TARGET_ARCH_ARM) endif() endif() -target_link_libraries (${DOTNET_PROJECT_NAME} PRIVATE ${CMAKE_DL_LIBS}) +target_link_libraries (nethost PRIVATE ${CMAKE_DL_LIBS}) +target_link_libraries (libnethost PUBLIC ${CMAKE_DL_LIBS}) install(FILES ../coreclr_delegates.h DESTINATION corehost) install(FILES ../hostfxr.h DESTINATION corehost) diff --git a/src/native/corehost/test/nativehost/CMakeLists.txt b/src/native/corehost/test/nativehost/CMakeLists.txt index 7ff27d495eabb..2cc54691e6ebf 100644 --- a/src/native/corehost/test/nativehost/CMakeLists.txt +++ b/src/native/corehost/test/nativehost/CMakeLists.txt @@ -11,8 +11,6 @@ else() set(CMAKE_INSTALL_RPATH "\$ORIGIN") endif() -include_directories(${CMAKE_CURRENT_LIST_DIR}/../../nethost) - set(SOURCES ./error_writer_redirector.cpp ./get_native_search_directories_test.cpp @@ -38,8 +36,6 @@ if(CLR_CMAKE_TARGET_WIN32) list(APPEND HEADERS ./comhost_test.h) - - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DELAYLOAD:nethost.dll") endif() add_executable(nativehost ${SOURCES}) @@ -55,6 +51,7 @@ endif() target_link_libraries(nativehost PRIVATE nethost hostmisc) if (CLR_CMAKE_TARGET_WIN32) + target_link_options(nativehost PRIVATE /DELAYLOAD:$) target_link_libraries(nativehost PRIVATE delayimp.lib) endif() From a47e8bc3b3f6d918ef850594dd85fec60a19d9c0 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Mon, 20 May 2024 17:23:12 -0700 Subject: [PATCH 08/18] Move everyone off of lib.cmake and exe.cmake --- src/native/corehost/CMakeLists.txt | 22 +++++++++++++ .../apphost/standalone/CMakeLists.txt | 33 +++++++++++-------- .../corehost/apphost/static/CMakeLists.txt | 32 ++++++++++++------ src/native/corehost/comhost/CMakeLists.txt | 11 +++---- src/native/corehost/common.cmake | 31 ----------------- src/native/corehost/dotnet/CMakeLists.txt | 16 ++++++--- src/native/corehost/exe.cmake | 32 ------------------ .../corehost/fxr/standalone/CMakeLists.txt | 6 +++- .../corehost/fxr/staticlib/CMakeLists.txt | 11 ++----- src/native/corehost/hostmisc/CMakeLists.txt | 6 +++- .../hostpolicy/standalone/CMakeLists.txt | 9 +++-- src/native/corehost/ijwhost/CMakeLists.txt | 15 +++++---- src/native/corehost/lib.cmake | 18 ---------- src/native/corehost/nethost/CMakeLists.txt | 12 ++----- 14 files changed, 107 insertions(+), 147 deletions(-) delete mode 100644 src/native/corehost/common.cmake delete mode 100644 src/native/corehost/exe.cmake delete mode 100644 src/native/corehost/lib.cmake diff --git a/src/native/corehost/CMakeLists.txt b/src/native/corehost/CMakeLists.txt index f323c3b978ded..f4417d9cf99a9 100644 --- a/src/native/corehost/CMakeLists.txt +++ b/src/native/corehost/CMakeLists.txt @@ -45,12 +45,34 @@ endif() configure_file(configure.h.in ${CMAKE_CURRENT_BINARY_DIR}/configure.h) +# add_resources_to_target(targetName [resourceDirName]) +function(add_resources_to_target targetName) + set(RESOURCE_INCLUDE_DIR ${targetName}) + if (${ARGC} GREATER 1) + set(RESOURCE_INCLUDE_DIR ${ARGV1}) + endif() + + if (CLR_CMAKE_TARGET_WIN32) + target_sources(${targetName} PRIVATE ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/native.rc) + set_property(SOURCE ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/native.rc + TARGET_DIRECTORY ${targetName} + APPEND PROPERTY INCLUDE_DIRECTORIES + ${CLI_CMAKE_RESOURCE_DIR}/${RESOURCE_INCLUDE_DIR}) + else() + target_sources(${targetName} PRIVATE ${VERSION_FILE_PATH}) + endif() +endfunction() + # This is required to map a symbol reference to a matching definition local to the module (.so) # containing the reference instead of using definitions from other modules. if(CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_SUNOS) add_link_options(LINKER:-Bsymbolic) endif() +add_library(hostfxr_resolver INTERFACE) +target_sources(hostfxr_resolver INTERFACE fxr_resolver.cpp corehost.cpp) +target_include_directories(hostfxr_resolver INTERFACE fxr) + add_subdirectory(hostcommon) add_subdirectory(hostmisc) add_subdirectory(fxr) diff --git a/src/native/corehost/apphost/standalone/CMakeLists.txt b/src/native/corehost/apphost/standalone/CMakeLists.txt index 8a6a23934d85d..054094dada376 100644 --- a/src/native/corehost/apphost/standalone/CMakeLists.txt +++ b/src/native/corehost/apphost/standalone/CMakeLists.txt @@ -1,9 +1,6 @@ # Licensed to the .NET Foundation under one or more agreements. # The .NET Foundation licenses this file to you under the MIT license. -project(apphost) -set(DOTNET_PROJECT_NAME "apphost") - # Add RPATH to the apphost binary that allows using local copies of shared libraries # dotnet core depends on for special scenarios when system wide installation of such # dependencies is not possible for some reason. @@ -14,8 +11,6 @@ if (NOT CLR_CMAKE_TARGET_OSX) set(CMAKE_INSTALL_RPATH "\$ORIGIN/netcoredeps") endif() -set(SKIP_VERSIONING 1) - include_directories(..) set(SOURCES @@ -29,7 +24,7 @@ set(HEADERS ) if(CLR_CMAKE_TARGET_WIN32) - add_definitions(-DUNICODE) + add_compile_definitions(UNICODE) list(APPEND SOURCES ../apphost.windows.cpp) @@ -37,21 +32,31 @@ if(CLR_CMAKE_TARGET_WIN32) ../apphost.windows.h) endif() -include(../../exe.cmake) +if(CLR_CMAKE_TARGET_WIN32) + list(APPEND SOURCES ${HEADERS}) +endif() + +add_compile_definitions(FEATURE_APPHOST) + +add_executable(apphost ${SOURCES} ${RESOURCES}) -add_definitions(-DFEATURE_APPHOST=1) +target_link_libraries(apphost PRIVATE hostmisc hostfxr_resolver) + +add_sanitizer_runtime_support(apphost) + +if(NOT CLR_CMAKE_TARGET_WIN32) + disable_pax_mprotect(apphost) +endif() + +install_with_stripped_symbols(apphost TARGETS corehost) # Disable manifest generation into the file .exe on Windows if(CLR_CMAKE_TARGET_WIN32) - set_property(TARGET ${PROJECT_NAME} PROPERTY - LINK_FLAGS "/MANIFEST:NO" - ) + add_link_options(apphost PRIVATE "/MANIFEST:NO") endif() # Specify non-default Windows libs to be used for Arm64 builds -if (CLR_CMAKE_TARGET_WIN32 AND CLR_CMAKE_TARGET_ARCH_ARM64) - target_link_libraries(apphost PRIVATE shell32.lib) -endif() +target_link_libraries(apphost PRIVATE shell32) if (CLR_CMAKE_HOST_APPLE) adhoc_sign_with_entitlements(apphost "${CLR_ENG_NATIVE_DIR}/entitlements.plist") diff --git a/src/native/corehost/apphost/static/CMakeLists.txt b/src/native/corehost/apphost/static/CMakeLists.txt index 7a14c7c92ed66..820ba76fc67ce 100644 --- a/src/native/corehost/apphost/static/CMakeLists.txt +++ b/src/native/corehost/apphost/static/CMakeLists.txt @@ -14,29 +14,34 @@ if (NOT CLR_CMAKE_TARGET_APPLE) set(CMAKE_INSTALL_RPATH "\$ORIGIN/netcoredeps") endif() -set(SKIP_VERSIONING 1) - include_directories(..) +include_directories(../..) +include_directories(../../hostmisc) include_directories(../../json) include_directories(${CLR_SRC_NATIVE_DIR}/libs/System.IO.Compression.Native) include_directories(${CLR_SRC_NATIVE_DIR}/libs/Common) +include_directories(${CLR_ARTIFACTS_OBJ_DIR}) # Generated version files + +add_subdirectory(../../hostmisc hostmisc) set(SOURCES ../bundle_marker.cpp ./hostfxr_resolver.cpp ./hostpolicy_resolver.cpp ../../hostpolicy/static/coreclr_resolver.cpp + ../../fxr_resolver.cpp + ../../corehost.cpp ) set(HEADERS ../bundle_marker.h ../../hostfxr_resolver.h + ../../fxr_resolver.h ) -add_definitions(-D_NO_ASYNCRTIMP) -add_definitions(-D_NO_PPLXIMP) -remove_definitions(-DEXPORT_SHARED_API) -add_definitions(-DNATIVE_LIBS_EMBEDDED) +add_compile_definitions(_NO_ASYNCRTIMP + _NO_PPLXIMP + NATIVE_LIBS_EMBEDDED) include(../../fxr/files.cmake) include(../../hostpolicy/files.cmake) @@ -52,7 +57,7 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES GNU) endif() if(CLR_CMAKE_TARGET_WIN32) - add_definitions(-DUNICODE) + add_compile_definitions(UNICODE) list(APPEND SOURCES ../apphost.windows.cpp ${CLR_SRC_NATIVE_DIR}/libs/Common/delayloadhook_windows.cpp @@ -78,11 +83,16 @@ else() set_exports_linker_option(${EXPORTS_FILE}) endif() -if (CLR_SINGLE_FILE_HOST_ONLY) - set(ADDITIONAL_INSTALL_ARGUMENTS COMPONENT runtime) +add_executable(singlefilehost ${SOURCES}) + +add_sanitizer_runtime_support(singlefilehost) + +if(NOT CLR_CMAKE_TARGET_WIN32) + disable_pax_mprotect(singlefilehost) endif() -include(../../exe.cmake) +install_with_stripped_symbols(singlefilehost TARGETS corehost COMPONENT runtime) + include(configure.cmake) if(CLR_CMAKE_HOST_UNIX) @@ -262,4 +272,6 @@ target_link_libraries( ${END_WHOLE_ARCHIVE} ) +target_link_libraries(singlefilehost PRIVATE hostmisc) + add_sanitizer_runtime_support(singlefilehost) diff --git a/src/native/corehost/comhost/CMakeLists.txt b/src/native/corehost/comhost/CMakeLists.txt index 9f777bff56997..39b7c65e4a418 100644 --- a/src/native/corehost/comhost/CMakeLists.txt +++ b/src/native/corehost/comhost/CMakeLists.txt @@ -1,10 +1,6 @@ # Licensed to the .NET Foundation under one or more agreements. # The .NET Foundation licenses this file to you under the MIT license. -project(comhost) - -set(DOTNET_PROJECT_NAME "comhost") - # Include directories include_directories(../fxr) include_directories(../json) @@ -26,9 +22,12 @@ if(CLR_CMAKE_TARGET_WIN32) Exports.def) endif() -include(../lib.cmake) +add_compile_definitions(FEATURE_LIBHOST) +add_compile_definitions(EXPORT_SHARED_API) + +add_library(comhost SHARED ${SOURCES}) -add_definitions(-DFEATURE_LIBHOST=1) +add_resources_to_target(comhost) if (CLR_CMAKE_TARGET_WIN32) set(WINLIBS wintrust.lib) diff --git a/src/native/corehost/common.cmake b/src/native/corehost/common.cmake deleted file mode 100644 index 58f5c4e6566e5..0000000000000 --- a/src/native/corehost/common.cmake +++ /dev/null @@ -1,31 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. - -project(${DOTNET_PROJECT_NAME}) - -# Include directories -if(CLR_CMAKE_TARGET_WIN32) - include_directories("${CLI_CMAKE_RESOURCE_DIR}/${DOTNET_PROJECT_NAME}") -endif() - -set(RESOURCES) -if (CLR_CMAKE_TARGET_WIN32) - if (NOT SKIP_VERSIONING) - list(APPEND RESOURCES ${CMAKE_CURRENT_LIST_DIR}/native.rc) - endif() -else() - list(APPEND SOURCES ${VERSION_FILE_PATH}) -endif() - -if(CLR_CMAKE_TARGET_WIN32) - list(APPEND SOURCES ${HEADERS}) -endif() - -function(set_common_libs TargetType) - # Libraries used for exe projects - if (${TargetType} STREQUAL "exe") - if((CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_FREEBSD) AND NOT CLR_CMAKE_TARGET_ANDROID) - target_link_libraries (${DOTNET_PROJECT_NAME} PRIVATE "pthread") - endif() - endif() -endfunction() diff --git a/src/native/corehost/dotnet/CMakeLists.txt b/src/native/corehost/dotnet/CMakeLists.txt index d670b95e879c2..45b0f8a5aaf2b 100644 --- a/src/native/corehost/dotnet/CMakeLists.txt +++ b/src/native/corehost/dotnet/CMakeLists.txt @@ -1,9 +1,6 @@ # Licensed to the .NET Foundation under one or more agreements. # The .NET Foundation licenses this file to you under the MIT license. -project(dotnet) -set(DOTNET_PROJECT_NAME "dotnet") - if(CLR_CMAKE_TARGET_WIN32) list(APPEND SOURCES dotnet.manifest @@ -14,7 +11,18 @@ list(APPEND SOURCES ../apphost/standalone/hostfxr_resolver.cpp ) -include(../exe.cmake) +add_executable(dotnet ${SOURCES}) + +target_link_libraries(dotnet PRIVATE hostmisc hostfxr_resolver) + +add_sanitizer_runtime_support(dotnet) + +if(NOT CLR_CMAKE_TARGET_WIN32) + disable_pax_mprotect(dotnet) +endif() + +install_with_stripped_symbols(dotnet TARGETS corehost) +add_resources_to_target(dotnet) if (CLR_CMAKE_HOST_APPLE) adhoc_sign_with_entitlements(dotnet "${CLR_ENG_NATIVE_DIR}/entitlements.plist") diff --git a/src/native/corehost/exe.cmake b/src/native/corehost/exe.cmake deleted file mode 100644 index d15c09a0d1fe6..0000000000000 --- a/src/native/corehost/exe.cmake +++ /dev/null @@ -1,32 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. - -project (${DOTNET_PROJECT_NAME}) - -include(${CMAKE_CURRENT_LIST_DIR}/common.cmake) - -# Include directories -include_directories(${CMAKE_CURRENT_LIST_DIR}/fxr) - -# CMake does not recommend using globbing since it messes with the freshness checks -list(APPEND SOURCES - ${CMAKE_CURRENT_LIST_DIR}/fxr_resolver.cpp - ${CMAKE_CURRENT_LIST_DIR}/corehost.cpp -) -list(APPEND HEADERS - ${CMAKE_CURRENT_LIST_DIR}/hostfxr_resolver.h -) - -add_executable(${DOTNET_PROJECT_NAME} ${SOURCES} ${RESOURCES}) - -target_link_libraries(${DOTNET_PROJECT_NAME} PRIVATE hostmisc) - -add_sanitizer_runtime_support(${DOTNET_PROJECT_NAME}) - -if(NOT CLR_CMAKE_TARGET_WIN32) - disable_pax_mprotect(${DOTNET_PROJECT_NAME}) -endif() - -install_with_stripped_symbols(${DOTNET_PROJECT_NAME} TARGETS corehost ${ADDITIONAL_INSTALL_ARGUMENTS}) - -set_common_libs("exe") diff --git a/src/native/corehost/fxr/standalone/CMakeLists.txt b/src/native/corehost/fxr/standalone/CMakeLists.txt index 74820e5b25123..74562483cbbd7 100644 --- a/src/native/corehost/fxr/standalone/CMakeLists.txt +++ b/src/native/corehost/fxr/standalone/CMakeLists.txt @@ -27,7 +27,11 @@ else(CLR_CMAKE_TARGET_WIN32) set_exports_linker_option(${EXPORTS_FILE}) endif(CLR_CMAKE_TARGET_WIN32) -include(../../lib.cmake) +add_compile_definitions(EXPORT_SHARED_API) + +add_library(hostfxr SHARED ${SOURCES}) + +add_resources_to_target(hostfxr) if(CLR_CMAKE_HOST_UNIX) add_custom_target(hostfxr_exports DEPENDS ${EXPORTS_FILE}) diff --git a/src/native/corehost/fxr/staticlib/CMakeLists.txt b/src/native/corehost/fxr/staticlib/CMakeLists.txt index 87adc9a1890ea..2d8a154631bca 100644 --- a/src/native/corehost/fxr/staticlib/CMakeLists.txt +++ b/src/native/corehost/fxr/staticlib/CMakeLists.txt @@ -14,16 +14,7 @@ set(HEADERS ../hostpolicy_resolver.h ) -if (CLR_CMAKE_TARGET_WIN32) - include_directories("${CLI_CMAKE_RESOURCE_DIR}/hostfxr") - list(APPEND SOURCES ../../native.rc) -else() - list(APPEND SOURCES ${VERSION_FILE_PATH}) -endif() - add_compile_definitions( - _NO_ASYNCRTIMP - _NO_PPLXIMP EXPORT_SHARED_API) include(../../hostcommon/files.cmake) @@ -31,6 +22,8 @@ include(../files.cmake) add_library(libhostfxr STATIC ${SOURCES}) +add_resources_to_target(libhostfxr hostfxr) + set_target_properties(libhostfxr PROPERTIES MACOSX_RPATH TRUE) set_target_properties(libhostfxr PROPERTIES PREFIX "") diff --git a/src/native/corehost/hostmisc/CMakeLists.txt b/src/native/corehost/hostmisc/CMakeLists.txt index 9f7b1ca13dacc..0f56a0d04e76a 100644 --- a/src/native/corehost/hostmisc/CMakeLists.txt +++ b/src/native/corehost/hostmisc/CMakeLists.txt @@ -51,4 +51,8 @@ target_link_libraries (hostmisc INTERFACE ${CMAKE_DL_LIBS}) if((CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_FREEBSD) AND NOT CLR_CMAKE_TARGET_ANDROID) target_link_libraries (hostmisc INTERFACE pthread) -endif() \ No newline at end of file +endif() + +target_compile_definitions(hostmisc INTERFACE + _NO_ASYNCRTIMP + _NO_PPLXIMP) \ No newline at end of file diff --git a/src/native/corehost/hostpolicy/standalone/CMakeLists.txt b/src/native/corehost/hostpolicy/standalone/CMakeLists.txt index f977c733d9968..0d4ba542a7d3f 100644 --- a/src/native/corehost/hostpolicy/standalone/CMakeLists.txt +++ b/src/native/corehost/hostpolicy/standalone/CMakeLists.txt @@ -1,10 +1,6 @@ # Licensed to the .NET Foundation under one or more agreements. # The .NET Foundation licenses this file to you under the MIT license. -project(hostpolicy) - -set(DOTNET_PROJECT_NAME "hostpolicy") - set(SOURCES ./coreclr_resolver.cpp ) @@ -22,7 +18,10 @@ else(CLR_CMAKE_TARGET_WIN32) set_exports_linker_option(${EXPORTS_FILE}) endif(CLR_CMAKE_TARGET_WIN32) -include(../../lib.cmake) +add_compile_definitions(EXPORT_SHARED_API) + +add_library(hostpolicy SHARED ${SOURCES}) +add_resources_to_target(hostpolicy) if(CLR_CMAKE_HOST_UNIX) add_custom_target(hostpolicy_exports DEPENDS ${EXPORTS_FILE}) diff --git a/src/native/corehost/ijwhost/CMakeLists.txt b/src/native/corehost/ijwhost/CMakeLists.txt index 1661f162974d5..a7538d175dde8 100644 --- a/src/native/corehost/ijwhost/CMakeLists.txt +++ b/src/native/corehost/ijwhost/CMakeLists.txt @@ -1,10 +1,6 @@ # Licensed to the .NET Foundation under one or more agreements. # The .NET Foundation licenses this file to you under the MIT license. -project(ijwhost) - -set(DOTNET_PROJECT_NAME "ijwhost") - # Include directories include_directories(../fxr) include_directories(${ARCH_SOURCES_DIR}) @@ -27,7 +23,7 @@ endif() set (ASM_HELPERS_SOURCES ${ARCH_SOURCES_DIR}/asmhelpers.asm) -add_definitions(-DFEATURE_LIBHOST=1) +add_compile_definitions(FEATURE_LIBHOST) convert_to_absolute_path(SOURCES ${SOURCES}) convert_to_absolute_path(ASM_HELPERS_SOURCES ${ASM_HELPERS_SOURCES}) @@ -45,11 +41,16 @@ endif () list(APPEND SOURCES ${ASM_HELPERS_SOURCES}) -include(../lib.cmake) +add_compile_definitions(EXPORT_SHARED_API) + +add_library(ijwhost SHARED ${SOURCES} ${RESOURCES}) +add_resources_to_target(ijwhost) + +target_link_libraries(ijwhost PRIVATE hostmisc) # Specify non-default Windows libs to be used for Arm64 builds if (CLR_CMAKE_TARGET_WIN32 AND CLR_CMAKE_TARGET_ARCH_ARM64) - target_link_libraries(ijwhost PRIVATE Ole32.lib) + target_link_libraries(ijwhost PRIVATE ole32) endif() install_with_stripped_symbols(ijwhost TARGETS corehost) diff --git a/src/native/corehost/lib.cmake b/src/native/corehost/lib.cmake deleted file mode 100644 index e1be3da77c9d5..0000000000000 --- a/src/native/corehost/lib.cmake +++ /dev/null @@ -1,18 +0,0 @@ -# Licensed to the .NET Foundation under one or more agreements. -# The .NET Foundation licenses this file to you under the MIT license. - -project(${DOTNET_PROJECT_NAME}) - -include(${CMAKE_CURRENT_LIST_DIR}/common.cmake) - -add_definitions(-D_NO_ASYNCRTIMP) -add_definitions(-D_NO_PPLXIMP) -add_definitions(-DEXPORT_SHARED_API=1) - -add_library(${DOTNET_PROJECT_NAME} SHARED ${SOURCES} ${RESOURCES}) - -target_link_libraries(${DOTNET_PROJECT_NAME} PRIVATE hostmisc) - -set_target_properties(${DOTNET_PROJECT_NAME} PROPERTIES MACOSX_RPATH TRUE) - -set_common_libs("lib") diff --git a/src/native/corehost/nethost/CMakeLists.txt b/src/native/corehost/nethost/CMakeLists.txt index e40ce5acf0250..f870000463dd2 100644 --- a/src/native/corehost/nethost/CMakeLists.txt +++ b/src/native/corehost/nethost/CMakeLists.txt @@ -19,16 +19,7 @@ if(CLR_CMAKE_TARGET_WIN32) Exports.def) endif() -if (CLR_CMAKE_TARGET_WIN32) - include_directories("${CLI_CMAKE_RESOURCE_DIR}/nethost") - list(APPEND SOURCES ../native.rc) -else() - list(APPEND SOURCES ${VERSION_FILE_PATH}) -endif() - add_compile_definitions( - _NO_ASYNCRTIMP - _NO_PPLXIMP EXPORT_SHARED_API FEATURE_LIBHOST NETHOST_EXPORT) @@ -36,6 +27,9 @@ add_compile_definitions( add_library(nethost SHARED ${SOURCES}) add_library(libnethost STATIC ${SOURCES}) +add_resources_to_target(nethost) +add_resources_to_target(libnethost nethost) + target_include_directories(nethost PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_include_directories(libnethost PUBLIC $) From 179c666ab60c9297b89024f6bf9dc3eaefa93aac Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Mon, 20 May 2024 17:30:35 -0700 Subject: [PATCH 09/18] Change how fxr_resolver.cpp is shared between targets --- src/native/corehost/CMakeLists.txt | 6 +++--- .../corehost/apphost/standalone/CMakeLists.txt | 3 ++- src/native/corehost/comhost/CMakeLists.txt | 4 +--- src/native/corehost/dotnet/CMakeLists.txt | 3 ++- src/native/corehost/ijwhost/CMakeLists.txt | 7 +------ src/native/corehost/nethost/CMakeLists.txt | 12 ++---------- 6 files changed, 11 insertions(+), 24 deletions(-) diff --git a/src/native/corehost/CMakeLists.txt b/src/native/corehost/CMakeLists.txt index f4417d9cf99a9..a3c300619495a 100644 --- a/src/native/corehost/CMakeLists.txt +++ b/src/native/corehost/CMakeLists.txt @@ -69,9 +69,9 @@ if(CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_SUNOS) add_link_options(LINKER:-Bsymbolic) endif() -add_library(hostfxr_resolver INTERFACE) -target_sources(hostfxr_resolver INTERFACE fxr_resolver.cpp corehost.cpp) -target_include_directories(hostfxr_resolver INTERFACE fxr) +add_library(fxr_resolver INTERFACE) +target_sources(fxr_resolver INTERFACE fxr_resolver.cpp) +target_include_directories(fxr_resolver INTERFACE fxr) add_subdirectory(hostcommon) add_subdirectory(hostmisc) diff --git a/src/native/corehost/apphost/standalone/CMakeLists.txt b/src/native/corehost/apphost/standalone/CMakeLists.txt index 054094dada376..d2f17fd464d71 100644 --- a/src/native/corehost/apphost/standalone/CMakeLists.txt +++ b/src/native/corehost/apphost/standalone/CMakeLists.txt @@ -16,6 +16,7 @@ include_directories(..) set(SOURCES ../bundle_marker.cpp ./hostfxr_resolver.cpp + ../../corehost.cpp ) set(HEADERS @@ -40,7 +41,7 @@ add_compile_definitions(FEATURE_APPHOST) add_executable(apphost ${SOURCES} ${RESOURCES}) -target_link_libraries(apphost PRIVATE hostmisc hostfxr_resolver) +target_link_libraries(apphost PRIVATE hostmisc fxr_resolver) add_sanitizer_runtime_support(apphost) diff --git a/src/native/corehost/comhost/CMakeLists.txt b/src/native/corehost/comhost/CMakeLists.txt index 39b7c65e4a418..8602ca92abe78 100644 --- a/src/native/corehost/comhost/CMakeLists.txt +++ b/src/native/corehost/comhost/CMakeLists.txt @@ -2,13 +2,11 @@ # The .NET Foundation licenses this file to you under the MIT license. # Include directories -include_directories(../fxr) include_directories(../json) # CMake does not recommend using globbing since it messes with the freshness checks set(SOURCES comhost.cpp - ../fxr_resolver.cpp clsidmap.cpp ../redirected_error_writer.cpp ) @@ -41,4 +39,4 @@ if (CLR_CMAKE_TARGET_WIN32) endif() install_with_stripped_symbols(comhost TARGETS corehost) -target_link_libraries(comhost PRIVATE libhostcommon) +target_link_libraries(comhost PRIVATE libhostcommon fxr_resolver) diff --git a/src/native/corehost/dotnet/CMakeLists.txt b/src/native/corehost/dotnet/CMakeLists.txt index 45b0f8a5aaf2b..94366783da16d 100644 --- a/src/native/corehost/dotnet/CMakeLists.txt +++ b/src/native/corehost/dotnet/CMakeLists.txt @@ -9,11 +9,12 @@ endif() list(APPEND SOURCES ../apphost/standalone/hostfxr_resolver.cpp + ../corehost.cpp ) add_executable(dotnet ${SOURCES}) -target_link_libraries(dotnet PRIVATE hostmisc hostfxr_resolver) +target_link_libraries(dotnet PRIVATE hostmisc fxr_resolver) add_sanitizer_runtime_support(dotnet) diff --git a/src/native/corehost/ijwhost/CMakeLists.txt b/src/native/corehost/ijwhost/CMakeLists.txt index a7538d175dde8..9db4a2f28884e 100644 --- a/src/native/corehost/ijwhost/CMakeLists.txt +++ b/src/native/corehost/ijwhost/CMakeLists.txt @@ -2,14 +2,12 @@ # The .NET Foundation licenses this file to you under the MIT license. # Include directories -include_directories(../fxr) include_directories(${ARCH_SOURCES_DIR}) # CMake does not recommend using globbing since it messes with the freshness checks set(SOURCES ijwthunk.cpp ijwhost.cpp - ../fxr_resolver.cpp pedecoder.cpp bootstrap_thunk_chunk.cpp ${ARCH_SOURCES_DIR}/bootstrap_thunk.cpp @@ -25,9 +23,6 @@ set (ASM_HELPERS_SOURCES add_compile_definitions(FEATURE_LIBHOST) -convert_to_absolute_path(SOURCES ${SOURCES}) -convert_to_absolute_path(ASM_HELPERS_SOURCES ${ASM_HELPERS_SOURCES}) - if (CLR_CMAKE_TARGET_WIN32 AND CLR_CMAKE_TARGET_ARCH_ARM64) preprocess_files(ASM_HELPERS_SOURCES ${ASM_HELPERS_SOURCES}) if (CMAKE_GENERATOR MATCHES "Visual Studio") @@ -46,7 +41,7 @@ add_compile_definitions(EXPORT_SHARED_API) add_library(ijwhost SHARED ${SOURCES} ${RESOURCES}) add_resources_to_target(ijwhost) -target_link_libraries(ijwhost PRIVATE hostmisc) +target_link_libraries(ijwhost PRIVATE hostmisc fxr_resolver) # Specify non-default Windows libs to be used for Arm64 builds if (CLR_CMAKE_TARGET_WIN32 AND CLR_CMAKE_TARGET_ARCH_ARM64) diff --git a/src/native/corehost/nethost/CMakeLists.txt b/src/native/corehost/nethost/CMakeLists.txt index f870000463dd2..6410d09484c99 100644 --- a/src/native/corehost/nethost/CMakeLists.txt +++ b/src/native/corehost/nethost/CMakeLists.txt @@ -1,17 +1,9 @@ # Licensed to the .NET Foundation under one or more agreements. # The .NET Foundation licenses this file to you under the MIT license. -project(nethost) - -set(DOTNET_PROJECT_NAME "nethost") - -# Include directories -include_directories(../fxr) - # CMake does not recommend using globbing since it messes with the freshness checks set(SOURCES nethost.cpp - ../fxr_resolver.cpp ) if(CLR_CMAKE_TARGET_WIN32) @@ -41,8 +33,8 @@ if (WIN32) ) endif(WIN32) -target_link_libraries(nethost PRIVATE hostmisc) -target_link_libraries(libnethost PRIVATE hostmisc) +target_link_libraries(nethost PRIVATE hostmisc fxr_resolver) +target_link_libraries(libnethost PRIVATE hostmisc fxr_resolver) target_compile_definitions(nethost PRIVATE FEATURE_LIBHOST NETHOST_EXPORT) target_compile_definitions(libnethost PRIVATE FEATURE_LIBHOST NETHOST_EXPORT) From de0c33399a9a7bec55eb514e1dc7db535f7a4f37 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Mon, 20 May 2024 17:34:26 -0700 Subject: [PATCH 10/18] Clean up libatomic references --- src/native/corehost/hostmisc/CMakeLists.txt | 2 +- .../corehost/hostpolicy/standalone/CMakeLists.txt | 4 ++++ src/native/corehost/nethost/CMakeLists.txt | 9 --------- src/native/corehost/test/nativehost/CMakeLists.txt | 10 +--------- 4 files changed, 6 insertions(+), 19 deletions(-) diff --git a/src/native/corehost/hostmisc/CMakeLists.txt b/src/native/corehost/hostmisc/CMakeLists.txt index 0f56a0d04e76a..b415944631e53 100644 --- a/src/native/corehost/hostmisc/CMakeLists.txt +++ b/src/native/corehost/hostmisc/CMakeLists.txt @@ -43,7 +43,7 @@ if (MSVC) target_link_libraries(hostmisc INTERFACE advapi32) endif() -if (CLR_CMAKE_TARGET_ARCH_ARM AND NOT CLR_CMAKE_TARGET_WIN32) +if (CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_ARCH_ARMV6 AND NOT CLR_CMAKE_TARGET_WIN32) target_link_libraries(hostmisc INTERFACE atomic) endif() diff --git a/src/native/corehost/hostpolicy/standalone/CMakeLists.txt b/src/native/corehost/hostpolicy/standalone/CMakeLists.txt index 0d4ba542a7d3f..a8fbfc8f81e67 100644 --- a/src/native/corehost/hostpolicy/standalone/CMakeLists.txt +++ b/src/native/corehost/hostpolicy/standalone/CMakeLists.txt @@ -37,3 +37,7 @@ target_link_libraries(hostpolicy PRIVATE libhostcommon) if((CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_FREEBSD) AND NOT CLR_CMAKE_TARGET_ANDROID) target_link_libraries (hostpolicy PRIVATE pthread) endif() + +if (CLR_CMAKE_TARGET_ARCH_ARMV6) + target_link_libraries(hostfxr PRIVATE atomic) +endif() \ No newline at end of file diff --git a/src/native/corehost/nethost/CMakeLists.txt b/src/native/corehost/nethost/CMakeLists.txt index 6410d09484c99..f7f4af3dd94d9 100644 --- a/src/native/corehost/nethost/CMakeLists.txt +++ b/src/native/corehost/nethost/CMakeLists.txt @@ -42,15 +42,6 @@ set_target_properties(nethost PROPERTIES MACOSX_RPATH TRUE) set_target_properties(libnethost PROPERTIES MACOSX_RPATH TRUE) set_target_properties(libnethost PROPERTIES PREFIX "") -# Specify the import library to link against for Arm32 build since the default set is minimal -if (CLR_CMAKE_TARGET_ARCH_ARM) - if (CLR_CMAKE_TARGET_WIN32) - target_link_libraries(nethost PRIVATE shell32.lib advapi32.lib) - else() - target_link_libraries(nethost PRIVATE atomic.a) - endif() -endif() - target_link_libraries (nethost PRIVATE ${CMAKE_DL_LIBS}) target_link_libraries (libnethost PUBLIC ${CMAKE_DL_LIBS}) diff --git a/src/native/corehost/test/nativehost/CMakeLists.txt b/src/native/corehost/test/nativehost/CMakeLists.txt index 2cc54691e6ebf..49aefdf96bd44 100644 --- a/src/native/corehost/test/nativehost/CMakeLists.txt +++ b/src/native/corehost/test/nativehost/CMakeLists.txt @@ -52,14 +52,6 @@ target_link_libraries(nativehost PRIVATE nethost hostmisc) if (CLR_CMAKE_TARGET_WIN32) target_link_options(nativehost PRIVATE /DELAYLOAD:$) - target_link_libraries(nativehost PRIVATE delayimp.lib) + target_link_libraries(nativehost PRIVATE delayimp.lib ole32 oleaut32) endif() -# Specify non-default Windows libs to be used for Arm/Arm64 builds -if (CLR_CMAKE_TARGET_WIN32 AND (CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_ARCH_ARM64)) - target_link_libraries(nativehost PRIVATE ole32 oleaut32) -endif() - -if (CLR_CMAKE_TARGET_ARCH_ARMV6) - target_link_libraries(nativehost PRIVATE atomic) -endif() From 96fdb3fc39dd88dc752479605379685e2c1bf305 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Mon, 20 May 2024 17:41:03 -0700 Subject: [PATCH 11/18] Change how we reference atomic and pthread support libraries to make it smoother --- src/native/corehost/CMakeLists.txt | 4 ++++ src/native/corehost/fxr/standalone/CMakeLists.txt | 6 +++--- src/native/corehost/hostmisc/CMakeLists.txt | 13 ++++--------- .../corehost/hostpolicy/standalone/CMakeLists.txt | 10 +++------- src/native/corehost/test/nativehost/CMakeLists.txt | 6 +++--- 5 files changed, 17 insertions(+), 22 deletions(-) diff --git a/src/native/corehost/CMakeLists.txt b/src/native/corehost/CMakeLists.txt index a3c300619495a..497e583bd3225 100644 --- a/src/native/corehost/CMakeLists.txt +++ b/src/native/corehost/CMakeLists.txt @@ -43,6 +43,10 @@ if("${CLI_CMAKE_FALLBACK_OS}" STREQUAL "${CLR_CMAKE_TARGET_OS}") add_definitions(-DFALLBACK_OS_IS_SAME_AS_TARGET_OS) endif() +# Find support libraries that we need if they're present on the system. +find_library(PTHREAD_LIB pthread) +find_library(ATOMIC_SUPPORT_LIB atomic) + configure_file(configure.h.in ${CMAKE_CURRENT_BINARY_DIR}/configure.h) # add_resources_to_target(targetName [resourceDirName]) diff --git a/src/native/corehost/fxr/standalone/CMakeLists.txt b/src/native/corehost/fxr/standalone/CMakeLists.txt index 74562483cbbd7..a0f51a5e200ef 100644 --- a/src/native/corehost/fxr/standalone/CMakeLists.txt +++ b/src/native/corehost/fxr/standalone/CMakeLists.txt @@ -45,6 +45,6 @@ install_with_stripped_symbols(hostfxr TARGETS corehost) target_link_libraries(hostfxr PRIVATE libhostcommon) -if (CLR_CMAKE_TARGET_ARCH_ARMV6) - target_link_libraries(hostfxr PRIVATE atomic) -endif() +target_link_libraries(hostfxr PRIVATE + $<$:${ATOMIC_SUPPORT_LIB}>) + diff --git a/src/native/corehost/hostmisc/CMakeLists.txt b/src/native/corehost/hostmisc/CMakeLists.txt index b415944631e53..e1009e5682e84 100644 --- a/src/native/corehost/hostmisc/CMakeLists.txt +++ b/src/native/corehost/hostmisc/CMakeLists.txt @@ -43,15 +43,10 @@ if (MSVC) target_link_libraries(hostmisc INTERFACE advapi32) endif() -if (CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_ARCH_ARMV6 AND NOT CLR_CMAKE_TARGET_WIN32) - target_link_libraries(hostmisc INTERFACE atomic) -endif() - -target_link_libraries (hostmisc INTERFACE ${CMAKE_DL_LIBS}) - -if((CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_FREEBSD) AND NOT CLR_CMAKE_TARGET_ANDROID) - target_link_libraries (hostmisc INTERFACE pthread) -endif() +target_link_libraries(hostmisc INTERFACE + ${CMAKE_DL_LIBS} + $<$:${ATOMIC_SUPPORT_LIB}> + $<$:${PTHREAD_LIB}>) target_compile_definitions(hostmisc INTERFACE _NO_ASYNCRTIMP diff --git a/src/native/corehost/hostpolicy/standalone/CMakeLists.txt b/src/native/corehost/hostpolicy/standalone/CMakeLists.txt index a8fbfc8f81e67..1928c868e91d3 100644 --- a/src/native/corehost/hostpolicy/standalone/CMakeLists.txt +++ b/src/native/corehost/hostpolicy/standalone/CMakeLists.txt @@ -34,10 +34,6 @@ endif(CLR_CMAKE_HOST_UNIX) install_with_stripped_symbols(hostpolicy TARGETS corehost) target_link_libraries(hostpolicy PRIVATE libhostcommon) -if((CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_FREEBSD) AND NOT CLR_CMAKE_TARGET_ANDROID) - target_link_libraries (hostpolicy PRIVATE pthread) -endif() - -if (CLR_CMAKE_TARGET_ARCH_ARMV6) - target_link_libraries(hostfxr PRIVATE atomic) -endif() \ No newline at end of file +target_link_libraries(hostpolicy PRIVATE + $<$:${ATOMIC_SUPPORT_LIB}> + $<$:${PTHREAD_LIB}>) diff --git a/src/native/corehost/test/nativehost/CMakeLists.txt b/src/native/corehost/test/nativehost/CMakeLists.txt index 49aefdf96bd44..a3c9ed9fa24a3 100644 --- a/src/native/corehost/test/nativehost/CMakeLists.txt +++ b/src/native/corehost/test/nativehost/CMakeLists.txt @@ -44,9 +44,9 @@ add_sanitizer_runtime_support(nativehost) install_with_stripped_symbols(nativehost TARGETS corehost_test) -if((CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_FREEBSD) AND NOT CLR_CMAKE_TARGET_ANDROID) - target_link_libraries (nativehost PRIVATE pthread) -endif() +target_link_libraries(nativehost PRIVATE + $<$:${PTHREAD_LIB}>) + target_link_libraries(nativehost PRIVATE nethost hostmisc) From af2f6c183fa95d2021af8d58f49cf37356775301 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Mon, 20 May 2024 22:57:27 -0700 Subject: [PATCH 12/18] Make shell32 Windows-only --- src/native/corehost/apphost/standalone/CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/native/corehost/apphost/standalone/CMakeLists.txt b/src/native/corehost/apphost/standalone/CMakeLists.txt index d2f17fd464d71..8470ca92df5c1 100644 --- a/src/native/corehost/apphost/standalone/CMakeLists.txt +++ b/src/native/corehost/apphost/standalone/CMakeLists.txt @@ -56,8 +56,9 @@ if(CLR_CMAKE_TARGET_WIN32) add_link_options(apphost PRIVATE "/MANIFEST:NO") endif() -# Specify non-default Windows libs to be used for Arm64 builds -target_link_libraries(apphost PRIVATE shell32) +if (CLR_CMAKE_TARGET_WIN32) + target_link_libraries(apphost PRIVATE shell32) +endif() if (CLR_CMAKE_HOST_APPLE) adhoc_sign_with_entitlements(apphost "${CLR_ENG_NATIVE_DIR}/entitlements.plist") From 58601365b9076173aa830df5bb3047bc30db692d Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 21 May 2024 11:13:33 -0700 Subject: [PATCH 13/18] Add back convert_to_absolute_path for asm sources --- src/native/corehost/ijwhost/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/native/corehost/ijwhost/CMakeLists.txt b/src/native/corehost/ijwhost/CMakeLists.txt index 9db4a2f28884e..3ad39fff777ec 100644 --- a/src/native/corehost/ijwhost/CMakeLists.txt +++ b/src/native/corehost/ijwhost/CMakeLists.txt @@ -21,6 +21,8 @@ endif() set (ASM_HELPERS_SOURCES ${ARCH_SOURCES_DIR}/asmhelpers.asm) +convert_to_absolute_path(ASM_HELPERS_SOURCES ${ASM_HELPERS_SOURCES}) + add_compile_definitions(FEATURE_LIBHOST) if (CLR_CMAKE_TARGET_WIN32 AND CLR_CMAKE_TARGET_ARCH_ARM64) From 1d169b21c1f891fc92ede02c450c81e7c9cbd435 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 21 May 2024 11:16:46 -0700 Subject: [PATCH 14/18] Only link libatomic on arm32 --- src/native/corehost/fxr/standalone/CMakeLists.txt | 5 +++-- src/native/corehost/hostmisc/CMakeLists.txt | 6 +++++- src/native/corehost/hostpolicy/standalone/CMakeLists.txt | 7 ++++--- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/native/corehost/fxr/standalone/CMakeLists.txt b/src/native/corehost/fxr/standalone/CMakeLists.txt index a0f51a5e200ef..78e85cf0c7dea 100644 --- a/src/native/corehost/fxr/standalone/CMakeLists.txt +++ b/src/native/corehost/fxr/standalone/CMakeLists.txt @@ -45,6 +45,7 @@ install_with_stripped_symbols(hostfxr TARGETS corehost) target_link_libraries(hostfxr PRIVATE libhostcommon) -target_link_libraries(hostfxr PRIVATE +if(CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_ARCH_ARMV6) + target_link_libraries(hostfxr INTERFACE $<$:${ATOMIC_SUPPORT_LIB}>) - +endif() diff --git a/src/native/corehost/hostmisc/CMakeLists.txt b/src/native/corehost/hostmisc/CMakeLists.txt index e1009e5682e84..3e0d22043d825 100644 --- a/src/native/corehost/hostmisc/CMakeLists.txt +++ b/src/native/corehost/hostmisc/CMakeLists.txt @@ -45,9 +45,13 @@ endif() target_link_libraries(hostmisc INTERFACE ${CMAKE_DL_LIBS} - $<$:${ATOMIC_SUPPORT_LIB}> $<$:${PTHREAD_LIB}>) +if(CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_ARCH_ARMV6) + target_link_libraries(hostmisc INTERFACE + $<$:${ATOMIC_SUPPORT_LIB}>) +endif() + target_compile_definitions(hostmisc INTERFACE _NO_ASYNCRTIMP _NO_PPLXIMP) \ No newline at end of file diff --git a/src/native/corehost/hostpolicy/standalone/CMakeLists.txt b/src/native/corehost/hostpolicy/standalone/CMakeLists.txt index 1928c868e91d3..0f14539053ca4 100644 --- a/src/native/corehost/hostpolicy/standalone/CMakeLists.txt +++ b/src/native/corehost/hostpolicy/standalone/CMakeLists.txt @@ -34,6 +34,7 @@ endif(CLR_CMAKE_HOST_UNIX) install_with_stripped_symbols(hostpolicy TARGETS corehost) target_link_libraries(hostpolicy PRIVATE libhostcommon) -target_link_libraries(hostpolicy PRIVATE - $<$:${ATOMIC_SUPPORT_LIB}> - $<$:${PTHREAD_LIB}>) +if(CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_ARCH_ARMV6) + target_link_libraries(hostpolicy INTERFACE + $<$:${ATOMIC_SUPPORT_LIB}>) +endif() \ No newline at end of file From d9c7f7f8c7789b248b125749d869f30e1c2fa149 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 21 May 2024 17:10:51 -0700 Subject: [PATCH 15/18] Update src/native/corehost/test/comsxs/CMakeLists.txt --- src/native/corehost/test/comsxs/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/native/corehost/test/comsxs/CMakeLists.txt b/src/native/corehost/test/comsxs/CMakeLists.txt index fe6ca24c47219..144937e9f8152 100644 --- a/src/native/corehost/test/comsxs/CMakeLists.txt +++ b/src/native/corehost/test/comsxs/CMakeLists.txt @@ -5,7 +5,7 @@ add_executable(comsxs comsxs.cpp App.manifest) -add_sanitizer_runtime_support(test_fx_ver) +add_sanitizer_runtime_support(comsxs) target_link_libraries(comsxs PRIVATE hostmisc ole32 oleaut32 shell32 advapi32) From f57940ca63ba172009a80781f7864247a00f5450 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 28 May 2024 14:39:54 -0700 Subject: [PATCH 16/18] Make hostmisc an object lib instead of an interface lib --- src/coreclr/CMakeLists.txt | 1 + .../corehost/apphost/static/CMakeLists.txt | 5 ++-- src/native/corehost/hostcommon/CMakeLists.txt | 3 --- src/native/corehost/hostmisc/CMakeLists.txt | 26 +++++++++---------- 4 files changed, 15 insertions(+), 20 deletions(-) diff --git a/src/coreclr/CMakeLists.txt b/src/coreclr/CMakeLists.txt index b1951b3754943..80bf33a2878cb 100644 --- a/src/coreclr/CMakeLists.txt +++ b/src/coreclr/CMakeLists.txt @@ -64,6 +64,7 @@ if(NOT CLR_CROSS_COMPONENTS_BUILD) configure_file(${CLR_SRC_NATIVE_DIR}/corehost/configure.h.in ${GENERATED_INCLUDE_DIR}/corehost/configure.h) add_subdirectory(${CLR_SRC_NATIVE_DIR}/corehost/apphost/static Corehost.Static) target_include_directories(singlefilehost PRIVATE ${GENERATED_INCLUDE_DIR}/corehost) + target_include_directories(hostmisc PRIVATE ${GENERATED_INCLUDE_DIR}/corehost) add_dependencies(runtime singlefilehost) endif() #------------------------- diff --git a/src/native/corehost/apphost/static/CMakeLists.txt b/src/native/corehost/apphost/static/CMakeLists.txt index 820ba76fc67ce..5c7a19ad30fa1 100644 --- a/src/native/corehost/apphost/static/CMakeLists.txt +++ b/src/native/corehost/apphost/static/CMakeLists.txt @@ -39,9 +39,7 @@ set(HEADERS ../../fxr_resolver.h ) -add_compile_definitions(_NO_ASYNCRTIMP - _NO_PPLXIMP - NATIVE_LIBS_EMBEDDED) +add_compile_definitions(NATIVE_LIBS_EMBEDDED) include(../../fxr/files.cmake) include(../../hostpolicy/files.cmake) @@ -50,6 +48,7 @@ include(../../hostcommon/files.cmake) if(MSVC) # Host components don't try to handle asynchronous exceptions set_property(DIRECTORY PROPERTY CLR_EH_OPTION /EHsc) + set_property(TARGET hostmisc PROPERTY CLR_EH_OPTION /EHsc) elseif (CMAKE_CXX_COMPILER_ID MATCHES GNU) # Prevents libc from calling pthread_cond_destroy on static objects in # dlopen()'ed library which we dlclose() in pal::unload_library. diff --git a/src/native/corehost/hostcommon/CMakeLists.txt b/src/native/corehost/hostcommon/CMakeLists.txt index f9ab6b4a74d54..2d59348cad29c 100644 --- a/src/native/corehost/hostcommon/CMakeLists.txt +++ b/src/native/corehost/hostcommon/CMakeLists.txt @@ -4,9 +4,6 @@ include(files.cmake) add_library(libhostcommon STATIC ${SOURCES}) -target_compile_definitions(libhostcommon PUBLIC - _NO_ASYNCRTIMP - _NO_PPLXIMP) target_compile_definitions(libhostcommon PRIVATE EXPORT_SHARED_API) set_target_properties(libhostcommon PROPERTIES MACOSX_RPATH TRUE) diff --git a/src/native/corehost/hostmisc/CMakeLists.txt b/src/native/corehost/hostmisc/CMakeLists.txt index 3e0d22043d825..2f1cc32b5390a 100644 --- a/src/native/corehost/hostmisc/CMakeLists.txt +++ b/src/native/corehost/hostmisc/CMakeLists.txt @@ -3,13 +3,6 @@ include(configure.cmake) -add_library(hostmisc INTERFACE) - -target_include_directories(hostmisc INTERFACE - ${CMAKE_CURRENT_BINARY_DIR} - ${CLR_SRC_NATIVE_DIR} - ${CMAKE_CURRENT_LIST_DIR}) - # CMake does not recommend using globbing since it messes with the freshness checks set(SOURCES ${CMAKE_CURRENT_LIST_DIR}/trace.cpp @@ -36,22 +29,27 @@ else() ${CMAKE_CURRENT_LIST_DIR}/pal.unix.cpp) endif() -target_sources(hostmisc INTERFACE ${SOURCES}) +add_library(hostmisc ${SOURCES}) + +target_include_directories(hostmisc PUBLIC + ${CMAKE_CURRENT_BINARY_DIR} + ${CLR_SRC_NATIVE_DIR} + ${CMAKE_CURRENT_LIST_DIR}) if (MSVC) - target_sources(hostmisc INTERFACE ${HEADERS}) - target_link_libraries(hostmisc INTERFACE advapi32) + target_sources(hostmisc PRIVATE ${HEADERS}) + target_link_libraries(hostmisc PUBLIC advapi32) endif() -target_link_libraries(hostmisc INTERFACE +target_link_libraries(hostmisc PUBLIC ${CMAKE_DL_LIBS} $<$:${PTHREAD_LIB}>) if(CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_ARCH_ARMV6) - target_link_libraries(hostmisc INTERFACE + target_link_libraries(hostmisc PUBLIC $<$:${ATOMIC_SUPPORT_LIB}>) endif() -target_compile_definitions(hostmisc INTERFACE +target_compile_definitions(hostmisc PUBLIC _NO_ASYNCRTIMP - _NO_PPLXIMP) \ No newline at end of file + _NO_PPLXIMP) From db241dad257f8637255bbedba2e1317f03230412 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Mon, 3 Jun 2024 14:16:45 -0700 Subject: [PATCH 17/18] Various PR feedback --- src/coreclr/CMakeLists.txt | 3 --- src/native/corehost/CMakeLists.txt | 12 +++++++++--- .../corehost/apphost/standalone/CMakeLists.txt | 2 +- src/native/corehost/apphost/static/CMakeLists.txt | 3 +++ src/native/corehost/comhost/CMakeLists.txt | 2 +- src/native/corehost/corehost.cpp | 5 +---- src/native/corehost/dotnet/CMakeLists.txt | 2 +- src/native/corehost/fxr/standalone/CMakeLists.txt | 6 +++--- src/native/corehost/fxr/staticlib/CMakeLists.txt | 2 +- src/native/corehost/hostcommon/files.cmake | 1 - src/native/corehost/hostmisc/CMakeLists.txt | 8 +++----- .../corehost/hostpolicy/standalone/CMakeLists.txt | 2 +- src/native/corehost/ijwhost/CMakeLists.txt | 2 +- src/native/corehost/nethost/CMakeLists.txt | 4 ++-- src/native/corehost/test/fx_ver/CMakeLists.txt | 4 ---- 15 files changed, 27 insertions(+), 31 deletions(-) diff --git a/src/coreclr/CMakeLists.txt b/src/coreclr/CMakeLists.txt index 80bf33a2878cb..7ed0d509212cc 100644 --- a/src/coreclr/CMakeLists.txt +++ b/src/coreclr/CMakeLists.txt @@ -61,10 +61,7 @@ include(components.cmake) #--------------------------- if(NOT CLR_CROSS_COMPONENTS_BUILD) set(CLR_SINGLE_FILE_HOST_ONLY 1) - configure_file(${CLR_SRC_NATIVE_DIR}/corehost/configure.h.in ${GENERATED_INCLUDE_DIR}/corehost/configure.h) add_subdirectory(${CLR_SRC_NATIVE_DIR}/corehost/apphost/static Corehost.Static) - target_include_directories(singlefilehost PRIVATE ${GENERATED_INCLUDE_DIR}/corehost) - target_include_directories(hostmisc PRIVATE ${GENERATED_INCLUDE_DIR}/corehost) add_dependencies(runtime singlefilehost) endif() #------------------------- diff --git a/src/native/corehost/CMakeLists.txt b/src/native/corehost/CMakeLists.txt index 497e583bd3225..d3854db41f925 100644 --- a/src/native/corehost/CMakeLists.txt +++ b/src/native/corehost/CMakeLists.txt @@ -40,17 +40,23 @@ if("${CLI_CMAKE_FALLBACK_OS}" STREQUAL "") endif() if("${CLI_CMAKE_FALLBACK_OS}" STREQUAL "${CLR_CMAKE_TARGET_OS}") - add_definitions(-DFALLBACK_OS_IS_SAME_AS_TARGET_OS) + add_compile_definitions(FALLBACK_OS_IS_SAME_AS_TARGET_OS) endif() # Find support libraries that we need if they're present on the system. find_library(PTHREAD_LIB pthread) + +# Prefer libatomic.a over libatomic.so. +set(_current_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) +list(INSERT CMAKE_FIND_LIBRARY_SUFFIXES 0 .a) find_library(ATOMIC_SUPPORT_LIB atomic) +set(CMAKE_FIND_LIBRARY_SUFFIXES ${_current_CMAKE_FIND_LIBRARY_SUFFIXES}) +unset(_current_CMAKE_FIND_LIBRARY_SUFFIXES) configure_file(configure.h.in ${CMAKE_CURRENT_BINARY_DIR}/configure.h) -# add_resources_to_target(targetName [resourceDirName]) -function(add_resources_to_target targetName) +# add_version_info_to_target(targetName [resourceDirName]) +function(add_version_info_to_target targetName) set(RESOURCE_INCLUDE_DIR ${targetName}) if (${ARGC} GREATER 1) set(RESOURCE_INCLUDE_DIR ${ARGV1}) diff --git a/src/native/corehost/apphost/standalone/CMakeLists.txt b/src/native/corehost/apphost/standalone/CMakeLists.txt index 8470ca92df5c1..2630aed0deca3 100644 --- a/src/native/corehost/apphost/standalone/CMakeLists.txt +++ b/src/native/corehost/apphost/standalone/CMakeLists.txt @@ -53,7 +53,7 @@ install_with_stripped_symbols(apphost TARGETS corehost) # Disable manifest generation into the file .exe on Windows if(CLR_CMAKE_TARGET_WIN32) - add_link_options(apphost PRIVATE "/MANIFEST:NO") + target_link_options(apphost PRIVATE "/MANIFEST:NO") endif() if (CLR_CMAKE_TARGET_WIN32) diff --git a/src/native/corehost/apphost/static/CMakeLists.txt b/src/native/corehost/apphost/static/CMakeLists.txt index 5c7a19ad30fa1..e431b87e33d0c 100644 --- a/src/native/corehost/apphost/static/CMakeLists.txt +++ b/src/native/corehost/apphost/static/CMakeLists.txt @@ -24,6 +24,9 @@ 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) + set(SOURCES ../bundle_marker.cpp ./hostfxr_resolver.cpp diff --git a/src/native/corehost/comhost/CMakeLists.txt b/src/native/corehost/comhost/CMakeLists.txt index 8602ca92abe78..0e7a045146bde 100644 --- a/src/native/corehost/comhost/CMakeLists.txt +++ b/src/native/corehost/comhost/CMakeLists.txt @@ -25,7 +25,7 @@ add_compile_definitions(EXPORT_SHARED_API) add_library(comhost SHARED ${SOURCES}) -add_resources_to_target(comhost) +add_version_info_to_target(comhost) if (CLR_CMAKE_TARGET_WIN32) set(WINLIBS wintrust.lib) diff --git a/src/native/corehost/corehost.cpp b/src/native/corehost/corehost.cpp index 7cbc8790b03b2..902f8acace131 100644 --- a/src/native/corehost/corehost.cpp +++ b/src/native/corehost/corehost.cpp @@ -97,13 +97,10 @@ void need_newer_framework_error(const pal::string_t& dotnet_root, const pal::str #if defined(CURHOST_EXE) -#if defined(FEATURE_STATIC_HOST) && (defined(TARGET_OSX) || defined(TARGET_LINUX)) && !defined(TARGET_X86) -extern void initialize_static_createdump(); -#endif - int exe_start(const int argc, const pal::char_t* argv[]) { #if defined(FEATURE_STATIC_HOST) && (defined(TARGET_OSX) || defined(TARGET_LINUX)) && !defined(TARGET_X86) + extern void initialize_static_createdump(); initialize_static_createdump(); #endif diff --git a/src/native/corehost/dotnet/CMakeLists.txt b/src/native/corehost/dotnet/CMakeLists.txt index 94366783da16d..5704c911ac956 100644 --- a/src/native/corehost/dotnet/CMakeLists.txt +++ b/src/native/corehost/dotnet/CMakeLists.txt @@ -23,7 +23,7 @@ if(NOT CLR_CMAKE_TARGET_WIN32) endif() install_with_stripped_symbols(dotnet TARGETS corehost) -add_resources_to_target(dotnet) +add_version_info_to_target(dotnet) if (CLR_CMAKE_HOST_APPLE) adhoc_sign_with_entitlements(dotnet "${CLR_ENG_NATIVE_DIR}/entitlements.plist") diff --git a/src/native/corehost/fxr/standalone/CMakeLists.txt b/src/native/corehost/fxr/standalone/CMakeLists.txt index 78e85cf0c7dea..ceb0f9f417536 100644 --- a/src/native/corehost/fxr/standalone/CMakeLists.txt +++ b/src/native/corehost/fxr/standalone/CMakeLists.txt @@ -31,7 +31,7 @@ add_compile_definitions(EXPORT_SHARED_API) add_library(hostfxr SHARED ${SOURCES}) -add_resources_to_target(hostfxr) +add_version_info_to_target(hostfxr) if(CLR_CMAKE_HOST_UNIX) add_custom_target(hostfxr_exports DEPENDS ${EXPORTS_FILE}) @@ -46,6 +46,6 @@ install_with_stripped_symbols(hostfxr TARGETS corehost) target_link_libraries(hostfxr PRIVATE libhostcommon) if(CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_ARCH_ARMV6) - target_link_libraries(hostfxr INTERFACE - $<$:${ATOMIC_SUPPORT_LIB}>) + target_link_libraries(hostfxr PRIVATE + $<$:${ATOMIC_SUPPORT_LIB}>) endif() diff --git a/src/native/corehost/fxr/staticlib/CMakeLists.txt b/src/native/corehost/fxr/staticlib/CMakeLists.txt index 2d8a154631bca..9ab84349d1adc 100644 --- a/src/native/corehost/fxr/staticlib/CMakeLists.txt +++ b/src/native/corehost/fxr/staticlib/CMakeLists.txt @@ -22,7 +22,7 @@ include(../files.cmake) add_library(libhostfxr STATIC ${SOURCES}) -add_resources_to_target(libhostfxr hostfxr) +add_version_info_to_target(libhostfxr hostfxr) set_target_properties(libhostfxr PROPERTIES MACOSX_RPATH TRUE) set_target_properties(libhostfxr PROPERTIES PREFIX "") diff --git a/src/native/corehost/hostcommon/files.cmake b/src/native/corehost/hostcommon/files.cmake index 43bd124b9b592..9b23d326f4657 100644 --- a/src/native/corehost/hostcommon/files.cmake +++ b/src/native/corehost/hostcommon/files.cmake @@ -11,7 +11,6 @@ list(APPEND SOURCES ${CMAKE_CURRENT_LIST_DIR}/../roll_forward_option.cpp ${CMAKE_CURRENT_LIST_DIR}/../fx_definition.cpp ${CMAKE_CURRENT_LIST_DIR}/../fx_reference.cpp - ${CMAKE_CURRENT_LIST_DIR}/../fxr/fx_ver.cpp ${CMAKE_CURRENT_LIST_DIR}/../version_compatibility_range.cpp ${CMAKE_CURRENT_LIST_DIR}/../runtime_config.cpp ${CMAKE_CURRENT_LIST_DIR}/../bundle/info.cpp diff --git a/src/native/corehost/hostmisc/CMakeLists.txt b/src/native/corehost/hostmisc/CMakeLists.txt index 2f1cc32b5390a..f39b586590c62 100644 --- a/src/native/corehost/hostmisc/CMakeLists.txt +++ b/src/native/corehost/hostmisc/CMakeLists.txt @@ -29,7 +29,9 @@ else() ${CMAKE_CURRENT_LIST_DIR}/pal.unix.cpp) endif() -add_library(hostmisc ${SOURCES}) +# 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 ${CMAKE_CURRENT_BINARY_DIR} @@ -49,7 +51,3 @@ if(CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_ARCH_ARMV6) target_link_libraries(hostmisc PUBLIC $<$:${ATOMIC_SUPPORT_LIB}>) endif() - -target_compile_definitions(hostmisc PUBLIC - _NO_ASYNCRTIMP - _NO_PPLXIMP) diff --git a/src/native/corehost/hostpolicy/standalone/CMakeLists.txt b/src/native/corehost/hostpolicy/standalone/CMakeLists.txt index 0f14539053ca4..31f4f8e8e3815 100644 --- a/src/native/corehost/hostpolicy/standalone/CMakeLists.txt +++ b/src/native/corehost/hostpolicy/standalone/CMakeLists.txt @@ -21,7 +21,7 @@ endif(CLR_CMAKE_TARGET_WIN32) add_compile_definitions(EXPORT_SHARED_API) add_library(hostpolicy SHARED ${SOURCES}) -add_resources_to_target(hostpolicy) +add_version_info_to_target(hostpolicy) if(CLR_CMAKE_HOST_UNIX) add_custom_target(hostpolicy_exports DEPENDS ${EXPORTS_FILE}) diff --git a/src/native/corehost/ijwhost/CMakeLists.txt b/src/native/corehost/ijwhost/CMakeLists.txt index 3ad39fff777ec..5e5218e578f3f 100644 --- a/src/native/corehost/ijwhost/CMakeLists.txt +++ b/src/native/corehost/ijwhost/CMakeLists.txt @@ -41,7 +41,7 @@ list(APPEND SOURCES ${ASM_HELPERS_SOURCES}) add_compile_definitions(EXPORT_SHARED_API) add_library(ijwhost SHARED ${SOURCES} ${RESOURCES}) -add_resources_to_target(ijwhost) +add_version_info_to_target(ijwhost) target_link_libraries(ijwhost PRIVATE hostmisc fxr_resolver) diff --git a/src/native/corehost/nethost/CMakeLists.txt b/src/native/corehost/nethost/CMakeLists.txt index f7f4af3dd94d9..38b103b7178be 100644 --- a/src/native/corehost/nethost/CMakeLists.txt +++ b/src/native/corehost/nethost/CMakeLists.txt @@ -19,8 +19,8 @@ add_compile_definitions( add_library(nethost SHARED ${SOURCES}) add_library(libnethost STATIC ${SOURCES}) -add_resources_to_target(nethost) -add_resources_to_target(libnethost nethost) +add_version_info_to_target(nethost) +add_version_info_to_target(libnethost nethost) target_include_directories(nethost PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_include_directories(libnethost PUBLIC $) diff --git a/src/native/corehost/test/fx_ver/CMakeLists.txt b/src/native/corehost/test/fx_ver/CMakeLists.txt index 35935695648c3..a6bb1421dc7ca 100644 --- a/src/native/corehost/test/fx_ver/CMakeLists.txt +++ b/src/native/corehost/test/fx_ver/CMakeLists.txt @@ -2,10 +2,6 @@ # Licensed under the MIT license. See LICENSE file in the project root for full license information. include_directories(../../fxr) -set(SOURCES - test_fx_ver.cpp -) - add_executable(test_fx_ver test_fx_ver.cpp) add_sanitizer_runtime_support(test_fx_ver) From 5d04c10716c352aa6a1cdb31fe30f5834581fd91 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 4 Jun 2024 18:01:00 -0700 Subject: [PATCH 18/18] Update src/native/corehost/CMakeLists.txt Co-authored-by: Elinor Fung --- src/native/corehost/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/native/corehost/CMakeLists.txt b/src/native/corehost/CMakeLists.txt index d3854db41f925..a7b2c82de668d 100644 --- a/src/native/corehost/CMakeLists.txt +++ b/src/native/corehost/CMakeLists.txt @@ -48,7 +48,7 @@ find_library(PTHREAD_LIB pthread) # Prefer libatomic.a over libatomic.so. set(_current_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) -list(INSERT CMAKE_FIND_LIBRARY_SUFFIXES 0 .a) +list(PREPEND CMAKE_FIND_LIBRARY_SUFFIXES .a) find_library(ATOMIC_SUPPORT_LIB atomic) set(CMAKE_FIND_LIBRARY_SUFFIXES ${_current_CMAKE_FIND_LIBRARY_SUFFIXES}) unset(_current_CMAKE_FIND_LIBRARY_SUFFIXES)