@@ -54,10 +54,6 @@ The toolchain snapshot to build the early components with.
54
54
. PARAMETER PinnedSHA256
55
55
The SHA256 for the pinned toolchain.
56
56
57
- . PARAMETER PinnedToolchainVariant
58
- The toolchain variant to use while building the toolchain. Defaults to
59
- `Asserts`.
60
-
61
57
. PARAMETER AndroidNDKVersion
62
58
The version number of the Android NDK to be used.
63
59
@@ -100,8 +96,8 @@ in batch file format instead of executing them.
100
96
. PARAMETER HostArchName
101
97
The architecture where the toolchain will execute.
102
98
103
- . PARAMETER Variant
104
- The toolchain variant to build. Defaults to `Asserts` .
99
+ . PARAMETER IncludeNoAsserts
100
+ If set, the no-assert toolchain variant is also build and included in the output .
105
101
106
102
. PARAMETER FoundationTestConfiguration
107
103
Whether to run swift-foundation and swift-corelibs-foundation tests in a debug or release configuration.
@@ -132,8 +128,6 @@ param
132
128
[ValidatePattern (" ^([A-Fa-f0-9]{64}|)$" )]
133
129
[string ] $PinnedSHA256 = " " ,
134
130
[string ] $PinnedVersion = " " ,
135
- [ValidateSet (" Asserts" , " NoAsserts" )]
136
- [string ] $PinnedToolchainVariant = " Asserts" ,
137
131
[ValidatePattern (' ^\d+(\.\d+)*$' )]
138
132
[string ] $PythonVersion = " 3.9.10" ,
139
133
[ValidatePattern (" ^r(?:[1-9]|[1-9][0-9])(?:[a-z])?$" )]
@@ -148,8 +142,7 @@ param
148
142
[string ] $Stage = " " ,
149
143
[ValidateSet (" AMD64" , " ARM64" )]
150
144
[string ] $HostArchName = $ (if ($env: PROCESSOR_ARCHITEW6432 ) { $env: PROCESSOR_ARCHITEW6432 } else { $env: PROCESSOR_ARCHITECTURE }),
151
- [ValidateSet (" Asserts" , " NoAsserts" )]
152
- [string ] $Variant = " Asserts" ,
145
+ [switch ] $IncludeNoAsserts = $false ,
153
146
[switch ] $Clean ,
154
147
[switch ] $DebugInfo ,
155
148
[ValidatePattern (' ^\d+(\.\d+)*$' )]
@@ -623,8 +616,10 @@ function Get-InstallDir([Hashtable] $Platform) {
623
616
624
617
# For dev productivity, install the host toolchain directly using CMake.
625
618
# 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 "
619
+ $HostPlatform.ToolchainInstallRoot = " $ ( Get-InstallDir $HostPlatform ) \Toolchains\$ProductVersion +Asserts"
620
+ $HostPlatform.NoAssertsToolchainInstallRoot = " $ ( Get-InstallDir $HostPlatform ) \Toolchains\$ProductVersion +NoAsserts"
621
+ $BuildPlatform.ToolchainInstallRoot = " $ ( Get-InstallDir $BuildPlatform ) \Toolchains\$ProductVersion +Asserts"
622
+ $BuildPlatform.NoAssertsToolchainInstallRoot = " $ ( Get-InstallDir $BuildPlatform ) \Toolchains\$ProductVersion +NoAsserts"
628
623
629
624
# Build functions
630
625
function Invoke-BuildStep {
@@ -636,21 +631,36 @@ function Invoke-BuildStep {
636
631
[Parameter (Position = 1 , Mandatory )]
637
632
[Hashtable ] $Platform ,
638
633
[Parameter (ValueFromRemainingArguments )]
639
- $RemainingArgs
634
+ [ Object []] $RemainingArgs
640
635
)
641
636
642
637
if ($Summary ) {
643
638
$Stopwatch = [Diagnostics.Stopwatch ]::StartNew()
644
639
}
645
640
646
641
$SplatArgs = @ {}
647
- foreach ($Arg in $RemainingArgs ) {
648
- if ($Arg -is [Hashtable ]) {
649
- $SplatArgs += $Arg
650
- } elseif ($Arg -is [string ]) {
651
- $SplatArgs [$Arg.TrimStart (' -' )] = $true
652
- } else {
653
- throw " $Arg is unknown type: $ ( $Arg.GetType ()) "
642
+ if ($RemainingArgs ) {
643
+ $Enumerator = $RemainingArgs.GetEnumerator ()
644
+ while ($Enumerator.MoveNext ()) {
645
+ $Arg = $Enumerator.Current
646
+ if ($Arg -is [Hashtable ]) {
647
+ $SplatArgs += $Arg
648
+ } elseif ($Arg -is [string ] -and $Arg.StartsWith (' -' )) {
649
+ $ParamName = $Arg.TrimStart (' -' )
650
+ $HasNextArg = $RemainingArgs.IndexOf ($Arg ) -lt ($RemainingArgs.Count - 1 )
651
+ if ($HasNextArg ) {
652
+ $NextArg = $RemainingArgs [$RemainingArgs.IndexOf ($Arg ) + 1 ]
653
+ if ($NextArg -is [string ] -and ! $NextArg.StartsWith (' -' )) {
654
+ $SplatArgs [$ParamName ] = $NextArg
655
+ $Enumerator.MoveNext () # Skip NextArg
656
+ continue
657
+ }
658
+ }
659
+ # Must be a flag.
660
+ $SplatArgs [$ParamName ] = $true
661
+ } else {
662
+ throw " Positional parameter '$Arg ' found. The Invoke-BuildStep function only supports named parameters after the required Name and Platform parameters."
663
+ }
654
664
}
655
665
}
656
666
@@ -1179,15 +1189,15 @@ function Get-PinnedToolchainToolsDir() {
1179
1189
}
1180
1190
}
1181
1191
1182
- $VariantToolchainPath = [IO.Path ]::Combine($ToolchainsRoot , " $ ( Get-PinnedToolchainVersion ) +$PinnedToolchainVariant " , " usr" , " bin" )
1192
+ $VariantToolchainPath = [IO.Path ]::Combine($ToolchainsRoot , " $ ( Get-PinnedToolchainVersion ) +Asserts " , " usr" , " bin" )
1183
1193
1184
1194
if (Test-Path $VariantToolchainPath ) {
1185
1195
return $VariantToolchainPath
1186
1196
}
1187
1197
1188
1198
return [IO.Path ]::Combine(" $BinaryCache \" , " toolchains" , $PinnedToolchain ,
1189
1199
" Library" , " Developer" , " Toolchains" ,
1190
- " unknown-$PinnedToolchainVariant -development.xctoolchain" , " usr" , " bin" )
1200
+ " unknown-Asserts -development.xctoolchain" , " usr" , " bin" )
1191
1201
}
1192
1202
1193
1203
function Get-PinnedToolchainSDK () {
@@ -1673,7 +1683,7 @@ function Build-WiXProject() {
1673
1683
1674
1684
$MSBuildArgs = @ ( " -noLogo" , " -maxCpuCount" , " -restore" , " $SourceCache \swift-installer-scripts\platforms\Windows\$FileName " )
1675
1685
foreach ($Property in $Properties.GetEnumerator ()) {
1676
- if ($Property.Value.Contains (" " )) {
1686
+ if ($Property.Value -is [ string ] -and $Property .Value .Contains (" " )) {
1677
1687
$MSBuildArgs += " -p:$ ( $Property.Key ) =$ ( $Property.Value.Replace (' \' , ' \\' )) "
1678
1688
} else {
1679
1689
$MSBuildArgs += " -p:$ ( $Property.Key ) =$ ( $Property.Value ) "
@@ -1694,7 +1704,7 @@ function Build-CMark([Hashtable] $Platform) {
1694
1704
Build-CMakeProject `
1695
1705
- Src $SourceCache \cmark `
1696
1706
- Bin (Get-CMarkBinaryCache $Platform ) `
1697
- - InstallTo " $ ( Get-InstallDir $Platform ) \Toolchains\$ProductVersion +$Variant \usr" `
1707
+ - InstallTo " $ ( Get-InstallDir $Platform ) \Toolchains\$ProductVersion +Asserts \usr" `
1698
1708
- Platform $Platform `
1699
1709
- Defines @ {
1700
1710
BUILD_SHARED_LIBS = " YES" ;
@@ -1737,7 +1747,7 @@ function Build-BuildTools([Hashtable] $Platform) {
1737
1747
SWIFT_INCLUDE_APINOTES = " NO" ;
1738
1748
SWIFT_INCLUDE_DOCS = " NO" ;
1739
1749
SWIFT_INCLUDE_TESTS = " NO" ;
1740
- " cmark-gfm_DIR" = " $ ( Get-InstallDir $Platform ) \Toolchains\$ProductVersion +$Variant \usr\lib\cmake" ;
1750
+ " cmark-gfm_DIR" = " $ ( Get-InstallDir $Platform ) \Toolchains\$ProductVersion +Asserts \usr\lib\cmake" ;
1741
1751
}
1742
1752
}
1743
1753
@@ -1773,7 +1783,7 @@ function Load-LitTestOverrides($Filename) {
1773
1783
}
1774
1784
}
1775
1785
1776
- function Get-CompilersDefines ([Hashtable ] $Platform , [switch ] $Test ) {
1786
+ function Get-CompilersDefines ([Hashtable ] $Platform , [string ] $Variant , [ switch ] $Test ) {
1777
1787
$BuildTools = [IO.Path ]::Combine((Get-ProjectBinaryCache $BuildPlatform BuildTools), " bin" )
1778
1788
$PythonRoot = [IO.Path ]::Combine((Get-PythonPath $Platform ), " tools" )
1779
1789
$PythonLibName = " python{0}{1}" -f ([System.Version ]$PythonVersion ).Major, ([System.Version ]$PythonVersion ).Minor
@@ -1849,7 +1859,7 @@ function Get-CompilersDefines([Hashtable] $Platform, [switch] $Test) {
1849
1859
}
1850
1860
}
1851
1861
1852
- function Build-Compilers ([Hashtable ] $Platform ) {
1862
+ function Build-Compilers ([Hashtable ] $Platform , [ string ] $Variant ) {
1853
1863
New-Item - ItemType SymbolicLink - Path " $BinaryCache \$ ( $HostPlatform.Triple ) \compilers" - Target " $BinaryCache \5" - ErrorAction Ignore
1854
1864
Build-CMakeProject `
1855
1865
- Src $SourceCache \llvm- project\llvm `
@@ -1860,7 +1870,7 @@ function Build-Compilers([Hashtable] $Platform) {
1860
1870
- UsePinnedCompilers Swift `
1861
1871
- BuildTargets @ (" install-distribution" ) `
1862
1872
- CacheScript $SourceCache \swift\cmake\caches\Windows- $ ($Platform.Architecture.LLVMName ).cmake `
1863
- - Defines (Get-CompilersDefines $Platform )
1873
+ - Defines (Get-CompilersDefines $Platform $Variant )
1864
1874
1865
1875
$Settings = @ {
1866
1876
FallbackLibrarySearchPaths = @ (" usr/bin" )
@@ -1870,10 +1880,10 @@ function Build-Compilers([Hashtable] $Platform) {
1870
1880
Write-PList - Settings $Settings - Path " $ ( $Platform.ToolchainInstallRoot ) \ToolchainInfo.plist"
1871
1881
}
1872
1882
1873
- function Test-Compilers ([Hashtable ] $Platform , [switch ] $TestClang , [switch ] $TestLLD , [switch ] $TestLLDB , [switch ] $TestLLVM , [switch ] $TestSwift ) {
1883
+ function Test-Compilers ([Hashtable ] $Platform , [string ] $Variant , [ switch ] $TestClang , [switch ] $TestLLD , [switch ] $TestLLDB , [switch ] $TestLLVM , [switch ] $TestSwift ) {
1874
1884
Invoke-IsolatingEnvVars {
1875
1885
$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 "
1876
- $TestingDefines = Get-CompilersDefines $Platform - Test
1886
+ $TestingDefines = Get-CompilersDefines $Platform $Variant - Test
1877
1887
if ($TestLLVM ) { $Targets += @ (" check-llvm" ) }
1878
1888
if ($TestClang ) { $Targets += @ (" check-clang" ) }
1879
1889
if ($TestLLD ) { $Targets += @ (" check-lld" ) }
@@ -1985,19 +1995,24 @@ function Build-mimalloc() {
1985
1995
" ld.lld.exe" ,
1986
1996
" ld64.lld.exe"
1987
1997
)
1988
- foreach ($Tool in $Tools ) {
1989
- $Binary = [IO.Path ]::Combine($Platform.ToolchainInstallRoot , " usr" , " bin" , $Tool )
1998
+ $Binaries = $Tools | ForEach-Object {[IO.Path ]::Combine($Platform.ToolchainInstallRoot , " usr" , " bin" , $_ )}
1999
+ if ($IncludeNoAsserts ) {
2000
+ $NoAssertBinaries = $Tools | ForEach-Object {[IO.Path ]::Combine($Platform.NoAssertsToolchainInstallRoot , " usr" , " bin" , $_ )}
2001
+ $Binaries = $Binaries + $NoAssertBinaries
2002
+ }
2003
+ foreach ($Binary in $Binaries ) {
2004
+ $Name = [IO.Path ]::GetFileName($Binary )
1990
2005
# Binary-patch in place
1991
2006
Invoke-Program " $SourceCache \mimalloc\bin\minject$BuildSuffix " " -f" " -i" " $Binary "
1992
2007
# Log the import table
1993
- $LogFile = " $BinaryCache \$ ( $Platform.Triple ) \mimalloc\minject-log-$Tool .txt"
1994
- $ErrorFile = " $BinaryCache \$ ( $Platform.Triple ) \mimalloc\minject-log-$Tool -error.txt"
2008
+ $LogFile = " $BinaryCache \$ ( $Platform.Triple ) \mimalloc\minject-log-$Name .txt"
2009
+ $ErrorFile = " $BinaryCache \$ ( $Platform.Triple ) \mimalloc\minject-log-$Name -error.txt"
1995
2010
Invoke-Program " $SourceCache \mimalloc\bin\minject$BuildSuffix " " -l" " $Binary " - OutFile $LogFile - ErrorFile $ErrorFile
1996
2011
# Verify patching
1997
2012
$Found = Select-String - Path $LogFile - Pattern " mimalloc"
1998
2013
if (-not $Found ) {
1999
2014
Get-Content $ErrorFile
2000
- throw " Failed to patch mimalloc for $Tool "
2015
+ throw " Failed to patch mimalloc for $Name "
2001
2016
}
2002
2017
}
2003
2018
}
@@ -3243,8 +3258,8 @@ function Test-PackageManager() {
3243
3258
- Src $SrcDir `
3244
3259
- Bin " $BinaryCache \$ ( $HostPlatform.Triple ) \PackageManagerTests" `
3245
3260
- Platform $HostPlatform `
3246
- - Xcc " -I$ ( Get-InstallDir $Platform ) \Toolchains\$ProductVersion +$Variant \usr\include" `
3247
- - Xlinker " -L$ ( Get-InstallDir $Platform ) \Toolchains\$ProductVersion +$Variant \usr\lib"
3261
+ - Xcc " -I$ ( Get-InstallDir $Platform ) \Toolchains\$ProductVersion +Asserts \usr\include" `
3262
+ - Xlinker " -L$ ( Get-InstallDir $Platform ) \Toolchains\$ProductVersion +Asserts \usr\lib"
3248
3263
}
3249
3264
3250
3265
function Build-Installer ([Hashtable ] $Platform ) {
@@ -3272,6 +3287,7 @@ function Build-Installer([Hashtable] $Platform) {
3272
3287
$Properties [" Platforms" ] = " `" windows$ ( if ($Android ) { " ;android" }) `" " ;
3273
3288
$Properties [" AndroidArchitectures" ] = " `" $ ( ($AndroidSDKPlatforms | ForEach-Object { $_.Architecture.LLVMName }) -Join " ;" ) `" "
3274
3289
$Properties [" WindowsArchitectures" ] = " `" $ ( ($WindowsSDKPlatforms | ForEach-Object { $_.Architecture.LLVMName }) -Join " ;" ) `" "
3290
+ $Properties [" ToolchainVariants" ] = " `" asserts$ ( if ($IncludeNoAsserts ) { " ;noasserts" }) `" " ;
3275
3291
foreach ($SDKPlatform in $WindowsSDKPlatforms ) {
3276
3292
$Properties [" WindowsRuntime$ ( $SDKPlatform.Architecture.ShortName.ToUpperInvariant ()) " ] = [IO.Path ]::Combine((Get-InstallDir $SDKPlatform ), " Runtimes" , " $ProductVersion " );
3277
3293
}
@@ -3295,6 +3311,37 @@ function Copy-BuildArtifactsToStage([Hashtable] $Platform) {
3295
3311
Invoke-Program " $ ( $WiX.Path ) \wix.exe" -- burn detach " $BinaryCache \$ ( $Platform.Triple ) \installer\Release\$ ( $Platform.Architecture.VSName ) \installer.exe" - engine " $Stage \installer-engine.exe" - intermediateFolder " $BinaryCache \$ ( $Platform.Triple ) \installer\$ ( $Platform.Architecture.VSName ) \"
3296
3312
}
3297
3313
3314
+ function Build-NoAssertsToolchain () {
3315
+ if ($ToBatch ) {
3316
+ Write-Output " "
3317
+ Write-Output " Building NoAsserts Toolchain ..."
3318
+ } else {
3319
+ Write-Host - ForegroundColor Cyan " [$ ( [DateTime ]::Now.ToString(" yyyy-MM-dd HH:mm:ss" )) ] Building NoAsserts Toolchain ..."
3320
+ }
3321
+ $Stopwatch = [Diagnostics.Stopwatch ]::StartNew()
3322
+
3323
+ Invoke-BuildStep Build-Compilers $HostPlatform - Variant " NoAsserts"
3324
+
3325
+ # Only compilers have NoAsserts enabled. Copy the rest of the Toolcahin binaries from the Asserts output
3326
+ # Use robocopy for efficient copying
3327
+ # /E : Copies subdirectories, including empty ones.
3328
+ # /XC: Excludes existing files with the same timestamp but different file sizes.
3329
+ # /XN: Excludes existing files that are newer than the copy in the source directory.
3330
+ # /XO: Excludes existing files that are older than the copy in the source directory.
3331
+ # /NFL: Do not list coppied files in output
3332
+ # /NDL: Do not list directories in output
3333
+ # /NJH: Do not write a job header
3334
+ # /NC: Do not write file classes
3335
+ # /NS: Do not write file sizes
3336
+ # /NP: Do not show progress indicator
3337
+ & robocopy $HostPlatform.ToolchainInstallRoot $HostPlatform.NoAssertsToolchainInstallRoot / E / XC / XN / XO / NS / NC / NFL / NDL / NJH
3338
+
3339
+ if (-not $ToBatch ) {
3340
+ Write-Host - ForegroundColor Cyan " [$ ( [DateTime ]::Now.ToString(" yyyy-MM-dd HH:mm:ss" )) ] Building Instalting NoAsserts Toolchain in $ ( $Stopwatch.Elapsed ) "
3341
+ Write-Host " "
3342
+ }
3343
+ }
3344
+
3298
3345
# -------------------------------------------------------------------
3299
3346
try {
3300
3347
@@ -3325,15 +3372,15 @@ if (-not $SkipBuild) {
3325
3372
Invoke-BuildStep Build-BuildTools $BuildPlatform
3326
3373
if ($IsCrossCompiling ) {
3327
3374
Invoke-BuildStep Build-XML2 $BuildPlatform
3328
- Invoke-BuildStep Build-Compilers $BuildPlatform
3375
+ Invoke-BuildStep Build-Compilers $BuildPlatform - Variant " Asserts "
3329
3376
}
3330
3377
if ($IncludeDS2 ) {
3331
3378
Invoke-BuildStep Build-RegsGen2 $BuildPlatform
3332
3379
}
3333
3380
3334
3381
Invoke-BuildStep Build-CMark $HostPlatform
3335
3382
Invoke-BuildStep Build-XML2 $HostPlatform
3336
- Invoke-BuildStep Build-Compilers $HostPlatform
3383
+ Invoke-BuildStep Build-Compilers $HostPlatform - Variant " Asserts "
3337
3384
3338
3385
Invoke-BuildStep Build-SDK $BuildPlatform - IncludeMacros
3339
3386
@@ -3404,6 +3451,10 @@ if (-not $SkipBuild) {
3404
3451
3405
3452
Install-HostToolchain
3406
3453
3454
+ if ($IncludeNoAsserts ) {
3455
+ Build-NoAssertsToolchain
3456
+ }
3457
+
3407
3458
if (-not $SkipBuild ) {
3408
3459
Invoke-BuildStep Build-mimalloc $HostPlatform
3409
3460
}
@@ -3430,7 +3481,7 @@ if (-not $IsCrossCompiling) {
3430
3481
" -TestLLVM" = $Test -contains " llvm" ;
3431
3482
" -TestSwift" = $Test -contains " swift" ;
3432
3483
}
3433
- Invoke-BuildStep Test-Compilers $HostPlatform $Tests
3484
+ Invoke-BuildStep Test-Compilers $HostPlatform - Variant " Asserts " $Tests
3434
3485
}
3435
3486
3436
3487
# FIXME(jeffdav): Invoke-BuildStep needs a platform dictionary, even though the Test-
0 commit comments