Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release/7.0] source build backports #78395

Merged
merged 4 commits into from
Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@
<PackageProjectUrl>https://dot.net</PackageProjectUrl>
<Owners>microsoft,dotnetframework</Owners>
<IncludeSymbols>true</IncludeSymbols>
<RuntimeIdGraphDefinitionFile>$([MSBuild]::NormalizePath('$(LibrariesProjectRoot)', 'Microsoft.NETCore.Platforms', 'src', 'runtime.json'))</RuntimeIdGraphDefinitionFile>
<LicenseFile>$(MSBuildThisFileDirectory)LICENSE.TXT</LicenseFile>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
Expand Down
15 changes: 15 additions & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,21 @@
<Import Project="$(RepositoryEngineeringDir)generators.targets" />
<Import Project="$(RepositoryEngineeringDir)python.targets" />

<!--
When .NET gets built from source, make the SDK aware there are bootstrap packages
for Microsoft.NETCore.App.Runtime.<rid> and Microsoft.NETCore.App.Crossgen2.<rid>.
-->
<ItemGroup Condition="'$(DotNetBuildFromSource)' == 'true'">
<KnownFrameworkReference Update="@(KnownFrameworkReference->WithMetadataValue('Identity', 'Microsoft.NETCore.App')->WithMetadataValue('TargetFramework', '$(NetCoreAppCurrent)'))">
<RuntimePackRuntimeIdentifiers>$(PackageRID)</RuntimePackRuntimeIdentifiers>
</KnownFrameworkReference>
<KnownCrossgen2Pack Update="@(KnownCrossgen2Pack->WithMetadataValue('Identity', 'Microsoft.NETCore.App.Crossgen2')->WithMetadataValue('TargetFramework', '$(NetCoreAppCurrent)'))">
<Crossgen2RuntimeIdentifiers>$(PackageRID)</Crossgen2RuntimeIdentifiers>
</KnownCrossgen2Pack>
<!-- Avoid references to Microsoft.AspNetCore.App.Runtime.<rid> -->
<KnownFrameworkReference Remove="Microsoft.AspNetCore.App" />
</ItemGroup>

<PropertyGroup>
<!--
Define this here (not just in Versions.props) because the SDK resets it
Expand Down
24 changes: 17 additions & 7 deletions eng/SourceBuild.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,46 @@
<SourceBuildPortable>true</SourceBuildPortable>
<SourceBuildPortable Condition="'$(SourceBuildNonPortable)' == 'true'">false</SourceBuildPortable>

<!-- If TargetRid not specified, detect RID based on portability. -->
<!-- TargetRid names what gets built. -->
<TargetRid Condition="'$(TargetRid)' == '' and '$(SourceBuildNonPortable)' == 'true'">$([System.Runtime.InteropServices.RuntimeInformation]::RuntimeIdentifier)</TargetRid>
<TargetRid Condition="'$(TargetRid)' == ''">$(__DistroRid)</TargetRid>

<!-- Split e.g. 'fedora.33-x64' into 'fedora.33' and 'x64'. -->
<_targetRidPlatformIndex>$(TargetRid.LastIndexOf('-'))</_targetRidPlatformIndex>
<TargetRidWithoutPlatform>$(TargetRid.Substring(0, $(_targetRidPlatformIndex)))</TargetRidWithoutPlatform>
<TargetRidPlatform>$(TargetRid.Substring($(_targetRidPlatformIndex)).TrimStart('-'))</TargetRidPlatform>
<TargetArch>$(TargetRid.Substring($(_targetRidPlatformIndex)).TrimStart('-'))</TargetArch>

<!-- RuntimeOS is the build host rid OS. -->
<RuntimeOS>$(TargetRid.Substring(0, $(_targetRidPlatformIndex)))</RuntimeOS>

<!-- BaseOS is an expected known rid in the graph that TargetRid is compatible with.
It's used to add TargetRid in the graph if the parent can't be detected. -->
<BaseOS>$(RuntimeOS)</BaseOS>

<LogVerbosity Condition="'$(LogVerbosity)' == ''">minimal</LogVerbosity>
</PropertyGroup>

<Target Name="GetRuntimeSourceBuildCommandConfiguration"
BeforeTargets="GetSourceBuildCommandConfiguration">
<PropertyGroup>
<InnerBuildArgs>$(InnerBuildArgs) --arch $(TargetRidPlatform)</InnerBuildArgs>
<InnerBuildArgs>$(InnerBuildArgs) --arch $(TargetArch)</InnerBuildArgs>
<InnerBuildArgs>$(InnerBuildArgs) --configuration $(Configuration)</InnerBuildArgs>
<InnerBuildArgs Condition="'$(SourceBuildNonPortable)' == 'true'">$(InnerBuildArgs) --allconfigurations</InnerBuildArgs>
<InnerBuildArgs>$(InnerBuildArgs) --verbosity $(LogVerbosity)</InnerBuildArgs>
<InnerBuildArgs>$(InnerBuildArgs) --nodereuse false</InnerBuildArgs>
<InnerBuildArgs>$(InnerBuildArgs) --warnAsError false</InnerBuildArgs>
<InnerBuildArgs>$(InnerBuildArgs) /p:PackageRid=$(TargetRid)</InnerBuildArgs>
<InnerBuildArgs>$(InnerBuildArgs) --outputrid $(TargetRid)</InnerBuildArgs>
<InnerBuildArgs>$(InnerBuildArgs) --portablebuild $(SourceBuildPortable)</InnerBuildArgs>
<InnerBuildArgs>$(InnerBuildArgs) /p:NoPgoOptimize=true</InnerBuildArgs>
<InnerBuildArgs>$(InnerBuildArgs) /p:KeepNativeSymbols=true</InnerBuildArgs>
<InnerBuildArgs>$(InnerBuildArgs) /p:RuntimeOS=$(TargetRidWithoutPlatform)</InnerBuildArgs>
<InnerBuildArgs>$(InnerBuildArgs) /p:PortableBuild=$(SourceBuildPortable)</InnerBuildArgs>
<InnerBuildArgs>$(InnerBuildArgs) /p:RuntimeOS=$(RuntimeOS)</InnerBuildArgs>
<InnerBuildArgs Condition="'$(OfficialBuildId)' != ''">$(InnerBuildArgs) /p:OfficialBuildId=$(OfficialBuildId)</InnerBuildArgs>
<InnerBuildArgs Condition="'$(ContinuousIntegrationBuild)' != ''">$(InnerBuildArgs) /p:ContinuousIntegrationBuild=$(ContinuousIntegrationBuild)</InnerBuildArgs>
<InnerBuildArgs>$(InnerBuildArgs) /p:BuildDebPackage=false</InnerBuildArgs>
<InnerBuildArgs>$(InnerBuildArgs) /p:EnableNgenOptimization=false</InnerBuildArgs>
<InnerBuildArgs>$(InnerBuildArgs) /p:EnablePackageValidation=false</InnerBuildArgs>
<InnerBuildArgs>$(InnerBuildArgs) /p:DisableSourceLink=false</InnerBuildArgs>
<InnerBuildArgs>$(InnerBuildArgs) /p:AdditionalRuntimeIdentifierParent=$(BaseOS)</InnerBuildArgs>
<InnerBuildArgs Condition="'$(SourceBuildUseMonoRuntime)' == 'true'">$(InnerBuildArgs) /p:PrimaryRuntimeFlavor=Mono /p:RuntimeFlavor=Mono</InnerBuildArgs>
</PropertyGroup>
</Target>

Expand Down
10 changes: 10 additions & 0 deletions eng/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <rid> Optional argument that overrides the target rid name."
echo " --projects <value> 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"
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions eng/common/templates/steps/source-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -75,6 +80,7 @@ steps:
$internalRuntimeDownloadArgs \
$internalRestoreArgs \
$targetRidArgs \
$runtimeOsArgs \
/p:SourceBuildNonPortable=${{ parameters.platform.nonPortable }} \
/p:ArcadeBuildFromSource=true
displayName: Build
Expand Down
4 changes: 3 additions & 1 deletion eng/liveBuilds.targets
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@
ResolveLibrariesRuntimeFilesFromLocalBuild" />

<PropertyGroup>
<BundledRuntimeIdentifierGraphFile>$(RuntimeIdGraphDefinitionFile)</BundledRuntimeIdentifierGraphFile>
<!-- Keep in sync with outputs defined in Microsoft.NETCore.Platforms.csproj. -->
<BundledRuntimeIdentifierGraphFile>$([MSBuild]::NormalizePath('$(ArtifactsBinDir)', 'Microsoft.NETCore.Platforms', 'runtime.json'))</BundledRuntimeIdentifierGraphFile>
<BundledRuntimeIdentifierGraphFile Condition="!Exists('$(BundledRuntimeIdentifierGraphFile)')">$([MSBuild]::NormalizePath('$(LibrariesProjectRoot)', 'Microsoft.NETCore.Platforms', 'src', 'runtime.json'))</BundledRuntimeIdentifierGraphFile>
</PropertyGroup>
</Project>
16 changes: 16 additions & 0 deletions eng/native/build-commons.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand All @@ -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
Expand Down Expand Up @@ -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
;;
Expand Down Expand Up @@ -478,3 +490,7 @@ fi

# init the target distro name
initTargetDistroRid

if [ -z "$__OutputRid" ]; then
__OutputRid="$(echo $__DistroRid | tr '[:upper:]' '[:lower:]')"
fi
3 changes: 3 additions & 0 deletions eng/pipelines/common/global-build-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/tools/aot/ILCompiler/ILCompiler.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputPath>$(RuntimeBinDir)ilc/</OutputPath>
<RuntimeIdentifier>$(OutputRid)</RuntimeIdentifier>
<RuntimeIdentifier>$(PackageRID)</RuntimeIdentifier>
</PropertyGroup>

<Import Project="ILCompiler.props" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
<AvoidRestoreCycleOnSelfReference>true</AvoidRestoreCycleOnSelfReference>
<!-- TODO: Remove with AvoidRestoreCycleOnSelfReference hack. -->
<PackageValidationBaselineName>$(MSBuildProjectName)</PackageValidationBaselineName>
<BeforePack>GenerateRuntimeJson;UpdateRuntimeJson;$(BeforePack)</BeforePack>

<_generateRuntimeGraphTargetFramework Condition="'$(MSBuildRuntimeType)' == 'core'">$(NetCoreAppToolCurrent)</_generateRuntimeGraphTargetFramework>
<_generateRuntimeGraphTargetFramework Condition="'$(MSBuildRuntimeType)' != 'core'">net472</_generateRuntimeGraphTargetFramework>
Expand All @@ -44,7 +43,7 @@

<ItemGroup>
<Content Condition="'$(AdditionalRuntimeIdentifiers)' == ''" Include="runtime.json" PackagePath="/" />
<Content Condition="'$(AdditionalRuntimeIdentifiers)' != ''" Include="$(IntermediateOutputPath)runtime.json" PackagePath="/" />
<Content Condition="'$(AdditionalRuntimeIdentifiers)' != ''" Include="$(BaseOutputPath)runtime.json" PackagePath="/" />
<Content Include="$(PlaceholderFile)" PackagePath="lib/netstandard1.0" />
</ItemGroup>

Expand All @@ -58,12 +57,12 @@

<UsingTask TaskName="GenerateRuntimeGraph" AssemblyFile="$(_generateRuntimeGraphTask)"/>

<Target Name="GenerateRuntimeJson" Condition="'$(AdditionalRuntimeIdentifiers)' != ''">
<Target Name="GenerateRuntimeJson" AfterTargets="Build" Condition="'$(AdditionalRuntimeIdentifiers)' != ''">
<MakeDir Directories="$(IntermediateOutputPath)" />
<GenerateRuntimeGraph RuntimeGroups="@(RuntimeGroupWithQualifiers)"
AdditionalRuntimeIdentifiers="$(AdditionalRuntimeIdentifiers)"
AdditionalRuntimeIdentifierParent="$(AdditionalRuntimeIdentifierParent)"
RuntimeJson="$(IntermediateOutputPath)runtime.json"
RuntimeJson="$(BaseOutputPath)runtime.json"
UpdateRuntimeFiles="True" />
</Target>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<DnneGenRollForward>Major</DnneGenRollForward>
<!-- To integrate with DNNE's architecture calculation, we need to set the RID for this project. -->
<RuntimeIdentifier>$(OutputRid)</RuntimeIdentifier>
<AppHostRuntimeIdentifier>$(OutputRid)</AppHostRuntimeIdentifier>
<AppHostRuntimeIdentifier>$(PackageRID)</AppHostRuntimeIdentifier>
<_TargetsAppleOS Condition="'$(TargetOS)' == 'OSX' or '$(TargetOS)' == 'MacCatalyst' or
'$(TargetOS)' == 'iOS' or '$(TargetOS)' == 'tvOS' or '$(TargetOS)' == 'iOSSimulator' or
'$(TargetOS)' == 'tvOSSimulator'">true</_TargetsAppleOS>
Expand Down
3 changes: 1 addition & 2 deletions src/libraries/oob-all.proj
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
<!-- Build these packages in the allconfigurations leg only. -->
<ProjectReference Remove="Microsoft.Internal.Runtime.AspNetCore.Transport\src\Microsoft.Internal.Runtime.AspNetCore.Transport.proj;
Microsoft.Internal.Runtime.WindowsDesktop.Transport\src\Microsoft.Internal.Runtime.WindowsDesktop.Transport.proj;
Microsoft.Windows.Compatibility\src\Microsoft.Windows.Compatibility.csproj;
Microsoft.NETCore.Platforms\src\Microsoft.NETCore.Platforms.csproj"
Microsoft.Windows.Compatibility\src\Microsoft.Windows.Compatibility.csproj"
Condition="'$(BuildAllConfigurations)' != 'true'" />

<!-- Skip these projects during source-build as they rely on external prebuilts. -->
Expand Down
3 changes: 1 addition & 2 deletions src/libraries/oob-src.proj
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
('$(BuildAllConfigurations)' != 'true' and '$(RuntimeFlavor)' == '$(PrimaryRuntimeFlavor)')" />

<!-- Don't build task and tools project in the NetCoreAppCurrent vertical. -->
<ProjectReference Remove="Microsoft.NETCore.Platforms\src\Microsoft.NETCore.Platforms.csproj;
Microsoft.XmlSerializer.Generator\src\Microsoft.XmlSerializer.Generator.csproj" />
<ProjectReference Remove="Microsoft.XmlSerializer.Generator\src\Microsoft.XmlSerializer.Generator.csproj" />

<!-- Don't build meta-projects in the NetCoreAppCurrent vertical. -->
<ProjectReference Remove="Microsoft.Internal.Runtime.AspNetCore.Transport\src\Microsoft.Internal.Runtime.AspNetCore.Transport.proj;
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/pretest.proj
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
Condition="'$(BuildTargetFramework)' == '$(NetCoreAppCurrent)' or '$(BuildTargetFramework)' == ''">
<!-- Shared framework deps file generation. Produces a test shared-framework deps file. -->
<GenerateTestSharedFrameworkDepsFile SharedFrameworkDirectory="$(NetCoreAppCurrentTestHostSharedFrameworkPath)"
RuntimeGraphFiles="$(RuntimeIdGraphDefinitionFile)"
RuntimeGraphFiles="$(BundledRuntimeIdentifierGraphFile)"
TargetRuntimeIdentifier="$(PackageRID)" />
</Target>

Expand Down
7 changes: 3 additions & 4 deletions src/native/corehost/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
1 change: 1 addition & 0 deletions src/native/corehost/corehost.proj
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
<BuildArgs Condition="'$(Ninja)' == 'true'">$(BuildArgs) -ninja</BuildArgs>
<BuildArgs>$(BuildArgs) -runtimeflavor $(RuntimeFlavor)</BuildArgs>
<BuildArgs Condition="'$(OfficialBuildId)' != ''">$(BuildArgs) /p:OfficialBuildId="$(OfficialBuildId)"</BuildArgs>
<BuildArgs>$(BuildArgs) -outputrid $(OutputRid)</BuildArgs>
</PropertyGroup>

<!--
Expand Down