Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit740cb44

Browse files
authored
Build bootstrap compiler in separate phase (#72001)
* Build bootstrap compiler in separate phaseThis moves the infrastructure for building a bootstrap compiler into aseparate phase.The reason for this is to facilitate better performance investigations.Having the bootstrap compiler build inside our build makes it basicallyimpossible to profile using a freshly built compiler to build our repo.Having separate phases mean that locally I can now- build the bootstrap compiler- start the profiler- rebuild roslynOverall I think it's also just a bit cleaner this way.* yml* yml* cleanup* fixes* more* bootstrap change* yml* more* more
1 parent0b5b744 commit740cb44

21 files changed

+189
-163
lines changed

‎azure-pipelines.yml‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,10 @@ stages:
425425
steps:
426426
-template:eng/pipelines/checkout-windows-task.yml
427427

428-
-script:eng/test-determinism.cmd -configuration Debug
428+
-script:eng/make-bootstrap.cmd -name determinism
429+
displayName:Build Bootstrap Compiler
430+
431+
-script:eng/test-determinism.cmd -configuration Debug -bootstrapDir $(Build.SourcesDirectory)/artifacts/bootstrap/determinism
429432
displayName:Build - Validate determinism
430433

431434
-template:eng/pipelines/publish-logs.yml
@@ -445,8 +448,7 @@ stages:
445448
steps:
446449
-template:eng/pipelines/build-bootstrap.yml
447450
parameters:
448-
bootstrapName:Default
449-
bootstrapToolset:AnyCpu
451+
toolset:Default
450452

451453
-job:Correctness_Bootstrap_Build_Framework
452454
dependsOn:Determine_Changes
@@ -460,8 +462,7 @@ stages:
460462
steps:
461463
-template:eng/pipelines/build-bootstrap.yml
462464
parameters:
463-
bootstrapName:Framework
464-
bootstrapToolset:Framework
465+
toolset:Framework
465466

466467
-job:Correctness_TodoCheck
467468
pool:${{ parameters.ubuntuPool }}
@@ -484,7 +485,7 @@ stages:
484485
steps:
485486
-template:eng/pipelines/checkout-windows-task.yml
486487

487-
-powershell:.\eng\test-rebuild.ps1 -ci -configuration Release
488+
-script:.\eng\test-rebuild.cmd -ci -configuration Release -bootstrap
488489
displayName:Run BuildValidator
489490

490491
-task:PublishBuildArtifacts@1

‎eng/build-utils.ps1‎

Lines changed: 31 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ $PublishDataUrl = "https://raw.githubusercontent.com/dotnet/roslyn/main/eng/conf
1212

1313
$binaryLog=if (Test-Path variable:binaryLog) {$binaryLog }else {$false }
1414
$nodeReuse=if (Test-Path variable:nodeReuse) {$nodeReuse }else {$false }
15-
$bootstrapDir=if (Test-Path variable:bootstrapDir) {$bootstrapDir }else {"" }
16-
$bootstrapConfiguration=if (Test-Path variable:bootstrapConfiguration) {$bootstrapConfiguration }else {"Release" }
1715
$properties=if (Test-Path variable:properties) {$properties }else {@() }
1816
$originalTemp=$env:TEMP;
1917

@@ -89,7 +87,11 @@ function Exec-Block([scriptblock]$cmd) {
8987
}
9088
}
9189

92-
functionExec-CommandCore([string]$command, [string]$commandArgs, [switch]$useConsole=$true) {
90+
functionExec-CommandCore([string]$command, [string]$commandArgs, [switch]$useConsole=$true, [switch]$echoCommand=$true) {
91+
if ($echoCommand) {
92+
Write-Host"$command$commandArgs"
93+
}
94+
9395
if ($useConsole) {
9496
$exitCode= Exec-Process$command$commandArgs
9597
if ($exitCode-ne0) {
@@ -151,27 +153,39 @@ function Exec-CommandCore([string]$command, [string]$commandArgs, [switch]$useCo
151153
# $args = "/p:ManualBuild=true Test.proj"
152154
# Exec-Command $msbuild $args
153155
#
154-
functionExec-Command([string]$command, [string]$commandArgs) {
155-
Exec-CommandCore-command$command-commandArgs$commandargs-useConsole:$false
156-
}
157-
158-
# Functions exactly like Exec-Command but lets the process re-use the current
159-
# console. This means items like colored output will function correctly.
160-
#
161-
# In general this command should be used in place of
162-
# Exec-Command $msbuild $args | Out-Host
163-
#
164-
functionExec-Console([string]$command, [string]$commandArgs) {
165-
Exec-CommandCore-command$command-commandArgs$commandargs-useConsole:$true
156+
# The -useConsole argument controls if the process should re-use the current
157+
# console for output or return output as a string
158+
functionExec-Command([string]$command, [string]$commandArgs, [switch]$useConsole=$false, [switch]$echoCommand=$true) {
159+
if ($args-ne"") {
160+
throw"Extra arguments passed to Exec-Command:$args"
161+
}
162+
Exec-CommandCore-command$command-commandArgs$commandArgs-useConsole:$useConsole-echoCommand:$echoCommand
166163
}
167164

168165
# Handy function for executing a powershell script in a clean environment with
169166
# arguments. Prefer this over & sourcing a script as it will both use a clean
170167
# environment and do proper error checking
171-
functionExec-Script([string]$script, [string]$scriptArgs="") {
172-
Exec-Command"pwsh""-noprofile -executionPolicy RemoteSigned -file`"$script`"$scriptArgs"
168+
#
169+
# The -useConsole argument controls if the process should re-use the current
170+
# console for output or return output as a string
171+
functionExec-Script([string]$script, [string]$scriptArgs="", [switch]$useConsole=$true, [switch]$echoCommand=$true) {
172+
if ($args-ne"") {
173+
throw"Extra arguments passed to Exec-Script:$args"
174+
}
175+
Exec-CommandCore-command"pwsh"-commandArgs"-noprofile -executionPolicy RemoteSigned -file`"$script`"$scriptArgs"-useConsole:$useConsole-echoCommand:$echoCommand
173176
}
174177

178+
# Handy function for executing a dotnet command without having to track down the
179+
# proper dotnet executable or ensure it's on the path.
180+
functionExec-DotNet([string]$commandArgs="", [switch]$useConsole=$true, [switch]$echoCommand=$true) {
181+
if ($args-ne"") {
182+
throw"Extra arguments passed to Exec-DotNet:$args"
183+
}
184+
$dotnet= Ensure-DotNetSdk
185+
Exec-CommandCore-command$dotnet-commandArgs$commandArgs-useConsole:$useConsole-echoCommand:$echoCommand
186+
}
187+
188+
175189
# Ensure the proper .NET Core SDK is available. Returns the location to the dotnet.exe.
176190
functionEnsure-DotnetSdk() {
177191
$dotnetInstallDir= (InitializeDotNetCli-install:$true)
@@ -262,91 +276,6 @@ function Get-PackageDir([string]$name, [string]$version = "") {
262276
return$p
263277
}
264278

265-
# Create a bootstrap build of the compiler. Returns the directory where the bootstrap build
266-
# is located.
267-
#
268-
# Important to not set $script:bootstrapDir here yet as we're actually in the process of
269-
# building the bootstrap.
270-
functionMake-BootstrapBuild([string]$bootstrapToolset="") {
271-
272-
functionRun-MSBuild([string]$projectFilePath, [string]$buildArgs="", [string]$logFileName="", [string]$configuration=$script:configuration) {
273-
# Because we override the C#/VB toolset to build against our LKG package, it is important
274-
# that we do not reuse MSBuild nodes from other jobs/builds on the machine. Otherwise,
275-
# we'll run into issues such as https://github.com/dotnet/roslyn/issues/6211.
276-
# MSBuildAdditionalCommandLineArgs=
277-
$args="/p:TreatWarningsAsErrors=true /nologo /nodeReuse:false /p:Configuration=$configuration /v:m";
278-
279-
if ($warnAsError) {
280-
$args+=" /warnaserror"
281-
}
282-
283-
if ($runAnalyzers) {
284-
$args+=" /p:RunAnalyzersDuringBuild=true"
285-
}
286-
287-
if ($binaryLog) {
288-
if ($logFileName-eq"") {
289-
$logFileName= [IO.Path]::GetFileNameWithoutExtension($projectFilePath)
290-
}
291-
$logFileName= [IO.Path]::ChangeExtension($logFileName,".binlog")
292-
$logFilePath=Join-Path$LogDir$logFileName
293-
$args+=" /bl:$logFilePath"
294-
}
295-
296-
if ($officialBuildId) {
297-
$args+=" /p:OfficialBuildId="+$officialBuildId
298-
}
299-
300-
if ($ci) {
301-
$args+=" /p:ContinuousIntegrationBuild=true"
302-
}
303-
304-
if ($bootstrapDir-ne"") {
305-
$args+=" /p:BootstrapBuildPath=$bootstrapDir"
306-
}
307-
308-
$args+="$buildArgs"
309-
$args+="$projectFilePath"
310-
$args+="$properties"
311-
312-
$buildTool= InitializeBuildTool
313-
Exec-Console$buildTool.Path"$($buildTool.Command)$args"
314-
}
315-
316-
Write-Host"Building bootstrap compiler"
317-
318-
$dir=Join-Path$ArtifactsDir"Bootstrap"
319-
Remove-Item-re$dir-ErrorAction SilentlyContinue
320-
Create-Directory$dir
321-
322-
if ($bootstrapToolset-eq""-or$bootstrapToolset-eq"AnyCPU") {
323-
$projectPath="src\NuGet\Microsoft.Net.Compilers.Toolset\AnyCpu\Microsoft.Net.Compilers.Toolset.Package.csproj"
324-
$packageName="Microsoft.Net.Compilers.Toolset"
325-
}
326-
elseif ($bootstrapToolset-eq"Framework") {
327-
$projectPath="src\NuGet\Microsoft.Net.Compilers.Toolset\Framework\Microsoft.Net.Compilers.Toolset.Framework.Package.csproj"
328-
$packageName="Microsoft.Net.Compilers.Toolset.Framework"
329-
}
330-
else {
331-
throw"Unsupported bootstrap toolset$bootstrapToolset"
332-
}
333-
334-
Run-MSBuild$projectPath"/restore /t:Pack /p:RoslynEnforceCodeStyle=false /p:RunAnalyzersDuringBuild=false /p:DotNetUseShippingVersions=true /p:InitialDefineConstants=BOOTSTRAP /p:PackageOutputPath=`"$dir`" /p:EnableNgenOptimization=false /p:PublishWindowsPdb=false"-logFileName"Bootstrap"-configuration$bootstrapConfiguration
335-
$packageFile=Get-ChildItem-Path$dir-Filter"$packageName.*.nupkg"
336-
Unzip (Join-Path$dir$packageFile.Name)$dir
337-
338-
Write-Host"Cleaning Bootstrap compiler artifacts"
339-
Run-MSBuild$projectPath"/t:Clean"-logFileName"BootstrapClean"
340-
341-
# Work around NuGet bug that doesn't correctly re-generate our project.assets.json files.
342-
# Deleting everything forces a regen
343-
# https://github.com/NuGet/Home/issues/12437
344-
Remove-Item-Recurse-Force (Join-Path$ArtifactsDir"bin")
345-
Remove-Item-Recurse-Force (Join-Path$ArtifactsDir"obj")
346-
347-
return$dir
348-
}
349-
350279
functionSubst-TempDir() {
351280
if ($ci) {
352281
Exec-Command"subst""T:$TempDir"

‎eng/build.ps1‎

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ param (
3232

3333
# Options
3434
[switch]$bootstrap,
35-
[string]$bootstrapConfiguration="Release",
36-
[string]$bootstrapToolset="",
35+
[string]$bootstrapDir="",
3736
[switch][Alias('bl')]$binaryLog,
3837
[string]$binaryLogName="",
3938
[switch]$ci,
@@ -105,7 +104,7 @@ function Print-Usage() {
105104
Write-Host"Advanced settings:"
106105
Write-Host" -ci Set when running on CI server"
107106
Write-Host" -bootstrap Build using a bootstrap compilers"
108-
Write-Host" -bootstrapConfigurationBuild configuration forbootstrap compiler: 'Debug' or 'Release'"
107+
Write-Host" -bootstrapDir Build usingbootstrap compiler at specified location"
109108
Write-Host" -msbuildEngine <value> Msbuild engine to use to run build ('dotnet', 'vs', or unspecified)."
110109
Write-Host" -collectDumps Collect dumps from test runs"
111110
Write-Host" -runAnalyzers Run analyzers during build operations (short: -a)"
@@ -180,6 +179,10 @@ function Process-Arguments() {
180179
$script:binaryLogName="Build.binlog"
181180
}
182181

182+
if ($bootstrapDir-ne"") {
183+
$script:bootstrap=$true
184+
}
185+
183186
$anyUnit=$testDesktop-or$testCoreClr
184187
if ($anyUnit-and$testVsi) {
185188
Write-Host"Cannot combine unit and VSI testing"
@@ -463,7 +466,7 @@ function TestUsingRunTests() {
463466

464467
try {
465468
Write-Host"$runTests$args"
466-
Exec-Console$dotnetExe"$runTests$args"
469+
Exec-Command$dotnetExe"$runTests$args"
467470
}finally {
468471
Get-Process"xunit*"-ErrorAction SilentlyContinue|Stop-Process
469472
if ($ci) {
@@ -588,7 +591,7 @@ function Deploy-VsixViaTool() {
588591
$vsixFile=Join-Path$VSSetupDir$vsixFileName
589592
$fullArg="$baseArgs$vsixFile"
590593
Write-Host"`tInstalling$vsixFileName"
591-
Exec-Console$vsixExe$fullArg
594+
Exec-Command$vsixExe$fullArg
592595
}
593596

594597
# Set up registry
@@ -746,18 +749,10 @@ try {
746749
&(Ensure-DotNetSdk) tool restore
747750
}
748751

749-
try
750-
{
751-
if ($bootstrap) {
752-
$bootstrapDir= Make-BootstrapBuild$bootstrapToolset
753-
}
754-
}
755-
catch
756-
{
757-
if ($ci) {
758-
Write-LogIssue-Type"error"-Message"(NETCORE_ENGINEERING_TELEMETRY=Build) Build failed"
759-
}
760-
throw$_
752+
if ($bootstrap-and$bootstrapDir-eq"") {
753+
Write-Host"Building bootstrap Compiler"
754+
Exec-Script (Join-Path$PSScriptRoot"make-bootstrap.ps1")"-name build -force -ci:$ci"
755+
$bootstrapDir=Join-Path$ArtifactsDir"bootstrap""build"
761756
}
762757

763758
if ($restore-or$build-or$rebuild-or$pack-or$sign-or$publish) {

‎eng/generate-compiler-code.cmd‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
@echooff
2-
powershell -noprofile -executionPolicy RemoteSigned -file"%~dp0\generate-compiler-code.ps1"%*
2+
pwsh -noprofile -executionPolicy RemoteSigned -file"%~dp0\generate-compiler-code.ps1"%*
33

‎eng/generate-compiler-code.ps1‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ $ErrorActionPreference="Stop"
1111
functionRun-Tool($projectFilePath,$toolArgs,$targetFramework) {
1212
$toolName=Split-Path-leaf$projectFilePath
1313
Write-Host"Running$toolName$toolArgs"
14-
Exec-Console$dotnet"run --project$projectFilePath --framework$targetFramework$toolArgs"
14+
Exec-DotNet"run --project$projectFilePath --framework$targetFramework$toolArgs"
1515
}
1616

1717
functionRun-LanguageCore($language,$languageSuffix,$languageDir,$syntaxProject,$errorFactsProject,$generatedDir,$generatedTestDir) {

‎eng/make-bootstrap.cmd‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@echooff
2+
pwsh -noprofile -file"%~dp0\make-bootstrap.ps1"%*

‎eng/make-bootstrap.ps1‎

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Make a bootstrap compiler and install it into artifacts/bootstrap folder
2+
3+
[CmdletBinding(PositionalBinding=$false)]
4+
param (
5+
[string]$name="local",
6+
[string]$toolset="Default",
7+
[string]$configuration="Release",
8+
[switch]$force=$false,
9+
[switch]$ci=$false
10+
)
11+
12+
Set-StrictMode-version2.0
13+
$ErrorActionPreference="Stop"
14+
15+
try {
16+
17+
. (Join-Path$PSScriptRoot"build-utils.ps1")
18+
19+
$bootstrapDir=Join-Path$ArtifactsDir"bootstrap"$name
20+
Write-Host"Building bootstrap compiler into$bootstrapDir"
21+
22+
if (Test-Path$bootstrapDir) {
23+
if ($force) {
24+
Write-Host"Removing existing bootstrap compiler"
25+
Remove-Item-Recurse-Force$bootstrapDir
26+
}
27+
else {
28+
Write-Host"Bootstrap compiler already exists. Use -force to rebuild"
29+
exit1
30+
}
31+
}
32+
33+
if ($toolset-ieq"Default") {
34+
$projectPath="src\NuGet\Microsoft.Net.Compilers.Toolset\AnyCpu\Microsoft.Net.Compilers.Toolset.Package.csproj"
35+
$packageName="Microsoft.Net.Compilers.Toolset"
36+
}
37+
elseif ($toolset-ieq"Framework") {
38+
$projectPath="src\NuGet\Microsoft.Net.Compilers.Toolset\Framework\Microsoft.Net.Compilers.Toolset.Framework.Package.csproj"
39+
$packageName="Microsoft.Net.Compilers.Toolset.Framework"
40+
}
41+
else {
42+
throw"Unsupported bootstrap toolset$toolset"
43+
}
44+
45+
$binaryLogFilePath=Join-Path$LogDir"bootstrap-$($name).binlog"
46+
47+
# Because we override the C#/VB toolset to build against our LKG package, it is important
48+
# that we do not reuse MSBuild nodes from other jobs/builds on the machine. Otherwise,
49+
# we'll run into issues such as https://github.com/dotnet/roslyn/issues/6211.
50+
# MSBuildAdditionalCommandLineArgs=
51+
$args="/p:TreatWarningsAsErrors=true /warnaserror /nologo /nodeReuse:false /p:Configuration=$configuration /v:m";
52+
$args+=" /p:RunAnalyzersDuringBuild=false /bl:$binaryLogFilePath"
53+
$args+=" /t:Pack /p:RoslynEnforceCodeStyle=false /p:DotNetUseShippingVersions=true /p:InitialDefineConstants=BOOTSTRAP"
54+
$args+=" /p:PackageOutputPath=$bootstrapDir /p:NgenOptimization=false /p:PublishWindowsPdb=false"
55+
56+
if ($ci) {
57+
$args+=" /p:ContinuousIntegrationBuild=true"
58+
}
59+
60+
Exec-DotNet"build$args$projectPath"
61+
62+
$packageFilePath=Get-ChildItem-Path$bootstrapDir-Filter"$packageName.*.nupkg"
63+
Write-Host"Found package$packageFilePath"
64+
Unzip$packageFilePath.FullName$bootstrapDir
65+
66+
Write-Host"Cleaning up artifacts"
67+
Exec-DotNet"build --no-restore /t:Clean$projectPath"
68+
Exec-DotNet"build-server shutdown"
69+
70+
exit0
71+
}
72+
catch {
73+
Write-Host$_
74+
Write-Host$_.Exception
75+
Write-Host$_.ScriptStackTrace
76+
exit1
77+
}
78+
finally {
79+
Pop-Location
80+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp