@@ -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 ,
@@ -236,7 +247,7 @@ $ArchX64 = @{
236
247
ExperimentalSDKInstallRoot = " $BinaryCache \x64\Windows.platform\Developer\SDKs\WindowsExperimental.sdk" ;
237
248
XCTestInstallRoot = " $BinaryCache \x64\Windows.platform\Developer\Library\XCTest-development" ;
238
249
SwiftTestingInstallRoot = " $BinaryCache \x64\Windows.platform\Developer\Library\Testing-development" ;
239
- ToolchainInstallRoot = " $BinaryCache \x64\toolchains\$ProductVersion +Asserts " ;
250
+ ToolchainInstallRoot = " $BinaryCache \x64\toolchains\$ProductVersion +$Variant " ;
240
251
Cache = @ {};
241
252
}
242
253
@@ -266,7 +277,7 @@ $ArchARM64 = @{
266
277
SDKInstallRoot = " $BinaryCache \arm64\Windows.platform\Developer\SDKs\Windows.sdk" ;
267
278
ExperimentalSDKInstallRoot = " $BinaryCache \arm64\Windows.platform\Developer\SDKs\WindowsExperimental.sdk" ;
268
279
XCTestInstallRoot = " $BinaryCache \arm64\Windows.platform\Developer\Library\XCTest-development" ;
269
- ToolchainInstallRoot = " $BinaryCache \arm64\toolchains\$ProductVersion +Asserts " ;
280
+ ToolchainInstallRoot = " $BinaryCache \arm64\toolchains\$ProductVersion +$Variant " ;
270
281
SwiftTestingInstallRoot = " $BinaryCache \arm64\Windows.platform\Developer\Library\Testing-development" ;
271
282
Cache = @ {};
272
283
}
@@ -391,7 +402,7 @@ $LibraryRoot = "$ImageRoot\Library"
391
402
392
403
# For dev productivity, install the host toolchain directly using CMake.
393
404
# This allows iterating on the toolchain using ninja builds.
394
- $HostArch.ToolchainInstallRoot = " $ ( Get-InstallDir $HostArch ) \Toolchains\$ProductVersion +Asserts "
405
+ $HostArch.ToolchainInstallRoot = " $ ( Get-InstallDir $HostArch ) \Toolchains\$ProductVersion +$Variant "
395
406
396
407
# Resolve the architectures received as argument
397
408
$AndroidSDKArchs = @ ($AndroidSDKs | ForEach-Object {
@@ -917,20 +928,26 @@ function Fetch-Dependencies {
917
928
}
918
929
919
930
function Get-PinnedToolchainToolsDir () {
920
- # NOTE: add a workaround for the main snapshots that used the wrong version
921
- # when building that was not noticed. This allows use of the nightly snapshot
931
+ $ToolchainsRoot = [IO.Path ]::Combine(" $BinaryCache \toolchains" , " $PinnedToolchain " , " LocalApp" , " Programs" , " Swift" , " Toolchains" )
932
+
933
+ # NOTE: Add a workaround for the main snapshots that inadvertently used the
934
+ # wrong version when they were built. This allows use of the nightly snapshot
922
935
# as a pinned toolchain.
923
936
if ((Get-PinnedToolchainVersion ) -eq " 0.0.0" ) {
924
- if (-not (Test-Path " $BinaryCache \toolchains\ ${PinnedToolchain} \LocalApp\Programs\Swift\Toolchains \0.0.0+Asserts\usr\bin" )) {
925
- if (Test-Path " $BinaryCache \toolchains\ ${PinnedToolchain} \LocalApp\Programs\Swift\Toolchains \6.0.0+Asserts\usr\bin" ) {
926
- return " $BinaryCache \toolchains\ ${PinnedToolchain} \LocalApp\Programs\Swift\Toolchains \6.0.0+Asserts\usr\bin"
937
+ if (-not (Test-Path " $ToolchainsRoot \0.0.0+Asserts\usr\bin" )) {
938
+ if (Test-Path " $ToolchainsRoot \6.0.0+Asserts\usr\bin" ) {
939
+ return " $ToolchainsRoot \6.0.0+Asserts\usr\bin"
927
940
}
928
941
}
929
942
}
930
- if (Test-Path " $BinaryCache \toolchains\${PinnedToolchain} \LocalApp\Programs\Swift\Toolchains\$ ( Get-PinnedToolchainVersion ) +Asserts\usr\bin" ) {
931
- return " $BinaryCache \toolchains\${PinnedToolchain} \LocalApp\Programs\Swift\Toolchains\$ ( Get-PinnedToolchainVersion ) +Asserts\usr\bin"
943
+
944
+ $VariantToolchainPath = [IO.Path ]::Combine($ToolchainsRoot , " $ ( Get-PinnedToolchainVersion ) +$PinnedToolchainVariant " , " usr" , " bin" )
945
+
946
+ if (Test-Path $VariantToolchainPath ) {
947
+ return $VariantToolchainPath
932
948
}
933
- return " $BinaryCache \toolchains\${PinnedToolchain} \Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin"
949
+
950
+ return " $BinaryCache \toolchains\${PinnedToolchain} \Library\Developer\Toolchains\unknown-$PinnedToolchainVariant -development.xctoolchain\usr\bin"
934
951
}
935
952
936
953
function Get-PinnedToolchainSDK () {
@@ -1666,9 +1683,10 @@ function Build-Compilers() {
1666
1683
LLDB_TABLEGEN = (Join-Path - Path $BuildTools - ChildPath " lldb-tblgen.exe" );
1667
1684
LLDB_TEST_MAKE = " $BinaryCache \GnuWin32Make-4.4.1\bin\make.exe" ;
1668
1685
LLVM_CONFIG_PATH = (Join-Path - Path $BuildTools - ChildPath " llvm-config.exe" );
1686
+ LLVM_ENABLE_ASSERTIONS = $ (if ($Variant -eq " Asserts" ) { " YES" } else { " NO" })
1669
1687
LLVM_EXTERNAL_SWIFT_SOURCE_DIR = " $SourceCache \swift" ;
1670
- LLVM_NATIVE_TOOL_DIR = $BuildTools ;
1671
1688
LLVM_HOST_TRIPLE = $BuildArch.LLVMTarget ;
1689
+ LLVM_NATIVE_TOOL_DIR = $BuildTools ;
1672
1690
LLVM_TABLEGEN = (Join-Path $BuildTools - ChildPath " llvm-tblgen.exe" );
1673
1691
LLVM_USE_HOST_TOOLS = " NO" ;
1674
1692
Python3_EXECUTABLE = (Get-PythonExecutable );
@@ -1686,9 +1704,11 @@ function Build-Compilers() {
1686
1704
SWIFT_ENABLE_SYNCHRONIZATION = " YES" ;
1687
1705
SWIFT_ENABLE_VOLATILE = " YES" ;
1688
1706
SWIFT_PATH_TO_LIBDISPATCH_SOURCE = " $SourceCache \swift-corelibs-libdispatch" ;
1689
- SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE = " $SourceCache \swift-syntax" ;
1690
1707
SWIFT_PATH_TO_STRING_PROCESSING_SOURCE = " $SourceCache \swift-experimental-string-processing" ;
1691
1708
SWIFT_PATH_TO_SWIFT_SDK = (Get-PinnedToolchainSDK );
1709
+ SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE = " $SourceCache \swift-syntax" ;
1710
+ SWIFT_STDLIB_ASSERTIONS = " NO" ;
1711
+ SWIFTSYNTAX_ENABLE_ASSERTIONS = " NO" ;
1692
1712
" cmark-gfm_DIR" = " $ ( $Arch.ToolchainInstallRoot ) \usr\lib\cmake" ;
1693
1713
})
1694
1714
}
@@ -3099,8 +3119,7 @@ if ($Clean) {
3099
3119
}
3100
3120
3101
3121
# In case of a previous test run, clear out the swiftmodules as they are not a stable format.
3102
- Remove-Item - Force - Recurse - Path " $ ( $HostARch.ToolchainInstallRoot ) \usr\lib\swift\windows\*.swiftmodule" - ErrorAction Ignore
3103
-
3122
+ Remove-Item - Force - Recurse - Path " $ ( $HostArch.ToolchainInstallRoot ) \usr\lib\swift\windows\*.swiftmodule" - ErrorAction Ignore
3104
3123
foreach ($Arch in $WindowsSDKArchs ) {
3105
3124
foreach ($project in [TargetComponent ]::GetNames([TargetComponent ])) {
3106
3125
Remove-Item - Force - Recurse - Path " $BinaryCache \$ ( $Arch.LLVMTarget ) \$project " - ErrorAction Ignore
0 commit comments