Skip to content

Commit 2d6f05b

Browse files
committed
Remove Variant option and add support for IncludeNoAsserts instead
1 parent ce0ad87 commit 2d6f05b

File tree

1 file changed

+35
-23
lines changed

1 file changed

+35
-23
lines changed

utils/build.ps1

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ in batch file format instead of executing them.
100100
.PARAMETER HostArchName
101101
The architecture where the toolchain will execute.
102102
103-
.PARAMETER Variant
104-
The toolchain variant to build. Defaults to `Asserts`.
103+
.PARAMETER IncludeNoAsserts
104+
If set, the no-assert toolchain variant is also build and included in the output.
105105
106106
.PARAMETER FoundationTestConfiguration
107107
Whether to run swift-foundation and swift-corelibs-foundation tests in a debug or release configuration.
@@ -148,8 +148,7 @@ param
148148
[string] $Stage = "",
149149
[ValidateSet("AMD64", "ARM64")]
150150
[string] $HostArchName = $(if ($env:PROCESSOR_ARCHITEW6432) { $env:PROCESSOR_ARCHITEW6432 } else { $env:PROCESSOR_ARCHITECTURE }),
151-
[ValidateSet("Asserts", "NoAsserts")]
152-
[string] $Variant = "Asserts",
151+
[switch] $IncludeNoAsserts = $false,
153152
[switch] $Clean,
154153
[switch] $DebugInfo,
155154
[ValidatePattern('^\d+(\.\d+)*$')]
@@ -623,8 +622,10 @@ function Get-InstallDir([Hashtable] $Platform) {
623622

624623
# For dev productivity, install the host toolchain directly using CMake.
625624
# This allows iterating on the toolchain using ninja builds.
626-
$HostPlatform.ToolchainInstallRoot = "$(Get-InstallDir $HostPlatform)\Toolchains\$ProductVersion+$Variant"
627-
$BuildPlatform.ToolchainInstallRoot = "$(Get-InstallDir $BuildPlatform)\Toolchains\$ProductVersion+$Variant"
625+
$HostPlatform.ToolchainInstallRoot = "$(Get-InstallDir $HostPlatform)\Toolchains\$ProductVersion+$PinnedToolchainVariant"
626+
$HostPlatform.NoAssertsToolchainInstallRoot = "$(Get-InstallDir $HostPlatform)\Toolchains\$ProductVersion+NoAsserts"
627+
$BuildPlatform.ToolchainInstallRoot = "$(Get-InstallDir $BuildPlatform)\Toolchains\$ProductVersion+$PinnedToolchainVariant"
628+
$BuildPlatform.NoAssertsToolchainInstallRoot = "$(Get-InstallDir $BuildPlatform)\Toolchains\$ProductVersion+NoAsserts"
628629

629630
# Build functions
630631
function Invoke-BuildStep {
@@ -1694,7 +1695,7 @@ function Build-CMark([Hashtable] $Platform) {
16941695
Build-CMakeProject `
16951696
-Src $SourceCache\cmark `
16961697
-Bin (Get-CMarkBinaryCache $Platform) `
1697-
-InstallTo "$(Get-InstallDir $Platform)\Toolchains\$ProductVersion+$Variant\usr" `
1698+
-InstallTo "$(Get-InstallDir $Platform)\Toolchains\$ProductVersion+$PinnedToolchainVariant\usr" `
16981699
-Platform $Platform `
16991700
-Defines @{
17001701
BUILD_SHARED_LIBS = "YES";
@@ -1737,7 +1738,7 @@ function Build-BuildTools([Hashtable] $Platform) {
17371738
SWIFT_INCLUDE_APINOTES = "NO";
17381739
SWIFT_INCLUDE_DOCS = "NO";
17391740
SWIFT_INCLUDE_TESTS = "NO";
1740-
"cmark-gfm_DIR" = "$(Get-InstallDir $Platform)\Toolchains\$ProductVersion+$Variant\usr\lib\cmake";
1741+
"cmark-gfm_DIR" = "$(Get-InstallDir $Platform)\Toolchains\$ProductVersion+$PinnedToolchainVariant\usr\lib\cmake";
17411742
}
17421743
}
17431744

@@ -1773,7 +1774,7 @@ function Load-LitTestOverrides($Filename) {
17731774
}
17741775
}
17751776

1776-
function Get-CompilersDefines([Hashtable] $Platform, [switch] $Test) {
1777+
function Get-CompilersDefines([Hashtable] $Platformm, [string] $Variant, [switch] $Test) {
17771778
$BuildTools = [IO.Path]::Combine((Get-ProjectBinaryCache $BuildPlatform BuildTools), "bin")
17781779
$PythonRoot = [IO.Path]::Combine((Get-PythonPath $Platform), "tools")
17791780
$PythonLibName = "python{0}{1}" -f ([System.Version]$PythonVersion).Major, ([System.Version]$PythonVersion).Minor
@@ -1848,7 +1849,7 @@ function Get-CompilersDefines([Hashtable] $Platform, [switch] $Test) {
18481849
}
18491850
}
18501851

1851-
function Build-Compilers([Hashtable] $Platform) {
1852+
function Build-Compilers([Hashtable] $Platform, [string] $Variant) {
18521853
New-Item -ItemType SymbolicLink -Path "$BinaryCache\$($HostPlatform.Triple)\compilers" -Target "$BinaryCache\5" -ErrorAction Ignore
18531854
Build-CMakeProject `
18541855
-Src $SourceCache\llvm-project\llvm `
@@ -1859,7 +1860,7 @@ function Build-Compilers([Hashtable] $Platform) {
18591860
-UsePinnedCompilers Swift `
18601861
-BuildTargets @("install-distribution") `
18611862
-CacheScript $SourceCache\swift\cmake\caches\Windows-$($Platform.Architecture.LLVMName).cmake `
1862-
-Defines (Get-CompilersDefines $Platform)
1863+
-Defines (Get-CompilersDefines $Platform $Variant)
18631864

18641865
$Settings = @{
18651866
FallbackLibrarySearchPaths = @("usr/bin")
@@ -1869,10 +1870,10 @@ function Build-Compilers([Hashtable] $Platform) {
18691870
Write-PList -Settings $Settings -Path "$($Platform.ToolchainInstallRoot)\ToolchainInfo.plist"
18701871
}
18711872

1872-
function Test-Compilers([Hashtable] $Platform, [switch] $TestClang, [switch] $TestLLD, [switch] $TestLLDB, [switch] $TestLLVM, [switch] $TestSwift) {
1873+
function Test-Compilers([Hashtable] $Platform, [string] $Variant, [switch] $TestClang, [switch] $TestLLD, [switch] $TestLLDB, [switch] $TestLLVM, [switch] $TestSwift) {
18731874
Invoke-IsolatingEnvVars {
18741875
$env:Path = "$(Get-CMarkBinaryCache $Platform)\src;$(Get-ProjectBinaryCache $BuildPlatform Compilers)\tools\swift\libdispatch-windows-$($Platform.Architecture.LLVMName)-prefix\bin;$(Get-ProjectBinaryCache $BuildPlatform Compilers)\bin;$env:Path;$VSInstallRoot\DIA SDK\bin\$($HostPlatform.Architecture.VSName);$UnixToolsBinDir"
1875-
$TestingDefines = Get-CompilersDefines $Platform -Test
1876+
$TestingDefines = Get-CompilersDefines $Platform $Variant -Test
18761877
if ($TestLLVM) { $Targets += @("check-llvm") }
18771878
if ($TestClang) { $Targets += @("check-clang") }
18781879
if ($TestLLD) { $Targets += @("check-lld") }
@@ -1984,19 +1985,26 @@ function Build-mimalloc() {
19841985
"ld.lld.exe",
19851986
"ld64.lld.exe"
19861987
)
1987-
foreach ($Tool in $Tools) {
1988-
$Binary = [IO.Path]::Combine($Platform.ToolchainInstallRoot, "usr", "bin", $Tool)
1988+
$Binaries = $Tools | ForEach-Object {[IO.Path]::Combine($Platform.ToolchainInstallRoot, "usr", "bin", $_)}
1989+
if ($IncludeNoAsserts) {
1990+
$NoAssertBinaries = $Tools `
1991+
| ForEach-Object {[IO.Path]::Combine($Platform.NoAssertsToolchainInstallRoot, "usr", "bin", $_)} `
1992+
| Where-Object { Test-Path $_ -PathType Leaf }
1993+
$Binaries = $Binaries + $NoAssertBinaries
1994+
}
1995+
foreach ($Binary in $Binaries) {
1996+
$Name = [IO.Path]::GetFileName($Binary)
19891997
# Binary-patch in place
19901998
Invoke-Program "$SourceCache\mimalloc\bin\minject$BuildSuffix" "-f" "-i" "$Binary"
19911999
# Log the import table
1992-
$LogFile = "$BinaryCache\$($Platform.Triple)\mimalloc\minject-log-$Tool.txt"
1993-
$ErrorFile = "$BinaryCache\$($Platform.Triple)\mimalloc\minject-log-$Tool-error.txt"
2000+
$LogFile = "$BinaryCache\$($Platform.Triple)\mimalloc\minject-log-$Name.txt"
2001+
$ErrorFile = "$BinaryCache\$($Platform.Triple)\mimalloc\minject-log-$Name-error.txt"
19942002
Invoke-Program "$SourceCache\mimalloc\bin\minject$BuildSuffix" "-l" "$Binary" -OutFile $LogFile -ErrorFile $ErrorFile
19952003
# Verify patching
19962004
$Found = Select-String -Path $LogFile -Pattern "mimalloc"
19972005
if (-not $Found) {
19982006
Get-Content $ErrorFile
1999-
throw "Failed to patch mimalloc for $Tool"
2007+
throw "Failed to patch mimalloc for $Name"
20002008
}
20012009
}
20022010
}
@@ -3232,8 +3240,8 @@ function Test-PackageManager() {
32323240
-Src $SrcDir `
32333241
-Bin "$BinaryCache\$($HostPlatform.Triple)\PackageManagerTests" `
32343242
-Platform $HostPlatform `
3235-
-Xcc "-I$(Get-InstallDir $Platform)\Toolchains\$ProductVersion+$Variant\usr\include" `
3236-
-Xlinker "-L$(Get-InstallDir $Platform)\Toolchains\$ProductVersion+$Variant\usr\lib"
3243+
-Xcc "-I$(Get-InstallDir $Platform)\Toolchains\$ProductVersion+$PinnedToolchainVariant\usr\include" `
3244+
-Xlinker "-L$(Get-InstallDir $Platform)\Toolchains\$ProductVersion+$PinnedToolchainVariant\usr\lib"
32373245
}
32383246

32393247
function Build-Installer([Hashtable] $Platform) {
@@ -3245,6 +3253,7 @@ function Build-Installer([Hashtable] $Platform) {
32453253
BundleFlavor = "offline";
32463254
ImageRoot = "$(Get-InstallDir $Platform)\";
32473255
INCLUDE_SWIFT_DOCC = $INCLUDE_SWIFT_DOCC;
3256+
INCLUDE_NOASSERTS = $IncludeNoAsserts
32483257
SWIFT_DOCC_BUILD = "$(Get-ProjectBinaryCache $HostPlatform DocC)\release";
32493258
SWIFT_DOCC_RENDER_ARTIFACT_ROOT = "${SourceCache}\swift-docc-render-artifact";
32503259
}
@@ -3314,15 +3323,18 @@ if (-not $SkipBuild) {
33143323
Invoke-BuildStep Build-BuildTools $BuildPlatform
33153324
if ($IsCrossCompiling) {
33163325
Invoke-BuildStep Build-XML2 $BuildPlatform
3317-
Invoke-BuildStep Build-Compilers $BuildPlatform
3326+
Invoke-BuildStep Build-Compilers $BuildPlatform -Variant $PinnedToolchainVariant
33183327
}
33193328
if ($IncludeDS2) {
33203329
Invoke-BuildStep Build-RegsGen2 $BuildPlatform
33213330
}
33223331

33233332
Invoke-BuildStep Build-CMark $HostPlatform
33243333
Invoke-BuildStep Build-XML2 $HostPlatform
3325-
Invoke-BuildStep Build-Compilers $HostPlatform
3334+
Invoke-BuildStep Build-Compilers $HostPlatform -Variant "Asserts"
3335+
if ($IncludeNoAsserts) {
3336+
Invoke-BuildStep Build-Compilers $HostPlatform -Variant "NoAsserts"
3337+
}
33263338

33273339
Invoke-BuildStep Build-SDK $BuildPlatform -IncludeMacros
33283340

@@ -3419,7 +3431,7 @@ if (-not $IsCrossCompiling) {
34193431
"-TestLLVM" = $Test -contains "llvm";
34203432
"-TestSwift" = $Test -contains "swift";
34213433
}
3422-
Invoke-BuildStep Test-Compilers $HostPlatform $Tests
3434+
Invoke-BuildStep Test-Compilers $HostPlatform $PinnedToolchainVariant $Tests
34233435
}
34243436

34253437
# FIXME(jeffdav): Invoke-BuildStep needs a platform dictionary, even though the Test-

0 commit comments

Comments
 (0)