Skip to content

Commit 5cd7566

Browse files
jkoritzinskyam11
andauthored
Add bootstrapping build mechanism and enable for SourceBuild (#114285)
* Revert "Publish with BaseOS RID when its present" This reverts commit 38289af. * WIP: Bootstrap build instead of staged build * Fix bootstrap restore. * Get ILC and crossgen2 publishing with bootstrap subset + use-bootstrap * Remove two-stage build and convert to bootstrap build. * Don't build OOB libs in bootstrapping. They're not needed * Layout bootstrap files in a separate directory so our actual product build still builds everything. It's slower but ensures that our binlogs for the product build still have everything in them. * Fix condition for bootstrap in SB * Various refactorings and put cdac on the same plan as ilc/crossgen2 * Strip double-dash options too as they can be specified * Update eng/build.sh Co-authored-by: Adeel Mujahid <3840695+am11@users.noreply.github.com> * Update eng/DotNetBuild.props Co-authored-by: Adeel Mujahid <3840695+am11@users.noreply.github.com> * Apply suggestion * Don't remove the source-built-upstream-cache folder * Fix loongarch64 leg * Generate breadcrumbs in runtime.proj (where we build the aotsdk folder). Move BuildIntegration.proj to use Microsoft.Build.NoTargets * Adjust trimming tests to hook into targetingpacks.targets refactored logic * Add documentation * Fix local apphost path hookup * Docs feedback * Build hosts in runtime-linker-tests now that we're using the live hosts. * Use the targetingpacks.targets process for a live apphost * PR feedback * Add to build.sh * Fix up RID graph in the bootstrapping * Pass the right RID graph for NativeExports * Fix bootstrap for community portable platforms * Update eng/Subsets.props Co-authored-by: Adeel Mujahid <3840695+am11@users.noreply.github.com> * Update eng/Subsets.props Co-authored-by: Adeel Mujahid <3840695+am11@users.noreply.github.com> --------- Co-authored-by: Adeel Mujahid <3840695+am11@users.noreply.github.com>
1 parent 828dec9 commit 5cd7566

29 files changed

+263
-137
lines changed

Build.proj

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,40 @@
1515
<MSBuild Projects="$(RepoTasksDir)tasks.proj"
1616
Targets="BuildIncrementally" />
1717
</Target>
18+
19+
<Target Name="SetupBootstrapLayout"
20+
AfterTargets="Build"
21+
Condition="'$(Subset)' == 'bootstrap'">
22+
<ItemGroup>
23+
<AotSdkFile
24+
Include="$(CoreCLRAotSdkDir)/*"
25+
Condition="'$(UseNativeAotForComponents)' == 'true'" />
26+
<AppHostFile
27+
Include="$([MSBuild]::NormalizePath('$(DotNetHostBinDir)', 'apphost$(ExeSuffix)'))" />
28+
<AppHostFile
29+
Include="$([MSBuild]::NormalizePath('$(CoreCLRArtifactsPath)', 'corehost', 'singlefilehost$(ExeSuffix)'))"
30+
Condition="'$(UseNativeAotForComponents)' != 'true'" />
31+
<RefPackFile Include="$(MicrosoftNetCoreAppRefPackDir)/**/*" />
32+
<RuntimePackFile Include="$(MicrosoftNetCoreAppRuntimePackDir)/**/*" />
33+
<RidGraphFile Include="$(ArtifactsBinDir)Microsoft.NETCore.Platforms/*.json" />
34+
35+
<AotSdkFile
36+
DestinationPath="$(BootstrapAotSdkDir)/%(Filename)%(Extension)" />
37+
<AppHostFile
38+
DestinationPath="$(BootstrapHostDir)/%(Filename)%(Extension)" />
39+
<RefPackFile
40+
DestinationPath="$(BootstrapRefPackDir)/%(RecursiveDir)%(Filename)%(Extension)" />
41+
<RuntimePackFile
42+
DestinationPath="$(BootstrapRuntimePackDir)/%(RecursiveDir)%(Filename)%(Extension)" />
43+
<RidGraphFile
44+
DestinationPath="$(BootstrapRidGraphDir)/%(RecursiveDir)%(Filename)%(Extension)" />
45+
<BootstrapFile Include="@(AotSdkFile);@(AppHostFile);@(RefPackFile);@(RuntimePackFile);@(RidGraphFile)" />
46+
</ItemGroup>
47+
48+
<Copy
49+
SourceFiles="@(BootstrapFile)"
50+
DestinationFiles="@(BootstrapFile->Metadata('DestinationPath'))"
51+
SkipUnchangedFiles="true" />
52+
<Message Importance="high" Text="Bootstrap files copied to $(ArtifactsDir)bootstrap" />
53+
</Target>
1854
</Project>

Directory.Build.props

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -367,10 +367,4 @@
367367
<BeforeMicrosoftNETSdkTargets Condition="'$(MSBuildProjectExtension)' == '.ilproj'">$(BeforeMicrosoftNETSdkTargets);$(RepositoryEngineeringDir)ILSdk.BeforeTargets.targets</BeforeMicrosoftNETSdkTargets>
368368
</PropertyGroup>
369369

370-
<PropertyGroup>
371-
<!-- Keep in sync with outputs defined in Microsoft.NETCore.Platforms.csproj. -->
372-
<BundledRuntimeIdentifierGraphFile>$([MSBuild]::NormalizePath('$(ArtifactsBinDir)', 'Microsoft.NETCore.Platforms', 'runtime.json'))</BundledRuntimeIdentifierGraphFile>
373-
<BundledRuntimeIdentifierGraphFile Condition="!Exists('$(BundledRuntimeIdentifierGraphFile)')">$([MSBuild]::NormalizePath('$(LibrariesProjectRoot)', 'Microsoft.NETCore.Platforms', 'src', 'runtime.json'))</BundledRuntimeIdentifierGraphFile>
374-
</PropertyGroup>
375-
376370
</Project>

Directory.Build.targets

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,22 @@
77
<ImportDirectoryBuildTargets>false</ImportDirectoryBuildTargets>
88
</PropertyGroup>
99

10+
<Import Project="$(RepositoryEngineeringDir)liveBuilds.targets" />
11+
12+
<PropertyGroup Condition="'$(UseBootstrapLayout)' == 'true'">
13+
<!-- Keep in sync with outputs defined in Microsoft.NETCore.Platforms.csproj. -->
14+
<BundledRuntimeIdentifierGraphFile>$([MSBuild]::NormalizePath('$(BootstrapRidGraphDir)', 'runtime.json'))</BundledRuntimeIdentifierGraphFile>
15+
<!-- If our bootstrap build didn't add a new RID to the graph, fall back to the frozen graph. -->
16+
<BundledRuntimeIdentifierGraphFile Condition="!Exists('$(BundledRuntimeIdentifierGraphFile)')">$([MSBuild]::NormalizePath('$(LibrariesProjectRoot)', 'Microsoft.NETCore.Platforms', 'src', 'runtime.json'))</BundledRuntimeIdentifierGraphFile>
17+
</PropertyGroup>
18+
<PropertyGroup Condition="'$(UseBootstrapLayout)' != 'true'">
19+
<!-- Keep in sync with outputs defined in Microsoft.NETCore.Platforms.csproj. -->
20+
<BundledRuntimeIdentifierGraphFile>$([MSBuild]::NormalizePath('$(ArtifactsBinDir)', 'Microsoft.NETCore.Platforms', 'runtime.json'))</BundledRuntimeIdentifierGraphFile>
21+
<BundledRuntimeIdentifierGraphFile Condition="!Exists('$(BundledRuntimeIdentifierGraphFile)')">$([MSBuild]::NormalizePath('$(LibrariesProjectRoot)', 'Microsoft.NETCore.Platforms', 'src', 'runtime.json'))</BundledRuntimeIdentifierGraphFile>
22+
</PropertyGroup>
23+
1024
<Import Project="$(RepositoryEngineeringDir)Analyzers.targets" />
1125
<Import Project="Sdk.targets" Sdk="Microsoft.DotNet.Arcade.Sdk" />
12-
<Import Project="$(RepositoryEngineeringDir)liveBuilds.targets" />
1326
<Import Project="$(RepositoryEngineeringDir)toolAot.targets" />
1427
<Import Project="$(RepositoryEngineeringDir)generators.targets" />
1528
<Import Project="$(RepositoryEngineeringDir)python.targets" />

docs/workflow/building/coreclr/cross-building.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,3 +171,15 @@ docker run --rm \
171171
mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-18.04-cross-freebsd-12 \
172172
./build.sh --subset clr --cross --os freebsd
173173
```
174+
175+
### Building CoreCLR with Bootstrapping
176+
177+
CoreCLR builds a few tools, including NativeAOT compiler itself, using NativeAOT (or single file where NativeAOT is not supported). The build defaults to using a "Last Known Good" version of NativeAOT to build the tools. This "Last Known Good" version comes from the .NET SDK referenced in the global.json file. This default was chosen for a good local build experience of most repo contributors. Building with live NativeAOT version would make the local build longer and it would make debugging local changes that impact NativeAOT compiler complicated.
178+
179+
The runtime's build scripts provide an additional set of options to build with the live NativeAOT version instead of the "Last Known Good" version. This is useful for testing changes to NativeAOT or the tools that are built with it, and is required for building those tools for target platforms that are not known to the "Last Known Good" version of NativeAOT, such as FreeBSD, community architectures, or non-portable builds of .NET. This is not yet implemented for Windows.
180+
181+
To build the bootstrap subset of the runtime repo, you can build the `bootstrap` subset. To use the bootstrap components in the runtime repo build, you can pass the `--use-bootstrap` argument to the build script. This will use the bootstrap components instead of the "Last Known Good" version of NativeAOT.
182+
183+
For simplicity, a `--bootstrap` option is also provided. This option will build the `bootstrap` subset, clean up the artifacts directory, and then build the runtime repo with the `--use-bootstrap` option. This is useful for building the runtime repo with the live NativeAOT version without having to run two separate commands.
184+
185+
The `--bootstrap` option is automatically specified when building the runtime repo for .NET Source Build, as the vast majority of Source Build scenarios use non-portable RIDs.

docs/workflow/building/coreclr/freebsd-instructions.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ Ensure you have all of the prerequisites installed from the [Linux Requirements]
3838

3939
Once that is done, refer to the [Linux section of the cross-building doc](/docs/workflow/building/coreclr/cross-building.md#linux-cross-building). There are detailed instructions on how to cross-compile using your Linux environment, including a section dedicated to FreeBSD building.
4040

41+
You'll also need to use the `--bootstrap` option as documented in the [cross-building doc](/docs/workflow/building/coreclr/cross-building.md#building-coreclr-with-bootstrapping) to build the cross-compilation toolchain.
42+
4143
## Build directly on FreeBSD
4244

4345
Ensure you have all of the prerequisites installed from the [FreeBSD Requirements](/docs/workflow/requirements/freebsd-requirements.md).

eng/DotNetBuild.props

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@
4444
<InnerBuildArgs Condition="'$(OS)' != 'Windows_NT'">$(InnerBuildArgs) --outputrid $(OutputRID)</InnerBuildArgs>
4545
<!-- BaseOS is an expected known rid in the graph that OutputRID is compatible with.
4646
It's used to add OutputRID in the graph if the parent can't be detected. -->
47-
<InnerBuildArgs>$(InnerBuildArgs) /p:AdditionalRuntimeIdentifierParent=$(BaseOS) /p:BaseOS=$(BaseOS)</InnerBuildArgs>
47+
<InnerBuildArgs>$(InnerBuildArgs) /p:AdditionalRuntimeIdentifierParent=$(BaseOS)</InnerBuildArgs>
48+
<!-- Source-build will use non-portable RIDs. To build for these non-portable RID scenarios, we must do a boostrapped build. -->
49+
<InnerBuildArgs Condition="'$(DotNetBuildSourceOnly)' == 'true' and '$(DotNetBuildUseMonoRuntime)' != 'true'">$(InnerBuildArgs) --bootstrap</InnerBuildArgs>
4850
<!-- Pass through special build modes controlled by properties -->
4951
<InnerBuildArgs Condition="'$(DotNetBuildRuntimeWasmEnableThreads)' == 'true'">$(InnerBuildArgs) /p:WasmEnableThreads=true</InnerBuildArgs>
5052
<InnerBuildArgs Condition="'$(DotNetBuildMonoEnableLLVM)' != ''">$(InnerBuildArgs) /p:MonoEnableLLVM=$(DotNetBuildMonoEnableLLVM)</InnerBuildArgs>

eng/Subsets.props

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,13 @@
5151
<_NativeAotSupportedArch Condition="'$(TargetArchitecture)' == 'x64' or '$(TargetArchitecture)' == 'arm64' or '$(TargetArchitecture)' == 'arm' or '$(TargetArchitecture)' == 'loongarch64' or '$(TargetArchitecture)' == 'riscv64' or ('$(TargetOS)' == 'windows' and '$(TargetArchitecture)' == 'x86')">true</_NativeAotSupportedArch>
5252
<NativeAotSupported Condition="'$(_NativeAotSupportedOS)' == 'true' and '$(_NativeAotSupportedArch)' == 'true'">true</NativeAotSupported>
5353

54-
<!-- Determine if AOT tools can run on the specified target -->
55-
<_AotToolsSupportedOS Condition="'$(TargetsMobile)' != 'true' and '$(TargetsLinuxBionic)' != 'true' and '$(StageOneBuild)' != 'true'">true</_AotToolsSupportedOS>
56-
<_AotToolsSupportedArch Condition="'$(TargetArchitecture)' != 'armel'">true</_AotToolsSupportedArch>
57-
<AotToolsSupported Condition="'$(_AotToolsSupportedOS)' == 'true' and '$(_AotToolsSupportedArch)' == 'true'">true</AotToolsSupported>
54+
<!-- Determine if we support running the .NET SDK on the target platform -->
55+
<_SdkToolsSupportedOS Condition="'$(TargetsMobile)' != 'true' and '$(TargetsLinuxBionic)' != 'true'">true</_SdkToolsSupportedOS>
56+
<_SdkToolsSupportedArch Condition="'$(TargetArchitecture)' != 'armel'">true</_SdkToolsSupportedArch>
57+
<SdkToolsSupported Condition="'$(_SdkToolsSupportedOS)' == 'true' and '$(_SdkToolsSupportedArch)' == 'true'">true</SdkToolsSupported>
58+
59+
<_UseNativeAotForComponentsCrossOS Condition="'$(CrossBuild)' == 'true' and '$(_hostArchitecture)' == '$(_targetArchitecture)' and '$(_hostOS)' != 'windows'">true</_UseNativeAotForComponentsCrossOS>
60+
<UseNativeAotForComponents Condition="'$(NativeAotSupported)' == 'true' and ('$(TargetOS)' == '$(HostOS)' or '$(_UseNativeAotForComponentsCrossOS)' == 'true') and '$(TargetsLinuxBionic)' != 'true'">true</UseNativeAotForComponents>
5861
</PropertyGroup>
5962

6063
<PropertyGroup>
@@ -149,6 +152,12 @@
149152
<DefaultPacksSubsets Condition="'$(DotNetBuildSourceOnly)' != 'true'">$(DefaultPacksSubsets)+packs.installers</DefaultPacksSubsets>
150153
<DefaultPacksSubsets Condition="'$(BuildMonoAOTCrossCompilerOnly)' != 'true' and '$(DotNetBuildSourceOnly)' != 'true'">$(DefaultPacksSubsets)+packs.tests</DefaultPacksSubsets>
151154
<DefaultPacksSubsets Condition="'$(RuntimeFlavor)' != 'Mono' and '$(ForceBuildMobileManifests)' == 'true'">$(DefaultPacksSubsets)+mono.manifests</DefaultPacksSubsets>
155+
156+
<BootstrapSubsets>host.native+libs.sfx+libs.pretest</BootstrapSubsets>
157+
<BootstrapSubsets Condition="'$(UseNativeAotForComponents)' != 'true'">$(BootstrapSubsets)+clr.runtime+clr.corelib</BootstrapSubsets>
158+
<BootstrapSubsets Condition="'$(UseNativeAotForComponents)' == 'true'">$(BootstrapSubsets)+clr.nativeaotlibs+clr.nativeaotruntime+libs.native</BootstrapSubsets>
159+
160+
<SwapNativeForIL Condition="$(_subset.Contains('+bootstrap+')) and '$(RuntimeFlavor)' == 'CoreCLR'">true</SwapNativeForIL>
152161
</PropertyGroup>
153162

154163
<PropertyGroup>
@@ -160,6 +169,7 @@
160169
<_subset>$(_subset.Replace('+tools+', '+$(DefaultToolsSubsets)+'))</_subset>
161170
<_subset>$(_subset.Replace('+host+', '+$(DefaultHostSubsets)+'))</_subset>
162171
<_subset>$(_subset.Replace('+packs+', '+$(DefaultPacksSubsets)+'))</_subset>
172+
<_subset>$(_subset.Replace('+bootstrap+', '+bootstrap+$(BootstrapSubsets)+'))</_subset>
163173
<_subset Condition="'$(TargetOS)' == 'browser'">$(_subset.Replace('+clr.runtime+', '+mono.emsdk+clr.runtime+'))</_subset>
164174

165175
<!-- Surround _subset in dashes to simplify checks below -->
@@ -170,8 +180,6 @@
170180
</PropertyGroup>
171181

172182
<PropertyGroup>
173-
<_IsCommunityCrossArchitecture Condition="'$(CrossBuild)' == 'true' and ('$(TargetArchitecture)' == 'loongarch64' or '$(TargetArchitecture)' == 'riscv64')">true</_IsCommunityCrossArchitecture>
174-
<UseNativeAotForComponents Condition="'$(NativeAotSupported)' == 'true' and '$(TargetOS)' == '$(HostOS)' and '$(TargetsLinuxBionic)' != 'true' and '$(_IsCommunityCrossArchitecture)' != 'true'">true</UseNativeAotForComponents>
175183
<!-- If we're building clr.nativeaotlibs and not building the CLR runtime, compile libraries against NativeAOT CoreLib -->
176184
<UseNativeAotCoreLib Condition="'$(TestNativeAot)' == 'true' or ($(_subset.Contains('+clr.nativeaotlibs+')) and !$(_subset.Contains('+clr.native+')) and !$(_subset.Contains('+clr.runtime+')) and !$(_subset.Contains('+clr.corelib+')))">true</UseNativeAotCoreLib>
177185
</PropertyGroup>
@@ -259,6 +267,7 @@
259267
<SubsetName Include="RegenerateDownloadTable" OnDemand="true" Description="Regenerates the nightly build download table" />
260268
<SubsetName Include="RegenerateThirdPartyNotices" OnDemand="true" Description="Regenerates the THIRD-PARTY-NOTICES.TXT file based on other repos' TPN files." />
261269
<SubsetName Include="tasks" OnDemand="true" Description="Build the repo local task projects." />
270+
<SubsetName Include="bootstrap" OnDemand="true" Description="Build the projects needed to build shipping assets in the repo against live assets." />
262271

263272
</ItemGroup>
264273

@@ -441,22 +450,22 @@
441450
$(CoreClrProjectRoot)tools\PdbChecker\PdbChecker.csproj;
442451
$(CoreClrProjectRoot)tools\AssemblyChecker\AssemblyChecker.csproj;
443452
$(ToolsProjectRoot)StressLogAnalyzer\src\StressLogAnalyzer.csproj" Category="clr" Condition="'$(DotNetBuildSourceOnly)' != 'true'"/>
444-
<!-- We may use these targets with the in-build ILCompiler or with the shipping ILCompiler. Produce them whenever we may use them. -->
445-
<ProjectToBuild Include="$(CoreClrProjectRoot)nativeaot\BuildIntegration\BuildIntegration.proj" Category="clr" Condition="'$(AotToolsSupported)' == 'true' or '$(NativeAotSupported)' == 'true'" />
446-
<ProjectToBuild Include="$(CoreClrProjectRoot)tools\aot\ILCompiler.Build.Tasks\ILCompiler.Build.Tasks.csproj" Category="clr" Condition="'$(AotToolsSupported)' == 'true' or '$(NativeAotSupported)' == 'true'" />
447-
<!-- skip the architectures that don't have LKG runtime packs -->
448-
<ProjectToBuild Include="$(CoreClrProjectRoot)tools\aot\crossgen2\crossgen2_publish.csproj" Condition="'$(AotToolsSupported)' == 'true'" Category="clr" />
449-
<ProjectToBuild Include="$(CoreClrProjectRoot)tools\aot\ILCompiler\ILCompiler_publish.csproj" Category="clr" Condition="'$(AotToolsSupported)' == 'true'" />
450-
451-
<ProjectToBuild Include="$(CoreClrProjectRoot)tools\aot\ILCompiler\ILCompiler.csproj" Condition="'$(AotToolsSupported)' == 'true'" Category="clr" />
452-
<ProjectToBuild Include="$(CoreClrProjectRoot)tools\aot\crossgen2\crossgen2.csproj" Condition="'$(AotToolsSupported)' == 'true'" Category="clr" />
453-
454453
<!--
455454
Always build the in-build variants of these tools. They run on the host machine, which we always have LKG packs for.
456-
For two-stage builds, we omit this step during stage2 since stage1 covers it.
457455
-->
458-
<ProjectToBuild Include="$(CoreClrProjectRoot)tools\aot\ILCompiler\ILCompiler_inbuild.csproj" Category="clr" Condition="'$(StageTwoBuild)' != 'true'" />
459-
<ProjectToBuild Include="$(CoreClrProjectRoot)tools\aot\crossgen2\crossgen2_inbuild.csproj" Category="clr" Condition="'$(StageTwoBuild)' != 'true'" />
456+
<ProjectToBuild Include="$(CoreClrProjectRoot)tools\aot\ILCompiler\ILCompiler_inbuild.csproj" Category="clr" />
457+
<ProjectToBuild Include="$(CoreClrProjectRoot)tools\aot\crossgen2\crossgen2_inbuild.csproj" Category="clr" />
458+
459+
<!-- We may use these targets with the in-build ILCompiler or with the shipping ILCompiler. Produce them whenever we may use them. -->
460+
<ProjectToBuild Include="$(CoreClrProjectRoot)nativeaot\BuildIntegration\BuildIntegration.proj" Category="clr" Condition="'$(SdkToolsSupported)' == 'true' or '$(NativeAotSupported)' == 'true'" />
461+
<ProjectToBuild Include="$(CoreClrProjectRoot)tools\aot\ILCompiler.Build.Tasks\ILCompiler.Build.Tasks.csproj" Category="clr" Condition="'$(SdkToolsSupported)' == 'true' or '$(NativeAotSupported)' == 'true'" />
462+
463+
<ProjectToBuild Include="$(CoreClrProjectRoot)tools\aot\ILCompiler\ILCompiler_publish.csproj" Condition="'$(SdkToolsSupported)' == 'true'" Category="clr" />
464+
<ProjectToBuild Include="$(CoreClrProjectRoot)tools\aot\crossgen2\crossgen2_publish.csproj" Condition="'$(SdkToolsSupported)' == 'true'" Category="clr" />
465+
466+
467+
<ProjectToBuild Include="$(CoreClrProjectRoot)tools\aot\ILCompiler\ILCompiler.csproj" Condition="'$(SdkToolsSupported)' == 'true'" Category="clr" />
468+
<ProjectToBuild Include="$(CoreClrProjectRoot)tools\aot\crossgen2\crossgen2.csproj" Condition="'$(SdkToolsSupported)' == 'true'" Category="clr" />
460469

461470
<ProjectToBuild Condition="'$(TargetOS)' == 'windows' or ('$(TargetOS)' == 'linux' and ('$(TargetArchitecture)' == 'x64' or '$(TargetArchitecture)' == 'arm64')) or '$(TargetOS)' == 'osx'" Include="$(CoreClrProjectRoot)tools\SuperFileCheck\SuperFileCheck.csproj" Category="clr" />
462471

@@ -724,6 +733,11 @@
724733
<ProjectToBuild Include="$(RepoTasksDir)tasks.proj" Category="tasks" />
725734
</ItemGroup>
726735

736+
<!-- Bootstrap -->
737+
<ItemGroup Condition="$(_subset.Contains('+bootstrap+'))">
738+
<ProjectToBuild Include="$(LibrariesProjectRoot)Microsoft.NETCore.Platforms\src\Microsoft.NETCore.Platforms.csproj" Category="libraries" />
739+
</ItemGroup>
740+
727741
<!-- Set default configurations. -->
728742
<ItemGroup>
729743
<ProjectToBuild Update="@(ProjectToBuild)">

eng/build.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ usage()
4848
echo " --usemonoruntime Product a .NET runtime with Mono as the underlying runtime."
4949
echo " --verbosity (-v) MSBuild verbosity: q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]."
5050
echo " [Default: Minimal]"
51+
echo " --use-bootstrap Use the results of building the bootstrap subset to build published tools on the target machine."
52+
echo " --bootstrap Build the bootstrap subset and then build the repo with --use-bootstrap."
5153
echo ""
5254

5355
echo "Actions (defaults to --restore --build):"
@@ -156,6 +158,7 @@ cmakeargs=''
156158
extraargs=''
157159
crossBuild=0
158160
portableBuild=1
161+
bootstrap=0
159162

160163
source $scriptroot/common/native/init-os-and-arch.sh
161164

@@ -508,6 +511,16 @@ while [[ $# > 0 ]]; do
508511
shift 1
509512
;;
510513

514+
-use-bootstrap)
515+
arguments="$arguments /p:UseBootstrap=true"
516+
shift 1
517+
;;
518+
519+
-bootstrap)
520+
bootstrap=1
521+
shift 1
522+
;;
523+
511524
-fsanitize)
512525
if [ -z ${2+x} ]; then
513526
echo "No value for -fsanitize is supplied. See help (--help) for supported values." 1>&2
@@ -570,4 +583,21 @@ export DOTNETSDK_ALLOW_TARGETING_PACK_CACHING=0
570583
cmakeargs="${cmakeargs// /%20}"
571584
arguments="$arguments /p:TargetArchitecture=$arch /p:BuildArchitecture=$hostArch"
572585
arguments="$arguments /p:CMakeArgs=\"$cmakeargs\" $extraargs"
586+
587+
if [[ "$bootstrap" == "1" ]]; then
588+
# Strip build actions other than -restore and -build from the arguments for the bootstrap build.
589+
bootstrapArguments="$arguments"
590+
for flag in --sign --publish --pack --test -sign -publish -pack -test; do
591+
bootstrapArguments="${bootstrapArguments//$flag/}"
592+
done
593+
"$scriptroot/common/build.sh" $bootstrapArguments /p:Subset=bootstrap -bl:$scriptroot/../artifacts/log/bootstrap.binlog
594+
595+
# Remove artifacts from the bootstrap build so the product build is a "clean" build.
596+
echo "Cleaning up artifacts from bootstrap build..."
597+
rm -r "$scriptroot/../artifacts/bin"
598+
# Remove all directories in obj except for the source-built-upstream-cache directory to avoid breaking SourceBuild.
599+
find "$scriptroot/../artifacts/obj" -mindepth 1 -maxdepth 1 ! -name 'source-built-upstream-cache' -exec rm -rf {} +
600+
arguments="$arguments /p:UseBootstrap=true"
601+
fi
602+
573603
"$scriptroot/common/build.sh" $arguments

0 commit comments

Comments
 (0)