@@ -54,6 +54,10 @@ 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
+
57
61
. PARAMETER AndroidNDKVersion
58
62
The version number of the Android NDK to be used.
59
63
@@ -102,6 +106,9 @@ in batch file format instead of executing them.
102
106
. PARAMETER HostArchName
103
107
The architecture where the toolchain will execute.
104
108
109
+ . PARAMETER Variant
110
+ The toolchain variant to build. Defaults to `Asserts`.
111
+
105
112
. EXAMPLE
106
113
PS> .\Build.ps1
107
114
@@ -128,6 +135,8 @@ param
128
135
[ValidatePattern (" ^[A-Fa-f0-9]{64}$" )]
129
136
[string ] $PinnedSHA256 = " " ,
130
137
[string ] $PinnedVersion = " " ,
138
+ [ValidateSet (" Asserts" , " NoAsserts" )]
139
+ [string ] $PinnedToolchainVariant = " Asserts" ,
131
140
[string ] $PythonVersion = " 3.9.10" ,
132
141
[ValidatePattern (" ^r(?:[1-9]|[1-9][0-9])(?:[a-z])?$" )]
133
142
[string ] $AndroidNDKVersion = " r26b" ,
@@ -150,6 +159,8 @@ param
150
159
[string ] $BuildTo = " " ,
151
160
[ValidateSet (" AMD64" , " ARM64" )]
152
161
[string ] $HostArchName = $ (if ($env: PROCESSOR_ARCHITEW6432 -ne $null ) { " $env: PROCESSOR_ARCHITEW6432 " } else { " $env: PROCESSOR_ARCHITECTURE " }),
162
+ [ValidateSet (" Asserts" , " NoAsserts" )]
163
+ [string ] $Variant = " Asserts" ,
153
164
[switch ] $Clean ,
154
165
[switch ] $DebugInfo ,
155
166
[switch ] $EnableCaching ,
@@ -238,7 +249,7 @@ $ArchX64 = @{
238
249
ExperimentalSDKInstallRoot = " $BinaryCache \x64\Windows.platform\Developer\SDKs\WindowsExperimental.sdk" ;
239
250
XCTestInstallRoot = " $BinaryCache \x64\Windows.platform\Developer\Library\XCTest-development" ;
240
251
SwiftTestingInstallRoot = " $BinaryCache \x64\Windows.platform\Developer\Library\Testing-development" ;
241
- ToolchainInstallRoot = " $BinaryCache \x64\toolchains\$ProductVersion +Asserts " ;
252
+ ToolchainInstallRoot = " $BinaryCache \x64\toolchains\$ProductVersion +$Variant " ;
242
253
Cache = @ {};
243
254
}
244
255
@@ -272,7 +283,7 @@ $ArchARM64 = @{
272
283
SDKInstallRoot = " $BinaryCache \arm64\Windows.platform\Developer\SDKs\Windows.sdk" ;
273
284
ExperimentalSDKInstallRoot = " $BinaryCache \arm64\Windows.platform\Developer\SDKs\WindowsExperimental.sdk" ;
274
285
XCTestInstallRoot = " $BinaryCache \arm64\Windows.platform\Developer\Library\XCTest-development" ;
275
- ToolchainInstallRoot = " $BinaryCache \arm64\toolchains\$ProductVersion +Asserts " ;
286
+ ToolchainInstallRoot = " $BinaryCache \arm64\toolchains\$ProductVersion +$Variant " ;
276
287
SwiftTestingInstallRoot = " $BinaryCache \arm64\Windows.platform\Developer\Library\Testing-development" ;
277
288
Cache = @ {};
278
289
}
@@ -405,7 +416,7 @@ $LibraryRoot = "$ImageRoot\Library"
405
416
406
417
# For dev productivity, install the host toolchain directly using CMake.
407
418
# This allows iterating on the toolchain using ninja builds.
408
- $HostArch.ToolchainInstallRoot = " $ ( Get-InstallDir $HostArch ) \Toolchains\$ProductVersion +Asserts "
419
+ $HostArch.ToolchainInstallRoot = " $ ( Get-InstallDir $HostArch ) \Toolchains\$ProductVersion +$Variant "
409
420
410
421
# Resolve the architectures received as argument
411
422
$AndroidSDKArchs = @ ($AndroidSDKs | ForEach-Object {
@@ -934,20 +945,25 @@ function Fetch-Dependencies {
934
945
}
935
946
936
947
function Get-PinnedToolchainToolsDir () {
937
- # NOTE: add a workaround for the main snapshots that used the wrong version
938
- # when building that was not noticed. This allows use of the nightly snapshot
948
+ $ToolchainsRoot = [IO.Path ]::Combine(" $BinaryCache " , " toolchains" , " $PinnedToolchain " , " LocalApp" , " Programs" , " Swift" , " Toolchains" )
949
+ $VariantToolchainPath = [IO.Path ]::Combine($ToolchainsRoot , " $ ( Get-PinnedToolchainVersion ) +$PinnedToolchainVariant " , " usr" , " bin" )
950
+
951
+ # NOTE: Add a workaround for the main snapshots that inadvertently used the
952
+ # wrong version when they were built. This allows use of the nightly snapshot
939
953
# as a pinned toolchain.
940
954
if ((Get-PinnedToolchainVersion ) -eq " 0.0.0" ) {
941
- if (-not (Test-Path " $BinaryCache \toolchains\ ${PinnedToolchain} \LocalApp\Programs\Swift\Toolchains \0.0.0+Asserts\usr\bin" )) {
942
- if (Test-Path " $BinaryCache \toolchains\ ${PinnedToolchain} \LocalApp\Programs\Swift\Toolchains \6.0.0+Asserts\usr\bin" ) {
943
- return " $BinaryCache \toolchains\ ${PinnedToolchain} \LocalApp\Programs\Swift\Toolchains \6.0.0+Asserts\usr\bin"
955
+ if (-not (Test-Path " $ToolchainsRoot \0.0.0+Asserts\usr\bin" )) {
956
+ if (Test-Path " $ToolchainsRoot \6.0.0+Asserts\usr\bin" ) {
957
+ return " $ToolchainsRoot \6.0.0+Asserts\usr\bin"
944
958
}
945
959
}
946
960
}
947
- if (Test-Path " $BinaryCache \toolchains\${PinnedToolchain} \LocalApp\Programs\Swift\Toolchains\$ ( Get-PinnedToolchainVersion ) +Asserts\usr\bin" ) {
948
- return " $BinaryCache \toolchains\${PinnedToolchain} \LocalApp\Programs\Swift\Toolchains\$ ( Get-PinnedToolchainVersion ) +Asserts\usr\bin"
961
+
962
+ if (Test-Path $VariantToolchainPath ) {
963
+ return $VariantToolchainPath
949
964
}
950
- return " $BinaryCache \toolchains\${PinnedToolchain} \Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin"
965
+
966
+ return " $BinaryCache \toolchains\${PinnedToolchain} \Library\Developer\Toolchains\unknown-$PinnedToolchainVariant -development.xctoolchain\usr\bin"
951
967
}
952
968
953
969
function Get-PinnedToolchainSDK () {
@@ -1680,9 +1696,10 @@ function Build-Compilers() {
1680
1696
LLDB_TABLEGEN = (Join-Path - Path $BuildTools - ChildPath " lldb-tblgen.exe" );
1681
1697
LLDB_TEST_MAKE = " $BinaryCache \GnuWin32Make-4.4.1\bin\make.exe" ;
1682
1698
LLVM_CONFIG_PATH = (Join-Path - Path $BuildTools - ChildPath " llvm-config.exe" );
1699
+ LLVM_ENABLE_ASSERTIONS = $ (if ($Variant -eq " Asserts" ) { " YES" } else { " NO" })
1683
1700
LLVM_EXTERNAL_SWIFT_SOURCE_DIR = " $SourceCache \swift" ;
1684
- LLVM_NATIVE_TOOL_DIR = $BuildTools ;
1685
1701
LLVM_HOST_TRIPLE = $BuildArch.LLVMTarget ;
1702
+ LLVM_NATIVE_TOOL_DIR = $BuildTools ;
1686
1703
LLVM_TABLEGEN = (Join-Path $BuildTools - ChildPath " llvm-tblgen.exe" );
1687
1704
LLVM_USE_HOST_TOOLS = " NO" ;
1688
1705
Python3_EXECUTABLE = (Get-PythonExecutable );
@@ -1700,9 +1717,11 @@ function Build-Compilers() {
1700
1717
SWIFT_ENABLE_SYNCHRONIZATION = " YES" ;
1701
1718
SWIFT_ENABLE_VOLATILE = " YES" ;
1702
1719
SWIFT_PATH_TO_LIBDISPATCH_SOURCE = " $SourceCache \swift-corelibs-libdispatch" ;
1703
- SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE = " $SourceCache \swift-syntax" ;
1704
1720
SWIFT_PATH_TO_STRING_PROCESSING_SOURCE = " $SourceCache \swift-experimental-string-processing" ;
1705
1721
SWIFT_PATH_TO_SWIFT_SDK = (Get-PinnedToolchainSDK );
1722
+ SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE = " $SourceCache \swift-syntax" ;
1723
+ SWIFT_STDLIB_ASSERTIONS = " NO" ;
1724
+ SWIFTSYNTAX_ENABLE_ASSERTIONS = " NO" ;
1706
1725
" cmark-gfm_DIR" = " $ ( $Arch.ToolchainInstallRoot ) \usr\lib\cmake" ;
1707
1726
})
1708
1727
}
@@ -3112,7 +3131,7 @@ Fetch-Dependencies
3112
3131
if ($Clean ) {
3113
3132
10 ..[HostComponent ].getEnumValues()[-1 ] | ForEach-Object { Remove-Item - Force - Recurse " $BinaryCache \$_ " - ErrorAction Ignore }
3114
3133
# In case of a previous test run, clear out the swiftmodules as they are not a stable format.
3115
- Remove-Item - Force - Recurse - Path " $ ( $HostARch .ToolchainInstallRoot ) \usr\lib\swift\windows\*.swiftmodule" - ErrorAction Ignore
3134
+ Remove-Item - Force - Recurse - Path " $ ( $HostArch .ToolchainInstallRoot ) \usr\lib\swift\windows\*.swiftmodule" - ErrorAction Ignore
3116
3135
foreach ($Arch in $WindowsSDKArchs ) {
3117
3136
0 ..[TargetComponent ].getEnumValues()[-1 ] | ForEach-Object { Remove-Item - Force - Recurse " $BinaryCache \$ ( $Arch.BuildID + $_ ) " - ErrorAction Ignore }
3118
3137
}
0 commit comments