@@ -54,6 +54,10 @@ The toolchain snapshot to build the early components with.
5454. PARAMETER PinnedSHA256
5555The SHA256 for the pinned toolchain.
5656
57+ . PARAMETER PinnedToolchainVariant
58+ The toolchain variant to use while building the toolchain. Defaults to
59+ `Asserts`.
60+
5761. PARAMETER AndroidNDKVersion
5862The version number of the Android NDK to be used.
5963
@@ -102,6 +106,9 @@ in batch file format instead of executing them.
102106. PARAMETER HostArchName
103107The architecture where the toolchain will execute.
104108
109+ . PARAMETER Variant
110+ The toolchain variant to build. Defaults to `Asserts`.
111+
105112. EXAMPLE
106113PS> .\Build.ps1
107114
@@ -128,6 +135,8 @@ param
128135 [ValidatePattern (" ^[A-Fa-f0-9]{64}$" )]
129136 [string ] $PinnedSHA256 = " " ,
130137 [string ] $PinnedVersion = " " ,
138+ [ValidateSet (" Asserts" , " NoAsserts" )]
139+ [string ] $PinnedToolchainVariant = " Asserts" ,
131140 [string ] $PythonVersion = " 3.9.10" ,
132141 [ValidatePattern (" ^r(?:[1-9]|[1-9][0-9])(?:[a-z])?$" )]
133142 [string ] $AndroidNDKVersion = " r26b" ,
@@ -150,6 +159,8 @@ param
150159 [string ] $BuildTo = " " ,
151160 [ValidateSet (" AMD64" , " ARM64" )]
152161 [string ] $HostArchName = $ (if ($env: PROCESSOR_ARCHITEW6432 -ne $null ) { " $env: PROCESSOR_ARCHITEW6432 " } else { " $env: PROCESSOR_ARCHITECTURE " }),
162+ [ValidateSet (" Asserts" , " NoAsserts" )]
163+ [string ] $Variant = " Asserts" ,
153164 [switch ] $Clean ,
154165 [switch ] $DebugInfo ,
155166 [switch ] $EnableCaching ,
@@ -236,7 +247,7 @@ $ArchX64 = @{
236247 ExperimentalSDKInstallRoot = " $BinaryCache \x64\Windows.platform\Developer\SDKs\WindowsExperimental.sdk" ;
237248 XCTestInstallRoot = " $BinaryCache \x64\Windows.platform\Developer\Library\XCTest-development" ;
238249 SwiftTestingInstallRoot = " $BinaryCache \x64\Windows.platform\Developer\Library\Testing-development" ;
239- ToolchainInstallRoot = " $BinaryCache \x64\toolchains\$ProductVersion +Asserts " ;
250+ ToolchainInstallRoot = " $BinaryCache \x64\toolchains\$ProductVersion +$Variant " ;
240251 Cache = @ {};
241252}
242253
@@ -266,7 +277,7 @@ $ArchARM64 = @{
266277 SDKInstallRoot = " $BinaryCache \arm64\Windows.platform\Developer\SDKs\Windows.sdk" ;
267278 ExperimentalSDKInstallRoot = " $BinaryCache \arm64\Windows.platform\Developer\SDKs\WindowsExperimental.sdk" ;
268279 XCTestInstallRoot = " $BinaryCache \arm64\Windows.platform\Developer\Library\XCTest-development" ;
269- ToolchainInstallRoot = " $BinaryCache \arm64\toolchains\$ProductVersion +Asserts " ;
280+ ToolchainInstallRoot = " $BinaryCache \arm64\toolchains\$ProductVersion +$Variant " ;
270281 SwiftTestingInstallRoot = " $BinaryCache \arm64\Windows.platform\Developer\Library\Testing-development" ;
271282 Cache = @ {};
272283}
@@ -391,7 +402,7 @@ $LibraryRoot = "$ImageRoot\Library"
391402
392403# For dev productivity, install the host toolchain directly using CMake.
393404# 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 "
395406
396407# Resolve the architectures received as argument
397408$AndroidSDKArchs = @ ($AndroidSDKs | ForEach-Object {
@@ -917,20 +928,26 @@ function Fetch-Dependencies {
917928}
918929
919930function 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
922935 # as a pinned toolchain.
923936 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"
927940 }
928941 }
929942 }
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
932948 }
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"
934951}
935952
936953function Get-PinnedToolchainSDK () {
@@ -1666,9 +1683,10 @@ function Build-Compilers() {
16661683 LLDB_TABLEGEN = (Join-Path - Path $BuildTools - ChildPath " lldb-tblgen.exe" );
16671684 LLDB_TEST_MAKE = " $BinaryCache \GnuWin32Make-4.4.1\bin\make.exe" ;
16681685 LLVM_CONFIG_PATH = (Join-Path - Path $BuildTools - ChildPath " llvm-config.exe" );
1686+ LLVM_ENABLE_ASSERTIONS = $ (if ($Variant -eq " Asserts" ) { " YES" } else { " NO" })
16691687 LLVM_EXTERNAL_SWIFT_SOURCE_DIR = " $SourceCache \swift" ;
1670- LLVM_NATIVE_TOOL_DIR = $BuildTools ;
16711688 LLVM_HOST_TRIPLE = $BuildArch.LLVMTarget ;
1689+ LLVM_NATIVE_TOOL_DIR = $BuildTools ;
16721690 LLVM_TABLEGEN = (Join-Path $BuildTools - ChildPath " llvm-tblgen.exe" );
16731691 LLVM_USE_HOST_TOOLS = " NO" ;
16741692 Python3_EXECUTABLE = (Get-PythonExecutable );
@@ -1686,9 +1704,11 @@ function Build-Compilers() {
16861704 SWIFT_ENABLE_SYNCHRONIZATION = " YES" ;
16871705 SWIFT_ENABLE_VOLATILE = " YES" ;
16881706 SWIFT_PATH_TO_LIBDISPATCH_SOURCE = " $SourceCache \swift-corelibs-libdispatch" ;
1689- SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE = " $SourceCache \swift-syntax" ;
16901707 SWIFT_PATH_TO_STRING_PROCESSING_SOURCE = " $SourceCache \swift-experimental-string-processing" ;
16911708 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" ;
16921712 " cmark-gfm_DIR" = " $ ( $Arch.ToolchainInstallRoot ) \usr\lib\cmake" ;
16931713 })
16941714 }
@@ -3099,8 +3119,7 @@ if ($Clean) {
30993119 }
31003120
31013121 # 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
31043123 foreach ($Arch in $WindowsSDKArchs ) {
31053124 foreach ($project in [TargetComponent ]::GetNames([TargetComponent ])) {
31063125 Remove-Item - Force - Recurse - Path " $BinaryCache \$ ( $Arch.LLVMTarget ) \$project " - ErrorAction Ignore
0 commit comments