From f2ebae4e1a2b0f3ebf8f659e48e8d36447bdd0a0 Mon Sep 17 00:00:00 2001 From: Tom Deseyn Date: Wed, 15 Feb 2023 11:06:58 +0100 Subject: [PATCH 1/8] corehost: derive fallback rid from output rid. --- src/coreclr/build-runtime.sh | 5 ++++- src/coreclr/runtime.proj | 1 + src/native/corehost/build.sh | 5 ++++- src/native/corehost/hostmisc/pal.h | 19 +------------------ src/native/corehost/setup.cmake | 6 ++++++ 5 files changed, 16 insertions(+), 20 deletions(-) diff --git a/src/coreclr/build-runtime.sh b/src/coreclr/build-runtime.sh index f7474ad2350f4..52fb379f0a29f 100755 --- a/src/coreclr/build-runtime.sh +++ b/src/coreclr/build-runtime.sh @@ -145,8 +145,11 @@ export MSBUILDDEBUGPATH # Check prereqs. check_prereqs +# When the host runs on an unknown rid, it falls back to the output rid +__FallbackOS="${__OutputRid%-*}" # Strip architecture + # Build the coreclr (native) components. -__CMakeArgs="-DCLR_CMAKE_PGO_INSTRUMENT=$__PgoInstrument -DCLR_CMAKE_OPTDATA_PATH=$__PgoOptDataPath -DCLR_CMAKE_PGO_OPTIMIZE=$__PgoOptimize $__CMakeArgs" +__CMakeArgs="-DCLR_CMAKE_PGO_INSTRUMENT=$__PgoInstrument -DCLR_CMAKE_OPTDATA_PATH=$__PgoOptDataPath -DCLR_CMAKE_PGO_OPTIMIZE=$__PgoOptimize -DCLI_CMAKE_FALLBACK_RID=\"$__FallbackOS\" $__CMakeArgs" if [[ "$__SkipConfigure" == 0 && "$__CodeCoverage" == 1 ]]; then __CMakeArgs="-DCLR_CMAKE_ENABLE_CODE_COVERAGE=1 $__CMakeArgs" diff --git a/src/coreclr/runtime.proj b/src/coreclr/runtime.proj index 6dd2e17fba994..d7744c3433336 100644 --- a/src/coreclr/runtime.proj +++ b/src/coreclr/runtime.proj @@ -37,6 +37,7 @@ <_CoreClrBuildArg Condition="'$(PgoInstrument)' == 'true'" Include="-pgoinstrument" /> <_CoreClrBuildArg Condition="'$(NativeOptimizationDataSupported)' == 'true' and '$(NoPgoOptimize)' != 'true' and '$(PgoInstrument)' != 'true'" Include="-pgodatapath "$(PgoPackagePath)"" /> <_CoreClrBuildArg Condition="'$(HostArchitecture)' != ''" Include="-hostarch $(HostArchitecture)" /> + <_CoreClrBuildArg Include="-outputrid $(OutputRid)" /> diff --git a/src/native/corehost/build.sh b/src/native/corehost/build.sh index e48ab8cd28770..88197edd2bcdd 100755 --- a/src/native/corehost/build.sh +++ b/src/native/corehost/build.sh @@ -79,8 +79,11 @@ __IntermediatesDir="$__RootBinDir/obj/$__OutputRid.$__BuildType" export __BinDir __IntermediatesDir __RuntimeFlavor +# When the host runs on an unknown rid, it falls back to the output rid +__FallbackOS="${__OutputRid%-*}" # Strip architecture + __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=\"$__OutputRid\" -DCLI_CMAKE_COMMIT_HASH=\"$__commit_hash\" $__CMakeArgs" +__CMakeArgs="-DCLI_CMAKE_HOST_POLICY_VER=\"$__policy_ver\" -DCLI_CMAKE_PKG_RID=\"$__OutputRid\" -DCLI_CMAKE_FALLBACK_RID=\"$__FallbackOS\" -DCLI_CMAKE_COMMIT_HASH=\"$__commit_hash\" $__CMakeArgs" __CMakeArgs="-DRUNTIME_FLAVOR=\"$__RuntimeFlavor\" $__CMakeArgs" __CMakeArgs="-DFEATURE_DISTRO_AGNOSTIC_SSL=$__PortableBuild $__CMakeArgs" diff --git a/src/native/corehost/hostmisc/pal.h b/src/native/corehost/hostmisc/pal.h index dee5bf3c94d44..805cc5a0e1f62 100644 --- a/src/native/corehost/hostmisc/pal.h +++ b/src/native/corehost/hostmisc/pal.h @@ -67,27 +67,12 @@ #if defined(TARGET_WINDOWS) #define LIB_PREFIX "" #define LIB_FILE_EXT ".dll" -#define FALLBACK_HOST_RID _X("win10") #elif defined(TARGET_OSX) #define LIB_PREFIX "lib" #define LIB_FILE_EXT ".dylib" -#define FALLBACK_HOST_RID _X("osx.10.12") #else #define LIB_PREFIX "lib" #define LIB_FILE_EXT ".so" -#if defined(TARGET_FREEBSD) -#define FALLBACK_HOST_RID _X("freebsd") -#elif defined(TARGET_ILLUMOS) -#define FALLBACK_HOST_RID _X("illumos") -#elif defined(TARGET_SUNOS) -#define FALLBACK_HOST_RID _X("solaris") -#elif defined(TARGET_LINUX_MUSL) -#define FALLBACK_HOST_RID _X("linux-musl") -#elif defined(TARGET_ANDROID) -#define FALLBACK_HOST_RID _X("linux-bionic") -#else -#define FALLBACK_HOST_RID _X("linux") -#endif #endif #define _STRINGIFY(s) _X(s) @@ -276,9 +261,7 @@ namespace pal string_t get_current_os_rid_platform(); inline string_t get_current_os_fallback_rid() { - string_t fallbackRid(FALLBACK_HOST_RID); - - return fallbackRid; + return _STRINGIFY(FALLBACK_HOST_RID); } const void* mmap_read(const string_t& path, size_t* length = nullptr); diff --git a/src/native/corehost/setup.cmake b/src/native/corehost/setup.cmake index d2e4715eaf53b..803b7a41377f5 100644 --- a/src/native/corehost/setup.cmake +++ b/src/native/corehost/setup.cmake @@ -50,3 +50,9 @@ else() add_definitions(-DREPO_COMMIT_HASH="${CLI_CMAKE_COMMIT_HASH}") endif() endif() + +if("${CLI_CMAKE_FALLBACK_RID}" STREQUAL "") + message(FATAL_ERROR "Fallback rid needs to be specified to build the host") +else() + add_definitions(-DFALLBACK_HOST_RID="${CLI_CMAKE_FALLBACK_RID}") +endif() From fa7d0c48e94c7db7f204ff93c89f5d7181092fb4 Mon Sep 17 00:00:00 2001 From: Tom Deseyn Date: Wed, 15 Feb 2023 13:03:03 +0100 Subject: [PATCH 2/8] Attempt at writing Windows scripts. --- src/coreclr/build-runtime.cmd | 9 ++++++++- src/native/corehost/build.cmd | 16 +++++++++++----- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/coreclr/build-runtime.cmd b/src/coreclr/build-runtime.cmd index 9086bcb0f7d5d..18703759421ee 100644 --- a/src/coreclr/build-runtime.cmd +++ b/src/coreclr/build-runtime.cmd @@ -70,6 +70,7 @@ set __PgoOptDataPath= set __CMakeArgs= set __Ninja=1 set __RequestedBuildComponents= +set __OutputRid= :Arg_Loop if "%1" == "" goto ArgsDone @@ -128,6 +129,7 @@ if [!__PassThroughArgs!]==[] ( if /i "%1" == "-hostarch" (set __HostArch=%2&shift&shift&goto Arg_Loop) if /i "%1" == "-os" (set __TargetOS=%2&shift&shift&goto Arg_Loop) +if /i "%1" == "-outputrid" (set __OutputRid=%2&shift&shift&goto Arg_Loop) if /i "%1" == "-cmakeargs" (set __CMakeArgs=%2 %__CMakeArgs%&set __remainingArgs="!__remainingArgs:*%2=!"&shift&shift&goto Arg_Loop) if /i "%1" == "-configureonly" (set __ConfigureOnly=1&set __BuildNative=1&shift&goto Arg_Loop) @@ -355,7 +357,12 @@ if %__BuildNative% EQU 1 ( set __ExtraCmakeArgs="-DCMAKE_BUILD_TYPE=!__BuildType!" ) - set __ExtraCmakeArgs=!__ExtraCmakeArgs! "-DCLR_CMAKE_TARGET_ARCH=%__TargetArch%" "-DCLR_CMAKE_TARGET_OS=%__TargetOS%" "-DCLR_CMAKE_PGO_INSTRUMENT=%__PgoInstrument%" "-DCLR_CMAKE_OPTDATA_PATH=%__PgoOptDataPath%" "-DCLR_CMAKE_PGO_OPTIMIZE=%__PgoOptimize%" %__CMakeArgs% + :: When the host runs on an unknown rid, it falls back to the output rid + :: Strip the architecture + for /f "delims=-" %%i in ("%__OutputRid%") do set __FallbackOS=%%i + if "%__FallbackOS%" == "" set __FallbackOS=win10 + + set __ExtraCmakeArgs=!__ExtraCmakeArgs! "-DCLR_CMAKE_TARGET_ARCH=%__TargetArch%" "-DCLR_CMAKE_TARGET_OS=%__TargetOS%" "-DCLI_CMAKE_FALLBACK_RID=%__FallbackOS%" "-DCLR_CMAKE_PGO_INSTRUMENT=%__PgoInstrument%" "-DCLR_CMAKE_OPTDATA_PATH=%__PgoOptDataPath%" "-DCLR_CMAKE_PGO_OPTIMIZE=%__PgoOptimize%" %__CMakeArgs% echo Calling "%__RepoRootDir%\eng\native\gen-buildsys.cmd" "%__ProjectDir%" "%__IntermediatesDir%" %__VSVersion% %__HostArch% %__TargetOS% !__ExtraCmakeArgs! call "%__RepoRootDir%\eng\native\gen-buildsys.cmd" "%__ProjectDir%" "%__IntermediatesDir%" %__VSVersion% %__HostArch% %__TargetOS% !__ExtraCmakeArgs! if not !errorlevel! == 0 ( diff --git a/src/native/corehost/build.cmd b/src/native/corehost/build.cmd index 84ee51dba022d..2d55a4b1f5af4 100644 --- a/src/native/corehost/build.cmd +++ b/src/native/corehost/build.cmd @@ -20,6 +20,7 @@ set __PortableBuild=0 set __ConfigureOnly=0 set __IncrementalNativeBuild=0 set __Ninja=1 +set __OutputRid="" :Arg_Loop if [%1] == [] goto :InitVSEnv @@ -35,7 +36,8 @@ if /i [%1] == [amd64] (set __BuildArch=x64&&shift&goto Arg_Loop) if /i [%1] == [arm64] (set __BuildArch=arm64&&shift&goto Arg_Loop) if /i [%1] == [portable] (set __PortableBuild=1&&shift&goto Arg_Loop) -if /i [%1] == [rid] (set __TargetRid=%2&&shift&&shift&goto Arg_Loop) +if /i [%1] == [rid] (set __OutputRid=%2&&shift&&shift&goto Arg_Loop) +if /i [%1] == [outputrid] (set __OutputRid=%2&&shift&&shift&goto Arg_Loop) if /i [%1] == [toolsetDir] (set "__ToolsetDir=%2"&&shift&&shift&goto Arg_Loop) if /i [%1] == [hostver] (set __HostVersion=%2&&shift&&shift&goto Arg_Loop) if /i [%1] == [apphostver] (set __AppHostVersion=%2&&shift&&shift&goto Arg_Loop) @@ -70,16 +72,16 @@ echo Configuring corehost native components echo. if %__CMakeBinDir% == "" ( - set "__CMakeBinDir=%__binDir%\%__TargetRid%.%CMAKE_BUILD_TYPE%" + set "__CMakeBinDir=%__binDir%\%__OutputRid%.%CMAKE_BUILD_TYPE%" ) if %__IntermediatesDir% == "" ( - set "__IntermediatesDir=%__objDir%\%__TargetRid%.%CMAKE_BUILD_TYPE%\corehost" + set "__IntermediatesDir=%__objDir%\%__OutputRid%.%CMAKE_BUILD_TYPE%\corehost" ) if %__Ninja% == 0 ( set "__IntermediatesDir=%__IntermediatesDir%\ide" ) -set "__ResourcesDir=%__objDir%\%__TargetRid%.%CMAKE_BUILD_TYPE%\hostResourceFiles" +set "__ResourcesDir=%__objDir%\%__OutputRid%.%CMAKE_BUILD_TYPE%\hostResourceFiles" set "__CMakeBinDir=%__CMakeBinDir:\=/%" set "__IntermediatesDir=%__IntermediatesDir:\=/%" @@ -100,8 +102,12 @@ if /i "%__PortableBuild%" == "1" (set cm_BaseRid=win) set cm_BaseRid=%cm_BaseRid%-%__BuildArch% echo "Computed RID for native build is %cm_BaseRid%" +:: When the host runs on an unknown rid, it falls back to the output rid +:: Strip the architecture +for /f "delims=-" %%i in ("%__OutputRid%") do set __FallbackOS=%%i + 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% "-DCLI_CMAKE_HOST_POLICY_VER=%__HostPolicyVersion%" "-DCLI_CMAKE_PKG_RID=%cm_BaseRid%" "-DCLI_CMAKE_FALLBACK_RID=%__FallbackOS%" "-DCLI_CMAKE_COMMIT_HASH=%__CommitSha%" set __ExtraCmakeParams=%__ExtraCmakeParams% "-DRUNTIME_FLAVOR=%__RuntimeFlavor% " set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCLI_CMAKE_RESOURCE_DIR=%__ResourcesDir%" "-DCMAKE_BUILD_TYPE=%CMAKE_BUILD_TYPE%" From 34ab6ea3e90e5aa3f8b50d5773985e2db05296be Mon Sep 17 00:00:00 2001 From: Tom Deseyn Date: Wed, 15 Feb 2023 15:41:25 +0100 Subject: [PATCH 3/8] build-runtime: move __FallbackOS assignment before if block. --- src/coreclr/build-runtime.cmd | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/coreclr/build-runtime.cmd b/src/coreclr/build-runtime.cmd index 18703759421ee..bb89f53ba4243 100644 --- a/src/coreclr/build-runtime.cmd +++ b/src/coreclr/build-runtime.cmd @@ -329,6 +329,11 @@ REM === Build Native assets including CLR runtime REM === REM ========================================================================================= +:: When the host runs on an unknown rid, it falls back to the output rid +:: Strip the architecture +for /f "delims=-" %%i in ("%__OutputRid%") do set __FallbackOS=%%i +if "%__FallbackOS%" == "" set __FallbackOS=win10 + if %__BuildNative% EQU 1 ( REM Scope environment changes start { setlocal @@ -357,11 +362,6 @@ if %__BuildNative% EQU 1 ( set __ExtraCmakeArgs="-DCMAKE_BUILD_TYPE=!__BuildType!" ) - :: When the host runs on an unknown rid, it falls back to the output rid - :: Strip the architecture - for /f "delims=-" %%i in ("%__OutputRid%") do set __FallbackOS=%%i - if "%__FallbackOS%" == "" set __FallbackOS=win10 - set __ExtraCmakeArgs=!__ExtraCmakeArgs! "-DCLR_CMAKE_TARGET_ARCH=%__TargetArch%" "-DCLR_CMAKE_TARGET_OS=%__TargetOS%" "-DCLI_CMAKE_FALLBACK_RID=%__FallbackOS%" "-DCLR_CMAKE_PGO_INSTRUMENT=%__PgoInstrument%" "-DCLR_CMAKE_OPTDATA_PATH=%__PgoOptDataPath%" "-DCLR_CMAKE_PGO_OPTIMIZE=%__PgoOptimize%" %__CMakeArgs% echo Calling "%__RepoRootDir%\eng\native\gen-buildsys.cmd" "%__ProjectDir%" "%__IntermediatesDir%" %__VSVersion% %__HostArch% %__TargetOS% !__ExtraCmakeArgs! call "%__RepoRootDir%\eng\native\gen-buildsys.cmd" "%__ProjectDir%" "%__IntermediatesDir%" %__VSVersion% %__HostArch% %__TargetOS% !__ExtraCmakeArgs! From c490ee5ab581bc8b858a1ea8f18243cf34d4050c Mon Sep 17 00:00:00 2001 From: Tom Deseyn Date: Wed, 15 Feb 2023 21:51:21 +0100 Subject: [PATCH 4/8] 'win' means 'win10' for fallback --- src/coreclr/build-runtime.cmd | 5 ++++- src/native/corehost/build.cmd | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/coreclr/build-runtime.cmd b/src/coreclr/build-runtime.cmd index bb89f53ba4243..b1c3681a1a131 100644 --- a/src/coreclr/build-runtime.cmd +++ b/src/coreclr/build-runtime.cmd @@ -332,7 +332,10 @@ REM ============================================================================ :: When the host runs on an unknown rid, it falls back to the output rid :: Strip the architecture for /f "delims=-" %%i in ("%__OutputRid%") do set __FallbackOS=%%i -if "%__FallbackOS%" == "" set __FallbackOS=win10 +:: The "win" host build is Windows 10 compatible +if "%__FallbackOS%" == "win" (set __FallbackOS=win10) +:: Default to "win10" fallback +if "%__FallbackOS%" == "" (set __FallbackOS=win10) if %__BuildNative% EQU 1 ( REM Scope environment changes start { diff --git a/src/native/corehost/build.cmd b/src/native/corehost/build.cmd index 2d55a4b1f5af4..17f31eeada145 100644 --- a/src/native/corehost/build.cmd +++ b/src/native/corehost/build.cmd @@ -105,6 +105,8 @@ echo "Computed RID for native build is %cm_BaseRid%" :: When the host runs on an unknown rid, it falls back to the output rid :: Strip the architecture for /f "delims=-" %%i in ("%__OutputRid%") do set __FallbackOS=%%i +:: The "win" host build is Windows 10 compatible +if "%__FallbackOS%" == "win" (set __FallbackOS=win10) 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_FALLBACK_RID=%__FallbackOS%" "-DCLI_CMAKE_COMMIT_HASH=%__CommitSha%" From acc903135efd53507097a86049eccf7722fc354b Mon Sep 17 00:00:00 2001 From: Tom Deseyn Date: Mon, 20 Feb 2023 13:26:34 +0100 Subject: [PATCH 5/8] corehost: build.cmd: remove rid argument (replaced by outputrid). --- src/native/corehost/build.cmd | 1 - src/native/corehost/corehost.proj | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/native/corehost/build.cmd b/src/native/corehost/build.cmd index 17f31eeada145..807e7fbf3dbbd 100644 --- a/src/native/corehost/build.cmd +++ b/src/native/corehost/build.cmd @@ -36,7 +36,6 @@ if /i [%1] == [amd64] (set __BuildArch=x64&&shift&goto Arg_Loop) if /i [%1] == [arm64] (set __BuildArch=arm64&&shift&goto Arg_Loop) if /i [%1] == [portable] (set __PortableBuild=1&&shift&goto Arg_Loop) -if /i [%1] == [rid] (set __OutputRid=%2&&shift&&shift&goto Arg_Loop) if /i [%1] == [outputrid] (set __OutputRid=%2&&shift&&shift&goto Arg_Loop) if /i [%1] == [toolsetDir] (set "__ToolsetDir=%2"&&shift&&shift&goto Arg_Loop) if /i [%1] == [hostver] (set __HostVersion=%2&&shift&&shift&goto Arg_Loop) diff --git a/src/native/corehost/corehost.proj b/src/native/corehost/corehost.proj index 7486b3bd40a19..73e945454070f 100644 --- a/src/native/corehost/corehost.proj +++ b/src/native/corehost/corehost.proj @@ -133,7 +133,7 @@ $([MSBuild]::NormalizePath('$(MSBuildThisFileDirectory)', 'build.cmd')) - $(Configuration) $(TargetArchitecture) apphostver $(AppHostVersion) hostver $(HostVersion) fxrver $(HostResolverVersion) policyver $(HostPolicyVersion) commit $([MSBuild]::ValueOrDefault('$(SourceRevisionId)', 'N/A')) rid $(OutputRid) + $(Configuration) $(TargetArchitecture) apphostver $(AppHostVersion) hostver $(HostVersion) fxrver $(HostResolverVersion) policyver $(HostPolicyVersion) commit $([MSBuild]::ValueOrDefault('$(SourceRevisionId)', 'N/A')) $(BuildArgs) configureonly $(BuildArgs) portable $(BuildArgs) incremental-native-build From 8d321a43f273a4f4b6d6da560cd3eb954251b9e2 Mon Sep 17 00:00:00 2001 From: Tom Deseyn Date: Mon, 20 Feb 2023 13:30:48 +0100 Subject: [PATCH 6/8] Rename FALLBACK_RID to FALLBACK_OS. --- src/coreclr/build-runtime.cmd | 2 +- src/coreclr/build-runtime.sh | 2 +- src/native/corehost/build.cmd | 2 +- src/native/corehost/build.sh | 2 +- src/native/corehost/hostmisc/pal.h | 2 +- src/native/corehost/setup.cmake | 4 ++-- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/coreclr/build-runtime.cmd b/src/coreclr/build-runtime.cmd index b1c3681a1a131..1b4972b4cf3ca 100644 --- a/src/coreclr/build-runtime.cmd +++ b/src/coreclr/build-runtime.cmd @@ -365,7 +365,7 @@ if %__BuildNative% EQU 1 ( set __ExtraCmakeArgs="-DCMAKE_BUILD_TYPE=!__BuildType!" ) - set __ExtraCmakeArgs=!__ExtraCmakeArgs! "-DCLR_CMAKE_TARGET_ARCH=%__TargetArch%" "-DCLR_CMAKE_TARGET_OS=%__TargetOS%" "-DCLI_CMAKE_FALLBACK_RID=%__FallbackOS%" "-DCLR_CMAKE_PGO_INSTRUMENT=%__PgoInstrument%" "-DCLR_CMAKE_OPTDATA_PATH=%__PgoOptDataPath%" "-DCLR_CMAKE_PGO_OPTIMIZE=%__PgoOptimize%" %__CMakeArgs% + set __ExtraCmakeArgs=!__ExtraCmakeArgs! "-DCLR_CMAKE_TARGET_ARCH=%__TargetArch%" "-DCLR_CMAKE_TARGET_OS=%__TargetOS%" "-DCLI_CMAKE_FALLBACK_OS=%__FallbackOS%" "-DCLR_CMAKE_PGO_INSTRUMENT=%__PgoInstrument%" "-DCLR_CMAKE_OPTDATA_PATH=%__PgoOptDataPath%" "-DCLR_CMAKE_PGO_OPTIMIZE=%__PgoOptimize%" %__CMakeArgs% echo Calling "%__RepoRootDir%\eng\native\gen-buildsys.cmd" "%__ProjectDir%" "%__IntermediatesDir%" %__VSVersion% %__HostArch% %__TargetOS% !__ExtraCmakeArgs! call "%__RepoRootDir%\eng\native\gen-buildsys.cmd" "%__ProjectDir%" "%__IntermediatesDir%" %__VSVersion% %__HostArch% %__TargetOS% !__ExtraCmakeArgs! if not !errorlevel! == 0 ( diff --git a/src/coreclr/build-runtime.sh b/src/coreclr/build-runtime.sh index 52fb379f0a29f..91023fea7d708 100755 --- a/src/coreclr/build-runtime.sh +++ b/src/coreclr/build-runtime.sh @@ -149,7 +149,7 @@ check_prereqs __FallbackOS="${__OutputRid%-*}" # Strip architecture # Build the coreclr (native) components. -__CMakeArgs="-DCLR_CMAKE_PGO_INSTRUMENT=$__PgoInstrument -DCLR_CMAKE_OPTDATA_PATH=$__PgoOptDataPath -DCLR_CMAKE_PGO_OPTIMIZE=$__PgoOptimize -DCLI_CMAKE_FALLBACK_RID=\"$__FallbackOS\" $__CMakeArgs" +__CMakeArgs="-DCLR_CMAKE_PGO_INSTRUMENT=$__PgoInstrument -DCLR_CMAKE_OPTDATA_PATH=$__PgoOptDataPath -DCLR_CMAKE_PGO_OPTIMIZE=$__PgoOptimize -DCLI_CMAKE_FALLBACK_OS=\"$__FallbackOS\" $__CMakeArgs" if [[ "$__SkipConfigure" == 0 && "$__CodeCoverage" == 1 ]]; then __CMakeArgs="-DCLR_CMAKE_ENABLE_CODE_COVERAGE=1 $__CMakeArgs" diff --git a/src/native/corehost/build.cmd b/src/native/corehost/build.cmd index 807e7fbf3dbbd..d2cf3403a3309 100644 --- a/src/native/corehost/build.cmd +++ b/src/native/corehost/build.cmd @@ -108,7 +108,7 @@ for /f "delims=-" %%i in ("%__OutputRid%") do set __FallbackOS=%%i if "%__FallbackOS%" == "win" (set __FallbackOS=win10) 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_FALLBACK_RID=%__FallbackOS%" "-DCLI_CMAKE_COMMIT_HASH=%__CommitSha%" +set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCLI_CMAKE_HOST_POLICY_VER=%__HostPolicyVersion%" "-DCLI_CMAKE_PKG_RID=%cm_BaseRid%" "-DCLI_CMAKE_FALLBACK_OS=%__FallbackOS%" "-DCLI_CMAKE_COMMIT_HASH=%__CommitSha%" set __ExtraCmakeParams=%__ExtraCmakeParams% "-DRUNTIME_FLAVOR=%__RuntimeFlavor% " set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCLI_CMAKE_RESOURCE_DIR=%__ResourcesDir%" "-DCMAKE_BUILD_TYPE=%CMAKE_BUILD_TYPE%" diff --git a/src/native/corehost/build.sh b/src/native/corehost/build.sh index 88197edd2bcdd..eef3a838f9123 100755 --- a/src/native/corehost/build.sh +++ b/src/native/corehost/build.sh @@ -83,7 +83,7 @@ export __BinDir __IntermediatesDir __RuntimeFlavor __FallbackOS="${__OutputRid%-*}" # Strip architecture __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=\"$__OutputRid\" -DCLI_CMAKE_FALLBACK_RID=\"$__FallbackOS\" -DCLI_CMAKE_COMMIT_HASH=\"$__commit_hash\" $__CMakeArgs" +__CMakeArgs="-DCLI_CMAKE_HOST_POLICY_VER=\"$__policy_ver\" -DCLI_CMAKE_PKG_RID=\"$__OutputRid\" -DCLI_CMAKE_FALLBACK_OS=\"$__FallbackOS\" -DCLI_CMAKE_COMMIT_HASH=\"$__commit_hash\" $__CMakeArgs" __CMakeArgs="-DRUNTIME_FLAVOR=\"$__RuntimeFlavor\" $__CMakeArgs" __CMakeArgs="-DFEATURE_DISTRO_AGNOSTIC_SSL=$__PortableBuild $__CMakeArgs" diff --git a/src/native/corehost/hostmisc/pal.h b/src/native/corehost/hostmisc/pal.h index 805cc5a0e1f62..72aa756a93399 100644 --- a/src/native/corehost/hostmisc/pal.h +++ b/src/native/corehost/hostmisc/pal.h @@ -261,7 +261,7 @@ namespace pal string_t get_current_os_rid_platform(); inline string_t get_current_os_fallback_rid() { - return _STRINGIFY(FALLBACK_HOST_RID); + return _STRINGIFY(FALLBACK_HOST_OS); } const void* mmap_read(const string_t& path, size_t* length = nullptr); diff --git a/src/native/corehost/setup.cmake b/src/native/corehost/setup.cmake index 803b7a41377f5..cedabbce6bca8 100644 --- a/src/native/corehost/setup.cmake +++ b/src/native/corehost/setup.cmake @@ -51,8 +51,8 @@ else() endif() endif() -if("${CLI_CMAKE_FALLBACK_RID}" STREQUAL "") +if("${CLI_CMAKE_FALLBACK_OS}" STREQUAL "") message(FATAL_ERROR "Fallback rid needs to be specified to build the host") else() - add_definitions(-DFALLBACK_HOST_RID="${CLI_CMAKE_FALLBACK_RID}") + add_definitions(-DFALLBACK_HOST_OS="${CLI_CMAKE_FALLBACK_OS}") endif() From 6f019d2de744263b68db00dee720dfc2266f66d6 Mon Sep 17 00:00:00 2001 From: Tom Deseyn Date: Mon, 20 Feb 2023 13:34:27 +0100 Subject: [PATCH 7/8] Move fallback os assignment to build-commons.sh. --- eng/native/build-commons.sh | 3 +++ src/coreclr/build-runtime.cmd | 8 ++++---- src/coreclr/build-runtime.sh | 5 +---- src/native/corehost/build.cmd | 6 +++--- src/native/corehost/build.sh | 5 +---- 5 files changed, 12 insertions(+), 15 deletions(-) diff --git a/eng/native/build-commons.sh b/eng/native/build-commons.sh index c56592494332b..1237fb49f27e9 100755 --- a/eng/native/build-commons.sh +++ b/eng/native/build-commons.sh @@ -490,3 +490,6 @@ initTargetDistroRid if [ -z "$__OutputRid" ]; then __OutputRid="$(echo $__DistroRid | tr '[:upper:]' '[:lower:]')" fi + +# When the host runs on an unknown rid, it falls back to the output rid +__HostFallbackOS="${__OutputRid%-*}" # Strip architecture diff --git a/src/coreclr/build-runtime.cmd b/src/coreclr/build-runtime.cmd index 1b4972b4cf3ca..a8fca255b8611 100644 --- a/src/coreclr/build-runtime.cmd +++ b/src/coreclr/build-runtime.cmd @@ -331,11 +331,11 @@ REM ============================================================================ :: When the host runs on an unknown rid, it falls back to the output rid :: Strip the architecture -for /f "delims=-" %%i in ("%__OutputRid%") do set __FallbackOS=%%i +for /f "delims=-" %%i in ("%__OutputRid%") do set __HostFallbackOS=%%i :: The "win" host build is Windows 10 compatible -if "%__FallbackOS%" == "win" (set __FallbackOS=win10) +if "%__HostFallbackOS%" == "win" (set __HostFallbackOS=win10) :: Default to "win10" fallback -if "%__FallbackOS%" == "" (set __FallbackOS=win10) +if "%__HostFallbackOS%" == "" (set __HostFallbackOS=win10) if %__BuildNative% EQU 1 ( REM Scope environment changes start { @@ -365,7 +365,7 @@ if %__BuildNative% EQU 1 ( set __ExtraCmakeArgs="-DCMAKE_BUILD_TYPE=!__BuildType!" ) - set __ExtraCmakeArgs=!__ExtraCmakeArgs! "-DCLR_CMAKE_TARGET_ARCH=%__TargetArch%" "-DCLR_CMAKE_TARGET_OS=%__TargetOS%" "-DCLI_CMAKE_FALLBACK_OS=%__FallbackOS%" "-DCLR_CMAKE_PGO_INSTRUMENT=%__PgoInstrument%" "-DCLR_CMAKE_OPTDATA_PATH=%__PgoOptDataPath%" "-DCLR_CMAKE_PGO_OPTIMIZE=%__PgoOptimize%" %__CMakeArgs% + set __ExtraCmakeArgs=!__ExtraCmakeArgs! "-DCLR_CMAKE_TARGET_ARCH=%__TargetArch%" "-DCLR_CMAKE_TARGET_OS=%__TargetOS%" "-DCLI_CMAKE_FALLBACK_OS=%__HostFallbackOS%" "-DCLR_CMAKE_PGO_INSTRUMENT=%__PgoInstrument%" "-DCLR_CMAKE_OPTDATA_PATH=%__PgoOptDataPath%" "-DCLR_CMAKE_PGO_OPTIMIZE=%__PgoOptimize%" %__CMakeArgs% echo Calling "%__RepoRootDir%\eng\native\gen-buildsys.cmd" "%__ProjectDir%" "%__IntermediatesDir%" %__VSVersion% %__HostArch% %__TargetOS% !__ExtraCmakeArgs! call "%__RepoRootDir%\eng\native\gen-buildsys.cmd" "%__ProjectDir%" "%__IntermediatesDir%" %__VSVersion% %__HostArch% %__TargetOS% !__ExtraCmakeArgs! if not !errorlevel! == 0 ( diff --git a/src/coreclr/build-runtime.sh b/src/coreclr/build-runtime.sh index 91023fea7d708..7399088f291d9 100755 --- a/src/coreclr/build-runtime.sh +++ b/src/coreclr/build-runtime.sh @@ -145,11 +145,8 @@ export MSBUILDDEBUGPATH # Check prereqs. check_prereqs -# When the host runs on an unknown rid, it falls back to the output rid -__FallbackOS="${__OutputRid%-*}" # Strip architecture - # Build the coreclr (native) components. -__CMakeArgs="-DCLR_CMAKE_PGO_INSTRUMENT=$__PgoInstrument -DCLR_CMAKE_OPTDATA_PATH=$__PgoOptDataPath -DCLR_CMAKE_PGO_OPTIMIZE=$__PgoOptimize -DCLI_CMAKE_FALLBACK_OS=\"$__FallbackOS\" $__CMakeArgs" +__CMakeArgs="-DCLR_CMAKE_PGO_INSTRUMENT=$__PgoInstrument -DCLR_CMAKE_OPTDATA_PATH=$__PgoOptDataPath -DCLR_CMAKE_PGO_OPTIMIZE=$__PgoOptimize -DCLI_CMAKE_FALLBACK_OS=\"$__HostFallbackOS\" $__CMakeArgs" if [[ "$__SkipConfigure" == 0 && "$__CodeCoverage" == 1 ]]; then __CMakeArgs="-DCLR_CMAKE_ENABLE_CODE_COVERAGE=1 $__CMakeArgs" diff --git a/src/native/corehost/build.cmd b/src/native/corehost/build.cmd index d2cf3403a3309..470746f4dde9f 100644 --- a/src/native/corehost/build.cmd +++ b/src/native/corehost/build.cmd @@ -103,12 +103,12 @@ echo "Computed RID for native build is %cm_BaseRid%" :: When the host runs on an unknown rid, it falls back to the output rid :: Strip the architecture -for /f "delims=-" %%i in ("%__OutputRid%") do set __FallbackOS=%%i +for /f "delims=-" %%i in ("%__OutputRid%") do set __HostFallbackOS=%%i :: The "win" host build is Windows 10 compatible -if "%__FallbackOS%" == "win" (set __FallbackOS=win10) +if "%__HostFallbackOS%" == "win" (set __HostFallbackOS=win10) 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_FALLBACK_OS=%__FallbackOS%" "-DCLI_CMAKE_COMMIT_HASH=%__CommitSha%" +set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCLI_CMAKE_HOST_POLICY_VER=%__HostPolicyVersion%" "-DCLI_CMAKE_PKG_RID=%cm_BaseRid%" "-DCLI_CMAKE_FALLBACK_OS=%__HostFallbackOS%" "-DCLI_CMAKE_COMMIT_HASH=%__CommitSha%" set __ExtraCmakeParams=%__ExtraCmakeParams% "-DRUNTIME_FLAVOR=%__RuntimeFlavor% " set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCLI_CMAKE_RESOURCE_DIR=%__ResourcesDir%" "-DCMAKE_BUILD_TYPE=%CMAKE_BUILD_TYPE%" diff --git a/src/native/corehost/build.sh b/src/native/corehost/build.sh index eef3a838f9123..def574f4839ca 100755 --- a/src/native/corehost/build.sh +++ b/src/native/corehost/build.sh @@ -79,11 +79,8 @@ __IntermediatesDir="$__RootBinDir/obj/$__OutputRid.$__BuildType" export __BinDir __IntermediatesDir __RuntimeFlavor -# When the host runs on an unknown rid, it falls back to the output rid -__FallbackOS="${__OutputRid%-*}" # Strip architecture - __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=\"$__OutputRid\" -DCLI_CMAKE_FALLBACK_OS=\"$__FallbackOS\" -DCLI_CMAKE_COMMIT_HASH=\"$__commit_hash\" $__CMakeArgs" +__CMakeArgs="-DCLI_CMAKE_HOST_POLICY_VER=\"$__policy_ver\" -DCLI_CMAKE_PKG_RID=\"$__OutputRid\" -DCLI_CMAKE_FALLBACK_OS=\"$__HostFallbackOS\" -DCLI_CMAKE_COMMIT_HASH=\"$__commit_hash\" $__CMakeArgs" __CMakeArgs="-DRUNTIME_FLAVOR=\"$__RuntimeFlavor\" $__CMakeArgs" __CMakeArgs="-DFEATURE_DISTRO_AGNOSTIC_SSL=$__PortableBuild $__CMakeArgs" From de6f01e25f2dd2cffc34017a932c7b39438b129f Mon Sep 17 00:00:00 2001 From: Tom Deseyn Date: Mon, 20 Feb 2023 21:40:57 +0100 Subject: [PATCH 8/8] corehost.proj: add missing outputrid argument. --- src/native/corehost/corehost.proj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/native/corehost/corehost.proj b/src/native/corehost/corehost.proj index 73e945454070f..2df956bd476a0 100644 --- a/src/native/corehost/corehost.proj +++ b/src/native/corehost/corehost.proj @@ -133,7 +133,7 @@ $([MSBuild]::NormalizePath('$(MSBuildThisFileDirectory)', 'build.cmd')) - $(Configuration) $(TargetArchitecture) apphostver $(AppHostVersion) hostver $(HostVersion) fxrver $(HostResolverVersion) policyver $(HostPolicyVersion) commit $([MSBuild]::ValueOrDefault('$(SourceRevisionId)', 'N/A')) + $(Configuration) $(TargetArchitecture) apphostver $(AppHostVersion) hostver $(HostVersion) fxrver $(HostResolverVersion) policyver $(HostPolicyVersion) commit $([MSBuild]::ValueOrDefault('$(SourceRevisionId)', 'N/A')) outputrid $(OutputRid) $(BuildArgs) configureonly $(BuildArgs) portable $(BuildArgs) incremental-native-build