From dcd4e44edf66952520465044db066108dbb5709f Mon Sep 17 00:00:00 2001 From: Tom Deseyn Date: Tue, 27 Sep 2022 13:22:50 +0200 Subject: [PATCH 1/4] Use generated runtime.json when building shared framework packages. (#76068) * Use generated runtime.json when building shared framework packages. * Don't UpdateRuntimeJson on Build. * PR feedback. * Update Microsoft.NETCore.Platforms.csproj Co-authored-by: Viktor Hofer --- Directory.Build.props | 1 - eng/liveBuilds.targets | 4 +++- .../src/Microsoft.NETCore.Platforms.csproj | 7 +++---- src/libraries/oob-all.proj | 3 +-- src/libraries/oob-src.proj | 3 +-- src/libraries/pretest.proj | 2 +- 6 files changed, 9 insertions(+), 11 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index ce67527ff8ed..ddc1334637af 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -274,7 +274,6 @@ https://dot.net microsoft,dotnetframework true - $([MSBuild]::NormalizePath('$(LibrariesProjectRoot)', 'Microsoft.NETCore.Platforms', 'src', 'runtime.json')) $(MSBuildThisFileDirectory)LICENSE.TXT MIT false diff --git a/eng/liveBuilds.targets b/eng/liveBuilds.targets index 6ba9ce672785..abda5471d74c 100644 --- a/eng/liveBuilds.targets +++ b/eng/liveBuilds.targets @@ -222,6 +222,8 @@ ResolveLibrariesRuntimeFilesFromLocalBuild" /> - $(RuntimeIdGraphDefinitionFile) + + $([MSBuild]::NormalizePath('$(ArtifactsBinDir)', 'Microsoft.NETCore.Platforms', 'runtime.json')) + $([MSBuild]::NormalizePath('$(LibrariesProjectRoot)', 'Microsoft.NETCore.Platforms', 'src', 'runtime.json')) diff --git a/src/libraries/Microsoft.NETCore.Platforms/src/Microsoft.NETCore.Platforms.csproj b/src/libraries/Microsoft.NETCore.Platforms/src/Microsoft.NETCore.Platforms.csproj index 482e0b70e47e..742f17881891 100644 --- a/src/libraries/Microsoft.NETCore.Platforms/src/Microsoft.NETCore.Platforms.csproj +++ b/src/libraries/Microsoft.NETCore.Platforms/src/Microsoft.NETCore.Platforms.csproj @@ -17,7 +17,6 @@ true $(MSBuildProjectName) - GenerateRuntimeJson;UpdateRuntimeJson;$(BeforePack) <_generateRuntimeGraphTargetFramework Condition="'$(MSBuildRuntimeType)' == 'core'">$(NetCoreAppToolCurrent) <_generateRuntimeGraphTargetFramework Condition="'$(MSBuildRuntimeType)' != 'core'">net472 @@ -44,7 +43,7 @@ - + @@ -58,12 +57,12 @@ - + diff --git a/src/libraries/oob-all.proj b/src/libraries/oob-all.proj index f84c5b405025..9164a5846ceb 100644 --- a/src/libraries/oob-all.proj +++ b/src/libraries/oob-all.proj @@ -16,8 +16,7 @@ diff --git a/src/libraries/oob-src.proj b/src/libraries/oob-src.proj index 2cbfdf9bb3c5..472a2dfb5e70 100644 --- a/src/libraries/oob-src.proj +++ b/src/libraries/oob-src.proj @@ -21,8 +21,7 @@ ('$(BuildAllConfigurations)' != 'true' and '$(RuntimeFlavor)' == '$(PrimaryRuntimeFlavor)')" /> - + From ba6fd5b7c811787b177adcf8bb363883708b020a Mon Sep 17 00:00:00 2001 From: Tom Deseyn Date: Wed, 12 Oct 2022 20:52:26 +0200 Subject: [PATCH 2/4] source-build: support building runtime using non-portable runtime packages. (#75597) * source-build: support building runtime using non-portable runtime packages. Currently source-build performs a 'runtime-portable' build that produces 'linux-{arch}' packages that are used when building target runtime (non-portable). With this change, we can use the non-portable packages that are produced by a previous (non-portable) 'runtime' build. This helps eliminate the 'runtime-portable' build. * Avoid references to Microsoft.AspNetCore.App.. * crossgen2: set RuntimeIdentifier explicitly. * PR feedback * Revert "crossgen2: set RuntimeIdentifier explicitly." This reverts commit 10be2744e624b833c43eecbf3f6f6896d415b7d7. * PR feedback. * Revert changes to ILCompiler.csproj. * Update Directory.Build.targets Co-authored-by: Viktor Hofer --- Directory.Build.targets | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Directory.Build.targets b/Directory.Build.targets index 541cdfb59f27..ef9e5f5810c7 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -12,6 +12,21 @@ + + + + $(PackageRID) + + + $(PackageRID) + + + + + + $([System.Runtime.InteropServices.RuntimeInformation]::RuntimeIdentifier) $(__DistroRid) <_targetRidPlatformIndex>$(TargetRid.LastIndexOf('-')) - $(TargetRid.Substring(0, $(_targetRidPlatformIndex))) - $(TargetRid.Substring($(_targetRidPlatformIndex)).TrimStart('-')) + $(TargetRid.Substring($(_targetRidPlatformIndex)).TrimStart('-')) + + + $(TargetRid.Substring(0, $(_targetRidPlatformIndex))) + + + $(RuntimeOS) minimal @@ -26,21 +32,24 @@ - $(InnerBuildArgs) --arch $(TargetRidPlatform) + $(InnerBuildArgs) --arch $(TargetArch) $(InnerBuildArgs) --configuration $(Configuration) $(InnerBuildArgs) --allconfigurations $(InnerBuildArgs) --verbosity $(LogVerbosity) $(InnerBuildArgs) --nodereuse false $(InnerBuildArgs) --warnAsError false - $(InnerBuildArgs) /p:PackageRid=$(TargetRid) + $(InnerBuildArgs) --outputrid $(TargetRid) + $(InnerBuildArgs) --portablebuild $(SourceBuildPortable) $(InnerBuildArgs) /p:NoPgoOptimize=true $(InnerBuildArgs) /p:KeepNativeSymbols=true - $(InnerBuildArgs) /p:RuntimeOS=$(TargetRidWithoutPlatform) - $(InnerBuildArgs) /p:PortableBuild=$(SourceBuildPortable) + $(InnerBuildArgs) /p:RuntimeOS=$(RuntimeOS) + $(InnerBuildArgs) /p:OfficialBuildId=$(OfficialBuildId) + $(InnerBuildArgs) /p:ContinuousIntegrationBuild=$(ContinuousIntegrationBuild) $(InnerBuildArgs) /p:BuildDebPackage=false $(InnerBuildArgs) /p:EnableNgenOptimization=false $(InnerBuildArgs) /p:EnablePackageValidation=false $(InnerBuildArgs) /p:DisableSourceLink=false + $(InnerBuildArgs) /p:AdditionalRuntimeIdentifierParent=$(BaseOS) $(InnerBuildArgs) /p:PrimaryRuntimeFlavor=Mono /p:RuntimeFlavor=Mono diff --git a/eng/build.sh b/eng/build.sh index 84a4fd746c91..352761a5208b 100755 --- a/eng/build.sh +++ b/eng/build.sh @@ -31,6 +31,7 @@ usage() echo " --os Target operating system: windows, Linux, FreeBSD, OSX, MacCatalyst, tvOS," echo " tvOSSimulator, iOS, iOSSimulator, Android, Browser, NetBSD, illumos or Solaris." echo " [Default: Your machine's OS.]" + echo " --outputrid Optional argument that overrides the target rid name." echo " --projects Project or solution file(s) to build." echo " --runtimeConfiguration (-rc) Runtime build configuration: Debug, Release or Checked." echo " Checked is exclusive to the CLR runtime. It is the same as Debug, except code is" @@ -402,6 +403,15 @@ while [[ $# > 0 ]]; do shift 1 ;; + -outputrid) + if [ -z ${2+x} ]; then + echo "No value for outputrid is supplied. See help (--help) for supported values." 1>&2 + exit 1 + fi + arguments="$arguments /p:OutputRid=$(echo "$2" | tr "[:upper:]" "[:lower:]")" + shift 2 + ;; + -portablebuild) if [ -z ${2+x} ]; then echo "No value for portablebuild is supplied. See help (--help) for supported values." 1>&2 diff --git a/eng/common/templates/steps/source-build.yml b/eng/common/templates/steps/source-build.yml index 12a8ff94d8e9..4624885e3bfe 100644 --- a/eng/common/templates/steps/source-build.yml +++ b/eng/common/templates/steps/source-build.yml @@ -63,6 +63,11 @@ steps: targetRidArgs='/p:TargetRid=${{ parameters.platform.targetRID }}' fi + runtimeOsArgs= + if [ '${{ parameters.platform.runtimeOS }}' != '' ]; then + runtimeOsArgs='/p:RuntimeOS=${{ parameters.platform.runtimeOS }}' + fi + publishArgs= if [ '${{ parameters.platform.skipPublishValidation }}' != 'true' ]; then publishArgs='--publish' @@ -75,6 +80,7 @@ steps: $internalRuntimeDownloadArgs \ $internalRestoreArgs \ $targetRidArgs \ + $runtimeOsArgs \ /p:SourceBuildNonPortable=${{ parameters.platform.nonPortable }} \ /p:ArcadeBuildFromSource=true displayName: Build diff --git a/eng/native/build-commons.sh b/eng/native/build-commons.sh index 4199828f2970..bc0083eed718 100755 --- a/eng/native/build-commons.sh +++ b/eng/native/build-commons.sh @@ -212,6 +212,7 @@ usage() echo "-gccx.y: optional argument to build using gcc version x.y." echo "-ninja: target ninja instead of GNU make" echo "-numproc: set the number of build processes." + echo "-outputrid: optional argument that overrides the target rid name." echo "-portablebuild: pass -portablebuild=false to force a non-portable build." echo "-skipconfigure: skip build configuration." echo "-keepnativesymbols: keep native/unmanaged debug symbols." @@ -232,6 +233,7 @@ __TargetArch=$arch __TargetOS=$os __HostOS=$os __BuildOS=$os +__OutputRid='' # Get the number of processors available to the scheduler # Other techniques such as `nproc` only get the number of @@ -396,6 +398,16 @@ while :; do __TargetArch=wasm ;; + outputrid|-outputrid) + if [[ -n "$2" ]]; then + __OutputRid="$2" + shift + else + echo "ERROR: 'outputrid' requires a non-empty option argument" + exit 1 + fi + ;; + ppc64le|-ppc64le) __TargetArch=ppc64le ;; @@ -478,3 +490,7 @@ fi # init the target distro name initTargetDistroRid + +if [ -z "$__OutputRid" ]; then + __OutputRid="$(echo $__DistroRid | tr '[:upper:]' '[:lower:]')" +fi diff --git a/eng/pipelines/common/global-build-job.yml b/eng/pipelines/common/global-build-job.yml index e1a8e45ba97b..61ee087bfa0c 100644 --- a/eng/pipelines/common/global-build-job.yml +++ b/eng/pipelines/common/global-build-job.yml @@ -141,6 +141,9 @@ jobs: platform: buildScript: $(_sclEnableCommand) $(Build.SourcesDirectory)$(dir)build$(scriptExt) nonPortable: true + # Use a custom RID that isn't in the RID graph here to validate we don't break the usage of custom rids that aren't in the graph. + targetRID: banana.24-x64 + runtimeOS: linux - ${{ if in(parameters.osGroup, 'OSX', 'iOS', 'tvOS', 'MacCatalyst') }}: - script: $(Build.SourcesDirectory)/eng/install-native-dependencies.sh ${{ parameters.osGroup }} ${{ parameters.archType }} azDO diff --git a/src/coreclr/tools/aot/ILCompiler/ILCompiler.csproj b/src/coreclr/tools/aot/ILCompiler/ILCompiler.csproj index 3b70c7b427be..eeb4b7923dae 100644 --- a/src/coreclr/tools/aot/ILCompiler/ILCompiler.csproj +++ b/src/coreclr/tools/aot/ILCompiler/ILCompiler.csproj @@ -1,7 +1,7 @@  $(RuntimeBinDir)ilc/ - $(OutputRid) + $(PackageRID) diff --git a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj index d420161d1a6e..57344f047443 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj +++ b/src/libraries/System.Runtime.InteropServices/tests/TestAssets/NativeExports/NativeExports.csproj @@ -9,7 +9,7 @@ Major $(OutputRid) - $(OutputRid) + $(PackageRID) <_TargetsAppleOS Condition="'$(TargetOS)' == 'OSX' or '$(TargetOS)' == 'MacCatalyst' or '$(TargetOS)' == 'iOS' or '$(TargetOS)' == 'tvOS' or '$(TargetOS)' == 'iOSSimulator' or '$(TargetOS)' == 'tvOSSimulator'">true diff --git a/src/native/corehost/build.sh b/src/native/corehost/build.sh index ae44091c5489..f300b10f672f 100755 --- a/src/native/corehost/build.sh +++ b/src/native/corehost/build.sh @@ -74,14 +74,13 @@ __LogsDir="$__RootBinDir/log" __MsbuildDebugLogsDir="$__LogsDir/MsbuildDebugLogs" # Set the remaining variables based upon the determined build configuration -__DistroRidLower="$(echo $__DistroRid | tr '[:upper:]' '[:lower:]')" -__BinDir="$__RootBinDir/bin/$__DistroRidLower.$__BuildType" -__IntermediatesDir="$__RootBinDir/obj/$__DistroRidLower.$__BuildType" +__BinDir="$__RootBinDir/bin/$__OutputRid.$__BuildType" +__IntermediatesDir="$__RootBinDir/obj/$__OutputRid.$__BuildType" export __BinDir __IntermediatesDir __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="-DCLI_CMAKE_HOST_POLICY_VER=\"$__policy_ver\" -DCLI_CMAKE_PKG_RID=\"$__OutputRid\" -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/corehost.proj b/src/native/corehost/corehost.proj index 9ce1a640eada..a320ab4d814a 100644 --- a/src/native/corehost/corehost.proj +++ b/src/native/corehost/corehost.proj @@ -81,6 +81,7 @@ $(BuildArgs) -ninja $(BuildArgs) -runtimeflavor $(RuntimeFlavor) $(BuildArgs) /p:OfficialBuildId="$(OfficialBuildId)" + $(BuildArgs) -outputrid $(OutputRid)