From: Vladimir Sadov Date: Sat, 20 Feb 2021 04:40:14 +0000 (-0800) Subject: Building singlefilehost with clr partition. (#48254) X-Git-Tag: submit/tizen/20210909.063632~3125 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2b53a0abd8194ac1005e5fb5db399a2eeb7fbfbf;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Building singlefilehost with clr partition. (#48254) * building single file host with clr partition * make coreclr_static a STATIC lib again --- diff --git a/src/coreclr/CMakeLists.txt b/src/coreclr/CMakeLists.txt index 9c9ba76..ac929b8 100644 --- a/src/coreclr/CMakeLists.txt +++ b/src/coreclr/CMakeLists.txt @@ -126,6 +126,10 @@ if(FEATURE_STANDALONE_GC) endif (CLR_CMAKE_BUILD_SUBSET_RUNTIME) endif(FEATURE_STANDALONE_GC) +if(NOT CLR_CROSS_COMPONENTS_BUILD) + add_subdirectory(${CLR_SRC_NATIVE_DIR}/corehost/apphost/static Corehost.Static) +endif() + if (CLR_CMAKE_HOST_UNIX) include_directories("pal/inc") include_directories("pal/inc/rt") diff --git a/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt b/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt index 2a39c57..705caae 100644 --- a/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt +++ b/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt @@ -1,3 +1,10 @@ + +# we need to define this library before adding .def fiels to sources. +add_library_clr(coreclr_static + STATIC + ${CLR_SOURCES} +) + if (CLR_CMAKE_TARGET_WIN32) preprocess_file(${DEF_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/coreclr.def) @@ -64,11 +71,6 @@ add_library_clr(coreclr ${CLR_SOURCES} ) -add_library_clr(coreclr_static - STATIC - ${CLR_SOURCES} -) - add_custom_target(coreclr_exports DEPENDS ${EXPORTS_FILE}) add_custom_target(coreclr_def DEPENDS ${DEF_FILE}) @@ -222,8 +224,5 @@ endif(CLR_CMAKE_TARGET_WIN32) # add the install targets install_clr(TARGETS coreclr ADDITIONAL_DESTINATIONS sharedFramework) -# publish coreclr_static lib -_install(TARGETS coreclr_static DESTINATION lib) - # Enable profile guided optimization add_pgo(coreclr) diff --git a/src/coreclr/jit/CMakeLists.txt b/src/coreclr/jit/CMakeLists.txt index b22f6e8..f5c5429 100644 --- a/src/coreclr/jit/CMakeLists.txt +++ b/src/coreclr/jit/CMakeLists.txt @@ -348,14 +348,14 @@ else() clr_unknown_arch() endif() -set(SOURCES +set(JIT_CORE_SOURCES ${JIT_SOURCES} ${JIT_HEADERS} - ${JIT_RESOURCES} ) -convert_to_absolute_path(SOURCES ${SOURCES}) +convert_to_absolute_path(JIT_CORE_SOURCES ${JIT_CORE_SOURCES}) convert_to_absolute_path(JIT_ARCH_SOURCES ${JIT_ARCH_SOURCES}) +convert_to_absolute_path(JIT_RESOURCES ${JIT_RESOURCES}) # Also convert the per-architecture sources to absolute paths, if the subdirs want to use them. @@ -371,7 +371,6 @@ if(CLR_CMAKE_TARGET_WIN32) set(JIT_EXPORTS_FILE ${CMAKE_CURRENT_BINARY_DIR}/ClrJit.exports.def) preprocess_file (${CLRJIT_EXPORTS} ${JIT_EXPORTS_FILE}) - set(JIT_CORE_SOURCES ${SOURCES}) set(JIT_DEF_FILE ${JIT_EXPORTS_FILE}) else() set(CLRJIT_EXPORTS ${CMAKE_CURRENT_LIST_DIR}/ClrJit.PAL.exports) @@ -386,7 +385,6 @@ else() set_exports_linker_option(${JIT_EXPORTS_FILE}) set(JIT_EXPORTS_LINKER_OPTION ${EXPORTS_LINKER_OPTION}) - set(JIT_CORE_SOURCES ${SOURCES}) endif() add_custom_target(jit_exports DEPENDS ${JIT_EXPORTS_FILE}) @@ -432,6 +430,7 @@ function(add_jit jitName) add_library_clr(${jitName} SHARED ${JIT_CORE_SOURCES} + ${JIT_RESOURCES} ${JIT_ARCH_SOURCES} ${JIT_DEF_FILE} ${JIT_DLL_MAIN_FILE} @@ -506,4 +505,4 @@ if (CLR_CMAKE_TARGET_WIN32 AND CLR_CMAKE_PGO_INSTRUMENT) find_path(PGORT_DIR ${PGORT_DLL} REQUIRED) _install(FILES "${PGORT_DIR}/${PGORT_DLL}" DESTINATION ${CMAKE_INSTALL_PREFIX}) _install(FILES "${PGORT_DIR}/${PGORT_DLL}" DESTINATION ${CMAKE_INSTALL_PREFIX}/sharedFramework) -endif () \ No newline at end of file +endif () diff --git a/src/coreclr/vm/CMakeLists.txt b/src/coreclr/vm/CMakeLists.txt index fd6072b..5bd3262 100644 --- a/src/coreclr/vm/CMakeLists.txt +++ b/src/coreclr/vm/CMakeLists.txt @@ -759,7 +759,6 @@ if(CLR_CMAKE_TARGET_ARCH_AMD64) ) elseif(CLR_CMAKE_TARGET_ARCH_I386) set(VM_SOURCES_DAC_AND_WKS_ARCH - gcdecode.cpp exinfo.cpp ${ARCH_SOURCES_DIR}/cgenx86.cpp ${ARCH_SOURCES_DIR}/excepx86.cpp @@ -888,12 +887,23 @@ if (CLR_CMAKE_TARGET_WIN32) list(APPEND VM_SOURCES_DAC ${VM_HEADERS_DAC}) endif(CLR_CMAKE_TARGET_WIN32) -#these two files we need to compile differently for standalone and mergeable flavors of WKS +# these two files we need to compile differently for standalone and mergeable flavors of WKS set (VM_SOURCES_WKS_SPECIAL codeman.cpp ceemain.cpp ) +# gcdecode.cpp is included by both JIT and VM. to avoid duplicate definitions we need to +# treat it in a special way when statically linking with both VM and JIT +if(CLR_CMAKE_TARGET_ARCH_I386) + list(APPEND VM_SOURCES_DAC + gcdecode.cpp + ) + list(APPEND VM_SOURCES_WKS_SPECIAL + gcdecode.cpp + ) +endif() + convert_to_absolute_path(VM_SOURCES_WKS ${VM_SOURCES_WKS}) convert_to_absolute_path(VM_SOURCES_WKS_ARCH_ASM ${VM_SOURCES_WKS_ARCH_ASM}) convert_to_absolute_path(VM_SOURCES_DAC ${VM_SOURCES_DAC}) diff --git a/src/coreclr/vm/gcdecode.cpp b/src/coreclr/vm/gcdecode.cpp index f7c819d..30dc9a5 100644 --- a/src/coreclr/vm/gcdecode.cpp +++ b/src/coreclr/vm/gcdecode.cpp @@ -11,4 +11,7 @@ /* GCDecoder.cpp is a common source file bewtween VM and JIT/IL */ /* GCDecoder.cpp is located in $COM99/inc */ +// we need only one copy when embedding +#if !defined(CORECLR_EMBEDDED) #include "gcdecoder.cpp" +#endif diff --git a/src/installer/corehost.proj b/src/installer/corehost.proj index de5ffe4..3f489a8 100644 --- a/src/installer/corehost.proj +++ b/src/installer/corehost.proj @@ -36,7 +36,6 @@ $(BuildArgs) $(Compiler) $(BuildArgs) $(CMakeArgs) $(BuildArgs) -coreclrartifacts $(CoreCLRArtifactsPath) - $(BuildArgs) -nativelibsartifacts $(LibrariesArtifactsPath)/bin/native/$(NetCoreAppCurrent)-$(TargetOS)-$(LibrariesConfiguration)-$(TargetArchitecture) $(BuildArgs) -ninja $(BuildArgs) -runtimeflavor $(RuntimeFlavor) @@ -92,7 +91,6 @@ $(BuildArgs) incremental-native-build $(BuildArgs) rootdir $(RepoRoot) $(BuildArgs) coreclrartifacts $(CoreCLRArtifactsPath) - $(BuildArgs) nativelibsartifacts $(LibrariesArtifactsPath)/bin/native/$(NetCoreAppCurrent)-$(TargetOS)-$(LibrariesConfiguration)-$(TargetArchitecture) $(BuildArgs) ninja $(BuildArgs) runtimeflavor $(RuntimeFlavor) $(BuildArgs) runtimeconfiguration $(RuntimeConfiguration) diff --git a/src/native/corehost/apphost/CMakeLists.txt b/src/native/corehost/apphost/CMakeLists.txt index dbd0bc5..61ff7bc 100644 --- a/src/native/corehost/apphost/CMakeLists.txt +++ b/src/native/corehost/apphost/CMakeLists.txt @@ -1,5 +1,4 @@ # Licensed to the .NET Foundation under one or more agreements. # The .NET Foundation licenses this file to you under the MIT license. -add_subdirectory(static) add_subdirectory(standalone) diff --git a/src/native/corehost/apphost/apphost.windows.cpp b/src/native/corehost/apphost/apphost.windows.cpp index 26257f3..a614c78 100644 --- a/src/native/corehost/apphost/apphost.windows.cpp +++ b/src/native/corehost/apphost/apphost.windows.cpp @@ -6,6 +6,7 @@ #include "pal.h" #include "trace.h" #include "utils.h" +#include namespace { diff --git a/src/native/corehost/apphost/static/CMakeLists.txt b/src/native/corehost/apphost/static/CMakeLists.txt index ce415c1..c922205 100644 --- a/src/native/corehost/apphost/static/CMakeLists.txt +++ b/src/native/corehost/apphost/static/CMakeLists.txt @@ -42,6 +42,20 @@ include(../../fxr/files.cmake) include(../../hostpolicy/files.cmake) include(../../hostcommon/files.cmake) +if(MSVC) + add_compile_options($<$:/wd4996>) + add_compile_options($<$:/wd4267>) + add_compile_options($<$:/wd4018>) + add_compile_options($<$:/wd4200>) + add_compile_options($<$:/wd4244>) + # Host components don't try to handle asynchronous exceptions + add_compile_options(/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. + add_compile_options($<$:-fno-use-cxa-atexit>) +endif() + if(CLR_CMAKE_TARGET_WIN32) list(APPEND SOURCES ../apphost.windows.cpp) @@ -84,59 +98,18 @@ if(CLR_CMAKE_TARGET_WIN32) # Disable manifest generation into the file .exe on Windows add_linker_flag("/MANIFEST:NO") - get_property(ALL_COMPILE_OPTIONS TARGET ${PROJECT_NAME} PROPERTY COMPILE_OPTIONS) - string(TOUPPER ${RUNTIME_CONFIG} UPPERCASE_RUNTIME_CONFIG) - - # make sure that certain compiler and linker settings match the runtime config - # we need to ensure that to be able to link with coreclr in mixed builds (ex: Debug with Release runtime) - if(UPPERCASE_RUNTIME_CONFIG STREQUAL DEBUG OR UPPERCASE_RUNTIME_CONFIG STREQUAL CHECKED) - # add_compile_options(/MTd) - # per-config options will win, so we have to use this syntax to override - set_property(TARGET ${PROJECT_NAME} PROPERTY - COMPILE_OPTIONS "${ALL_COMPILE_OPTIONS};$<$:/MTd>" - ) - - remove_definitions(-DNDEBUG) - add_definitions(-DDEBUG -D_DEBUG -D_DBG) - - # ignore runtime libraries that could have been added so far based on the config - add_linker_flag("/NODEFAULTLIB:ucrt.lib") - add_linker_flag("/NODEFAULTLIB:libucrt.lib") - add_linker_flag("/NODEFAULTLIB:libcmt.lib") - - # make sure we use statically linked crt - add_linker_flag("/DEFAULTLIB:libucrtd.lib") - else() - # add_compile_options(/MT) - # per-config options will win, so we have to use this syntax to override - set_property(TARGET ${PROJECT_NAME} PROPERTY - COMPILE_OPTIONS "${ALL_COMPILE_OPTIONS};$<$:/MT>" - ) - - remove_definitions(-DDEBUG -D_DEBUG -D_DBG) - add_definitions(-DNDEBUG) - - # Force uCRT to be dynamically linked for Release build - add_linker_flag("/NODEFAULTLIB:libucrt.lib") - add_linker_flag("/DEFAULTLIB:ucrt.lib") - endif() - # Incremental linking results in the linker inserting extra padding and routing function calls via thunks that can break the # invariants (e.g. size of region between Jit_PatchedCodeLast-Jit_PatchCodeStart needs to fit in a page). add_linker_flag("/INCREMENTAL:NO") endif() -# Path like: artifacts/bin/coreclr/windows.x64.Release/lib or -# /root/runtime/artifacts/transport/coreclr/lib -set(CORECLR_STATIC_LIB_LOCATION "${CORECLR_ARTIFACTS}/lib") - -message ("Looking for coreclr_static lib at location: '${CORECLR_STATIC_LIB_LOCATION}'.") - if(CLR_CMAKE_TARGET_WIN32) set(NATIVE_LIBS - ${CORECLR_STATIC_LIB_LOCATION}/coreclr_static.lib - ${CORECLR_STATIC_LIB_LOCATION}/System.Globalization.Native-Static.lib - ${CORECLR_STATIC_LIB_LOCATION}/System.IO.Compression.Native-Static.lib + coreclr_static + + System.Globalization.Native-Static + System.IO.Compression.Native-Static + kernel32.lib advapi32.lib ole32.lib @@ -145,24 +118,27 @@ if(CLR_CMAKE_TARGET_WIN32) user32.lib version.lib shlwapi.lib + shell32.lib bcrypt.lib RuntimeObject.lib ) - set(RUNTIMEINFO_LIB ${CORECLR_STATIC_LIB_LOCATION}/runtimeinfo.lib) + set(RUNTIMEINFO_LIB runtimeinfo) else() set(NATIVE_LIBS - ${CORECLR_STATIC_LIB_LOCATION}/libcoreclr_static.a - ${CORECLR_STATIC_LIB_LOCATION}/libSystem.Globalization.Native.a - ${CORECLR_STATIC_LIB_LOCATION}/libSystem.IO.Compression.Native.a - ${CORECLR_STATIC_LIB_LOCATION}/libSystem.Net.Security.Native.a - ${CORECLR_STATIC_LIB_LOCATION}/libSystem.Native.a - ${CORECLR_STATIC_LIB_LOCATION}/libSystem.Security.Cryptography.Native.OpenSsl.a - ${CORECLR_STATIC_LIB_LOCATION}/libpalrt.a - ${CORECLR_STATIC_LIB_LOCATION}/libcoreclrpal.a - ${CORECLR_STATIC_LIB_LOCATION}/libeventprovider.a - ${CORECLR_STATIC_LIB_LOCATION}/libnativeresourcestring.a + coreclr_static + + System.Globalization.Native-Static + System.IO.Compression.Native-Static + System.Net.Security.Native-Static + System.Native-Static + System.Security.Cryptography.Native.OpenSsl-Static + + palrt + coreclrpal + eventprovider + nativeresourcestring ) # additional requirements for System.IO.Compression.Native @@ -181,13 +157,13 @@ else() include(${CLR_REPO_ROOT_DIR}/src/libraries/Native/Unix/System.Security.Cryptography.Native/extra_libs.cmake) append_extra_cryptography_libs(NATIVE_LIBS) - set(RUNTIMEINFO_LIB ${CORECLR_STATIC_LIB_LOCATION}/libruntimeinfo.a) + set(RUNTIMEINFO_LIB runtimeinfo) endif() if(CLR_CMAKE_TARGET_OSX) LIST(APPEND NATIVE_LIBS - ${CORECLR_STATIC_LIB_LOCATION}/libSystem.Security.Cryptography.Native.Apple.a + System.Security.Cryptography.Native.Apple-Static ) # Additional requirements for System.Security.Cryptography.Native.Apple @@ -198,15 +174,6 @@ endif() # # Additional requirements for coreclr # - -# 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)) - LIST(APPEND NATIVE_LIBS - Advapi32.lib - shell32.lib - ) -endif() - if(CLR_CMAKE_TARGET_OSX) find_library(COREFOUNDATION CoreFoundation) find_library(CORESERVICES CoreServices) diff --git a/src/native/corehost/build.cmd b/src/native/corehost/build.cmd index 91adf50e..0c3207f 100644 --- a/src/native/corehost/build.cmd +++ b/src/native/corehost/build.cmd @@ -44,7 +44,6 @@ if /i [%1] == [commit] (set __CommitSha=%2&&shift&&shift&goto Arg_Loop) if /i [%1] == [incremental-native-build] ( set __IncrementalNativeBuild=1&&shift&goto Arg_Loop) if /i [%1] == [rootDir] ( set __rootDir=%2&&shift&&shift&goto Arg_Loop) if /i [%1] == [coreclrartifacts] (set __CoreClrArtifacts=%2&&shift&&shift&goto Arg_Loop) -if /i [%1] == [nativelibsartifacts] (set __NativeLibsArtifacts=%2&&shift&&shift&goto Arg_Loop) if /i [%1] == [ninja] (set __Ninja=1) if /i [%1] == [runtimeflavor] (set __RuntimeFlavor=%2&&shift&&shift&goto Arg_Loop) if /i [%1] == [runtimeconfiguration] (set __RuntimeConfiguration=%2&&shift&&shift&goto Arg_Loop) @@ -154,7 +153,6 @@ echo "Computed RID for native build is %cm_BaseRid%" set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCLI_CMAKE_HOST_VER=%__HostVersion%" "-DCLI_CMAKE_COMMON_HOST_VER=%__AppHostVersion%" "-DCLI_CMAKE_HOST_FXR_VER=%__HostFxrVersion%" set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCLI_CMAKE_HOST_POLICY_VER=%__HostPolicyVersion%" "-DCLI_CMAKE_PKG_RID=%cm_BaseRid%" "-DCLI_CMAKE_COMMIT_HASH=%__CommitSha%" -set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCORECLR_ARTIFACTS=%__CoreClrArtifacts% " "-DRUNTIME_CONFIG=%__RuntimeConfiguration%" "-DNATIVE_LIBS_ARTIFACTS=%__NativeLibsArtifacts%" set __ExtraCmakeParams=%__ExtraCmakeParams% "-DRUNTIME_FLAVOR=%__RuntimeFlavor% " set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCLI_CMAKE_RESOURCE_DIR=%__ResourcesDir%" "-DCMAKE_BUILD_TYPE=%CMAKE_BUILD_TYPE%" @@ -181,6 +179,18 @@ IF ERRORLEVEL 1 ( goto :Failure ) +if "%__RuntimeFlavor%" NEQ "Mono" ( + echo Copying "%__CoreClrArtifacts%\corehost\singlefilehost.exe" "%__CMakeBinDir%/corehost/" + copy /B /Y "%__CoreClrArtifacts%\corehost\singlefilehost.exe" "%__CMakeBinDir%/corehost/" + + echo Copying "%__CoreClrArtifacts%\corehost\PDB\singlefilehost.pdb" "%__CMakeBinDir%/corehost/PDB/" + copy /B /Y "%__CoreClrArtifacts%\corehost\PDB\singlefilehost.pdb" "%__CMakeBinDir%/corehost/PDB/" + + IF ERRORLEVEL 1 ( + goto :Failure + ) +) + echo Done building Native components exit /B 0 diff --git a/src/native/corehost/build.sh b/src/native/corehost/build.sh index d807a9c..0c7d512 100755 --- a/src/native/corehost/build.sh +++ b/src/native/corehost/build.sh @@ -66,11 +66,6 @@ handle_arguments() { __ShiftArgs=1 ;; - nativelibsartifacts|-nativelibsartifacts) - __NativeLibsArtifacts="$2" - __ShiftArgs=1 - ;; - runtimeflavor|-runtimeflavor) __RuntimeFlavor="$2" __ShiftArgs=1 @@ -92,18 +87,13 @@ __DistroRidLower="$(echo $__DistroRid | tr '[:upper:]' '[:lower:]')" __BinDir="$__RootBinDir/bin/$__DistroRidLower.$__BuildType" __IntermediatesDir="$__RootBinDir/obj/$__DistroRidLower.$__BuildType" -export __BinDir __IntermediatesDir __CoreClrArtifacts __NativeLibsArtifacts __RuntimeFlavor +export __BinDir __IntermediatesDir __CoreClrArtifacts __RuntimeFlavor __CMakeArgs="-DCLI_CMAKE_HOST_VER=\"$__host_ver\" -DCLI_CMAKE_COMMON_HOST_VER=\"$__apphost_ver\" -DCLI_CMAKE_HOST_FXR_VER=\"$__fxr_ver\" $__CMakeArgs" __CMakeArgs="-DCLI_CMAKE_HOST_POLICY_VER=\"$__policy_ver\" -DCLI_CMAKE_PKG_RID=\"$__DistroRid\" -DCLI_CMAKE_COMMIT_HASH=\"$__commit_hash\" $__CMakeArgs" -__CMakeArgs="-DCORECLR_ARTIFACTS=\"$__CoreClrArtifacts\" -DNATIVE_LIBS_ARTIFACTS=\"$__NativeLibsArtifacts\" $__CMakeArgs" __CMakeArgs="-DRUNTIME_FLAVOR=\"$__RuntimeFlavor\" $__CMakeArgs" __CMakeArgs="-DFEATURE_DISTRO_AGNOSTIC_SSL=$__PortableBuild $__CMakeArgs" -if [[ "$__PortableBuild" == 1 ]]; then - __CMakeArgs="-DCLI_CMAKE_PORTABLE_BUILD=1 $__CMakeArgs" -fi - # Specify path to be set for CMAKE_INSTALL_PREFIX. # This is where all built CoreClr libraries will copied to. __CMakeBinDir="$__BinDir" @@ -117,3 +107,8 @@ check_prereqs # Build the installer native components. build_native "$__TargetOS" "$__BuildArch" "$__scriptpath" "$__IntermediatesDir" "$__CMakeArgs" "installer component" + +if [[ "$__RuntimeFlavor" != "Mono" ]]; then + echo Copying "$__CoreClrArtifacts/corehost/." to "$__CMakeBinDir/corehost" + cp -a "$__CoreClrArtifacts/corehost/." "$__CMakeBinDir/corehost" +fi diff --git a/src/native/corehost/hostmisc/pal.windows.cpp b/src/native/corehost/hostmisc/pal.windows.cpp index 7ddaab8..2b7699c 100644 --- a/src/native/corehost/hostmisc/pal.windows.cpp +++ b/src/native/corehost/hostmisc/pal.windows.cpp @@ -423,7 +423,7 @@ bool pal::get_global_dotnet_dirs(std::vector* dirs) // To determine the OS version, we are going to use RtlGetVersion API // since GetVersion call can be shimmed on Win8.1+. -typedef NTSTATUS (WINAPI *pFuncRtlGetVersion)(RTL_OSVERSIONINFOW *); +typedef LONG (WINAPI *pFuncRtlGetVersion)(RTL_OSVERSIONINFOW *); pal::string_t pal::get_current_os_rid_platform() { @@ -434,7 +434,7 @@ pal::string_t pal::get_current_os_rid_platform() // Init the buffer ZeroMemory(&osinfo, sizeof(osinfo)); osinfo.dwOSVersionInfoSize = sizeof(osinfo); - HMODULE hmodNtdll = LoadLibrary("ntdll.dll"); + HMODULE hmodNtdll = LoadLibraryA("ntdll.dll"); if (hmodNtdll != NULL) { pFuncRtlGetVersion pRtlGetVersion = (pFuncRtlGetVersion)GetProcAddress(hmodNtdll, "RtlGetVersion"); diff --git a/src/native/corehost/setup.cmake b/src/native/corehost/setup.cmake index f46854b..64b06da 100644 --- a/src/native/corehost/setup.cmake +++ b/src/native/corehost/setup.cmake @@ -1,44 +1,52 @@ # Licensed to the .NET Foundation under one or more agreements. # The .NET Foundation licenses this file to you under the MIT license. -if (CLI_CMAKE_PORTABLE_BUILD) - add_definitions(-DFEATURE_PORTABLE_BUILD=1) -endif () - -if("${CLI_CMAKE_HOST_POLICY_VER}" STREQUAL "") - message(FATAL_ERROR "Host policy version is not specified") +if(${CLR_CMAKE_BUILD_SUBSET_RUNTIME}) + # 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_VER="static") + add_definitions(-DHOST_FXR_PKG_VER="static") + add_definitions(-DHOST_PKG_VER="static") + add_definitions(-DCOMMON_HOST_PKG_VER="static") + add_definitions(-DHOST_POLICY_PKG_NAME="static") + add_definitions(-DHOST_POLICY_PKG_REL_DIR="static") + add_definitions(-DREPO_COMMIT_HASH="static") else() - add_definitions(-DHOST_POLICY_PKG_VER="${CLI_CMAKE_HOST_POLICY_VER}") + if("${CLI_CMAKE_HOST_POLICY_VER}" STREQUAL "") + message(FATAL_ERROR "Host policy version is not specified") + else() + add_definitions(-DHOST_POLICY_PKG_VER="${CLI_CMAKE_HOST_POLICY_VER}") + endif() + + if("${CLI_CMAKE_HOST_FXR_VER}" STREQUAL "") + message(FATAL_ERROR "Host FXR version is not specified") + else() + add_definitions(-DHOST_FXR_PKG_VER="${CLI_CMAKE_HOST_FXR_VER}") + endif() + + if("${CLI_CMAKE_HOST_VER}" STREQUAL "") + message(FATAL_ERROR "Dotnet host version is not specified") + else() + add_definitions(-DHOST_PKG_VER="${CLI_CMAKE_HOST_VER}") + endif() + + if("${CLI_CMAKE_COMMON_HOST_VER}" STREQUAL "") + message(FATAL_ERROR "Common host version is not specified") + else() + add_definitions(-DCOMMON_HOST_PKG_VER="${CLI_CMAKE_COMMON_HOST_VER}") + endif() + + 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_HOST_FXR_VER}" STREQUAL "") - message(FATAL_ERROR "Host FXR version is not specified") -else() - add_definitions(-DHOST_FXR_PKG_VER="${CLI_CMAKE_HOST_FXR_VER}") -endif() - -if("${CLI_CMAKE_HOST_VER}" STREQUAL "") - message(FATAL_ERROR "Dotnet host version is not specified") -else() - add_definitions(-DHOST_PKG_VER="${CLI_CMAKE_HOST_VER}") -endif() - -if("${CLI_CMAKE_COMMON_HOST_VER}" STREQUAL "") - message(FATAL_ERROR "Common host version is not specified") -else() - add_definitions(-DCOMMON_HOST_PKG_VER="${CLI_CMAKE_COMMON_HOST_VER}") -endif() - -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() -