From e79e78da478d21cbbdde24b1a83b2719fca756e4 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Thu, 10 Jul 2025 10:30:12 -0700 Subject: [PATCH 1/7] utils: update toolchain snapshot to permit use of the experimental SDK Use the experimental SDK to build the toolchain and consume the redistributable. This is going to ensure that we build the entire toolchain against a stable point and run against the runtime that we build against. --- utils/build.ps1 | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/utils/build.ps1 b/utils/build.ps1 index de67a1c80bd3..8930f7d6e1a0 100644 --- a/utils/build.ps1 +++ b/utils/build.ps1 @@ -273,14 +273,14 @@ if ($UseHostToolchain -is [string]) { $DefaultPinned = @{ AMD64 = @{ - PinnedBuild = "https://download.swift.org/swift-6.1.2-release/windows10/swift-6.1.2-RELEASE/swift-6.1.2-RELEASE-windows10.exe"; - PinnedSHA256 = "92A0323ED7DD333C3B05E6E0E428F3A91C77D159F6CCFC8626A996F2ACE09A0B"; - PinnedVersion = "6.1.2"; + PinnedBuild = "https://download.swift.org/development/windows10/swift-DEVELOPMENT-SNAPSHOT-2025-11-03-a/swift-DEVELOPMENT-SNAPSHOT-2025-11-03-a-windows10.exe"; + PinnedSHA256 = ""; + PinnedVersion = "0.0.0"; }; ARM64 = @{ - PinnedBuild = "https://download.swift.org/swift-6.1.2-release/windows10-arm64/swift-6.1.2-RELEASE/swift-6.1.2-RELEASE-windows10-arm64.exe"; - PinnedSHA256 = "121FB407E578178F82DCCF39A4D03527873D8F7611A801A8FC26DA52503A0C5C"; - PinnedVersion = "6.1.2"; + PinnedBuild = "https://download.swift.org/development/windows10-arm64/swift-DEVELOPMENT-SNAPSHOT-2025-11-03-a/swift-DEVELOPMENT-SNAPSHOT-2025-11-03-a-windows10-arm64.exe" + PinnedSHA256 = ""; + PinnedVersion = "0.0.0"; }; } @@ -2236,6 +2236,7 @@ function Get-CompilersDefines([Hashtable] $Platform, [string] $Variant, [switch] return $TestDefines + $DebugDefines + @{ CLANG_TABLEGEN = (Join-Path -Path $BuildTools -ChildPath "clang-tblgen.exe"); CLANG_TIDY_CONFUSABLE_CHARS_GEN = (Join-Path -Path $BuildTools -ChildPath "clang-tidy-confusable-chars-gen.exe"); + CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib"; CMAKE_Swift_FLAGS = $SwiftFlags; LibXml2_DIR = "$BinaryCache\$($Platform.Triple)\usr\lib\cmake\libxml2-2.11.5"; LLDB_LIBXML2_VERSION = "2.11.5"; From e3adf316fa03d9540092d95a548cc60d01452491 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Thu, 7 Aug 2025 17:36:08 -0700 Subject: [PATCH 2/7] build.ps1: use pinned toolchain rather than built toolchain Adjust the toolchain build to use the pinned toolchain rather than the built toolchain. This is particularly important with the lack of ABI stability on Windows. We now uniformly build the toolchain with the same runtime. This extricates the SDK from the toolchain build. Now that we build the toolchain properly against a SxS installable version of the runtime, we can consume the runtime that we built against and inject that into the toolchain image. This avoids the need to rely on trying to maintain ABI compatibility in an ABI unstable environment. --- utils/build.ps1 | 188 +++++++++++++++++++++++++++++++----------------- 1 file changed, 121 insertions(+), 67 deletions(-) diff --git a/utils/build.ps1 b/utils/build.ps1 index 8930f7d6e1a0..186dac25a5fe 100644 --- a/utils/build.ps1 +++ b/utils/build.ps1 @@ -1444,7 +1444,7 @@ function Get-PinnedToolchainToolsDir() { "unknown-Asserts-development.xctoolchain", "usr", "bin") } -function Get-PinnedToolchainSDK([OS] $OS = $BuildPlatform.OS, [string] $Identifier = $OS.ToString()) { +function Get-PinnedToolchainSDK([OS] $OS = $BuildPlatform.OS, [string] $Identifier = "$($OS.ToString())Experimental") { $ToolchainName = $PinnedToolchain.TrimStart("swift-").TrimEnd("-a-windows10") return [IO.Path]::Combine("$BinaryCache\", "toolchains", $ToolchainName, @@ -1460,6 +1460,14 @@ function Get-PinnedToolchainRuntime() { "usr", "bin") } +function Get-PinnedToolchainRedistributables() { + $ToolchainName = $PinnedToolchain.TrimStart("swift-").TrimEnd("-a-windows10") + + return [IO.Path]::Combine("$BinaryCache\", "toolchains", $ToolchainName, + "LocalApp", "Programs", "Swift", "Redistributables", (Get-PinnedToolchainVersion) + ) +} + function Get-PinnedToolchainVersion() { if (Test-Path variable:PinnedVersion) { return $PinnedVersion @@ -1701,7 +1709,7 @@ function Build-CMakeProject { } $SWIFTC = if ($UseBuiltCompilers.Contains("Swift")) { - [IO.Path]::Combine((Get-ProjectBinaryCache $BuildPlatform Compilers), "bin", "swiftc.exe") + [IO.Path]::Combine($BuildPlatform.ToolchainInstallRoot, "usr", "bin", "swiftc.exe") } elseif ($UsePinnedCompilers.Contains("Swift")) { Join-Path -Path (Get-PinnedToolchainToolsDir) -ChildPath "swiftc.exe" } @@ -1821,7 +1829,7 @@ function Build-CMakeProject { Add-KeyValueIfNew $Defines SWIFT_ANDROID_NDK_PATH "$AndroidNDKPath" $SWIFTC = if ($UseBuiltCompilers.Contains("Swift")) { - [IO.Path]::Combine((Get-ProjectBinaryCache $BuildPlatform Compilers), "bin", "swiftc.exe") + [IO.Path]::Combine($BuildPlatform.ToolchainInstallRoot, "usr", "bin", "swiftc.exe") } else { Join-Path -Path (Get-PinnedToolchainToolsDir) -ChildPath "swiftc.exe" } @@ -1932,9 +1940,9 @@ function Build-CMakeProject { } if ($UseBuiltCompilers.Contains("Swift")) { - $env:Path = "$([IO.Path]::Combine((Get-InstallDir $BuildPlatform), "Runtimes", $ProductVersion, "usr", "bin"));$(Get-CMarkBinaryCache $BuildPlatform)\src;$($BuildPlatform.ToolchainInstallRoot)\usr\bin;$(Get-PinnedToolchainRuntime);${env:Path}" + $env:Path = "$($BuildPlatform.ToolchainInstallRoot)\usr\bin;$(Get-PinnedToolchainRuntime);${env:Path}" } elseif ($UsePinnedCompilers.Contains("Swift")) { - $env:Path = "$(Get-PinnedToolchainRuntime);${env:Path}" + $env:Path = "$(Get-PinnedToolchainToolsDir);$(Get-PinnedToolchainRuntime);${env:Path}" } if ($ToBatch) { Write-Output "" @@ -2004,8 +2012,8 @@ function Build-SPMProject { Invoke-IsolatingEnvVars { $RuntimeInstallRoot = [IO.Path]::Combine((Get-InstallDir $BuildPlatform), "Runtimes", $ProductVersion) - $env:Path = "$RuntimeInstallRoot\usr\bin;$($BuildPlatform.ToolchainInstallRoot)\usr\bin;${env:Path}" - $env:SDKROOT = (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) + $env:Path = "$(Get-PinnedToolchainRuntime);$(Get-PinnedToolchainToolsDir);${env:Path}" + $env:SDKROOT = (Get-PinnedToolchainSDK -OS $Platform.OS) $env:SWIFTCI_USE_LOCAL_DEPS = "1" $Arguments = @( @@ -2013,6 +2021,7 @@ function Build-SPMProject { "--package-path", $Src, "-c", $Configuration ) + if ($DebugInfo) { if ($Platform.OS -eq [OS]::Windows -and $SwiftDebugFormat -eq "codeview") { $Arguments += @("-debug-info-format", "codeview") @@ -2227,12 +2236,6 @@ function Get-CompilersDefines([Hashtable] $Platform, [string] $Variant, [switch] $SwiftFlags += @("-use-ld=lld"); } - $CMakeStaticLibPrefixSwiftDefine = if ((Get-PinnedToolchainVersion) -eq "0.0.0") { - @{ CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib"; } - } else { - @{} - } - return $TestDefines + $DebugDefines + @{ CLANG_TABLEGEN = (Join-Path -Path $BuildTools -ChildPath "clang-tblgen.exe"); CLANG_TIDY_CONFUSABLE_CHARS_GEN = (Join-Path -Path $BuildTools -ChildPath "clang-tidy-confusable-chars-gen.exe"); @@ -2285,7 +2288,7 @@ function Get-CompilersDefines([Hashtable] $Platform, [string] $Variant, [switch] SWIFT_STDLIB_ASSERTIONS = "NO"; SWIFTSYNTAX_ENABLE_ASSERTIONS = "NO"; "cmark-gfm_DIR" = "$($Platform.ToolchainInstallRoot)\usr\lib\cmake"; - } + $CMakeStaticLibPrefixSwiftDefine + } } function Build-Compilers([Hashtable] $Platform, [string] $Variant) { @@ -2350,7 +2353,7 @@ function Test-Compilers([Hashtable] $Platform, [string] $Variant, [switch] $Test # gtest sharding breaks llvm-lit's --xfail and LIT_XFAIL inputs: https://github.com/llvm/llvm-project/issues/102264 LLVM_LIT_ARGS = "-v --no-gtest-sharding --time-tests"; # LLDB Unit tests link against this library - LLVM_UNITTEST_LINK_FLAGS = "$(Get-SwiftSDK -OS Windows -Identifier Windows)\usr\lib\swift\windows\$($Platform.Architecture.LLVMName)\swiftCore.lib"; + LLVM_UNITTEST_LINK_FLAGS = "$(Get-PinnedToolchainSDK -OS Windows)\usr\lib\swift\windows\$($Platform.Architecture.LLVMName)\swiftCore.lib"; } } @@ -2526,7 +2529,8 @@ function Build-Brotli([Hashtable] $Platform) { -Src $SourceCache\brotli ` -Bin "$(Get-ProjectBinaryCache $Platform brotli)" ` -Platform $Platform ` - -UseMSVCCompilers C ` + -UseMSVCCompilers $(if ($UseHostToolchain) { @("C") } else { @("") }) ` + -UsePinnedCompilers $(if ($UseHostToolchain) { @("") } else { @("C") }) ` -BuildTargets default ` -Defines @{ BUILD_SHARED_LIBS = "NO"; @@ -2800,8 +2804,7 @@ function Build-ExperimentalRuntime([Hashtable] $Platform, [switch] $Static = $fa } Invoke-IsolatingEnvVars { - $env:Path = "$(Get-CMarkBinaryCache $Platform)\src;$(Get-PinnedToolchainRuntime);${env:Path}" - + # $env:Path = "$(Get-CMarkBinaryCache $Platform)\src;$(Get-PinnedToolchainRuntime);${env:Path}" $SDKRoot = Get-SwiftSDK -OS $Platform.OS -Identifier "$($Platform.OS)Experimental" $RuntimeBinaryCache = if ($Static) { @@ -3170,8 +3173,8 @@ function Build-FoundationMacros([Hashtable] $Platform) { -Bin (Get-ProjectBinaryCache $Platform FoundationMacros) ` -InstallTo "$($Platform.ToolchainInstallRoot)\usr" ` -Platform $Platform ` - -UseBuiltCompilers Swift ` - -SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) ` + -UsePinnedCompilers Swift ` + -SwiftSDK (Get-PinnedToolchainSDK -OS $Platform.OS) ` -Defines @{ SwiftSyntax_DIR = $SwiftSyntaxDir; } @@ -3455,8 +3458,8 @@ function Build-System([Hashtable] $Platform) { -Src $SourceCache\swift-system ` -Bin (Get-ProjectBinaryCache $Platform System) ` -Platform $Platform ` - -UseBuiltCompilers C,Swift ` - -SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) ` + -UsePinnedCompilers C,Swift ` + -SwiftSDK (Get-PinnedToolchainSDK -OS $Platform.OS) ` -BuildTargets default ` -Defines @{ BUILD_SHARED_LIBS = "NO"; @@ -3469,8 +3472,8 @@ function Build-Subprocess([Hashtable] $Platform) { -Src $sourceCache\swift-subprocess ` -Bin (Get-ProjectBinaryCache $Platform Subprocess) ` -Platform $Platform ` - -UseBuiltCompilers C,Swift ` - -SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) ` + -UsePinnedCompilers C,Swift ` + -SwiftSDK (Get-PinnedToolchainSDK -OS $Platform.OS) ` -Defines @{ BUILD_SHARED_LIBS = "NO"; CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib"; @@ -3487,8 +3490,8 @@ function Build-Build([Hashtable] $Platform) { -Bin (Get-ProjectBinaryCache $Platform Build) ` -InstallTo "$($Platform.ToolchainInstallRoot)\usr" ` -Platform $Platform ` - -UseBuiltCompilers C,CXX,Swift ` - -SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) ` + -UsePinnedCompilers C,CXX,Swift ` + -SwiftSDK (Get-PinnedToolchainSDK -OS $Platform.OS) ` -Defines (@{ BUILD_SHARED_LIBS = "YES"; CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib"; @@ -3508,14 +3511,11 @@ function Build-ToolsSupportCore([Hashtable] $Platform) { -Bin (Get-ProjectBinaryCache $Platform ToolsSupportCore) ` -InstallTo "$($Platform.ToolchainInstallRoot)\usr" ` -Platform $Platform ` - -UseBuiltCompilers C,Swift ` - -SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) ` + -UsePinnedCompilers C,Swift ` + -SwiftSDK (Get-PinnedToolchainSDK -OS $Platform.OS) ` -Defines @{ BUILD_SHARED_LIBS = "YES"; CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib"; - - Foundation_DIR = $(Get-ProjectCMakeModules $Platform DynamicFoundation); - XCTest_DIR = (Get-ProjectCMakeModules $Platform XCTest); } } @@ -3526,9 +3526,8 @@ function Build-LLBuild([Hashtable] $Platform) { -InstallTo "$($Platform.ToolchainInstallRoot)\usr" ` -Platform $Platform ` -UseMSVCCompilers $(if ($UseHostToolchain) { @("CXX") } else { @("") }) ` - -UsePinnedCompilers $(if ($UseHostToolchain) { @("") } else { @("CXX") }) ` - -UseBuiltCompilers Swift ` - -SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) ` + -UsePinnedCompilers $(if ($UseHostToolchain) { @("Swift") } else { @("CXX", "Swift") }) ` + -SwiftSDK (Get-PinnedToolchainSDK -OS $Platform.OS) ` -Defines @{ BUILD_SHARED_LIBS = "YES"; LLBUILD_SUPPORT_BINDINGS = "Swift"; @@ -3556,7 +3555,7 @@ function Test-LLBuild { -UseMSVCCompilers $(if ($UseHostToolchain) { @("CXX") } else { @("") }) ` -UsePinnedCompilers $(if ($UseHostToolchain) { @("") } else { @("CXX") }) ` -UseBuiltCompilers Swift ` - -SwiftSDK (Get-SwiftSDK -OS $BuildPlatform.OS -Identifier $BuildPlatform.DefaultSDK) ` + -SwiftSDK (Get-PinnedToolchainSDK -OS $BuildPlatform.OS) ` -BuildTargets default,test-llbuild ` -Defines = @{ BUILD_SHARED_LIBS = "YES"; @@ -3575,8 +3574,8 @@ function Build-ArgumentParser([Hashtable] $Platform) { -Bin (Get-ProjectBinaryCache $Platform ArgumentParser) ` -InstallTo "$($Platform.ToolchainInstallRoot)\usr" ` -Platform $Platform ` - -UseBuiltCompilers Swift ` - -SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) ` + -UsePinnedCompilers Swift ` + -SwiftSDK (Get-PinnedToolchainSDK -OS $Platform.OS) ` -Defines @{ BUILD_SHARED_LIBS = "YES"; BUILD_TESTING = "NO"; @@ -3590,8 +3589,8 @@ function Build-Driver([Hashtable] $Platform) { -Bin (Get-ProjectBinaryCache $Platform Driver) ` -InstallTo "$($Platform.ToolchainInstallRoot)\usr" ` -Platform $Platform ` - -UseBuiltCompilers C,CXX,Swift ` - -SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) ` + -UsePinnedCompilers C,CXX,Swift ` + -SwiftSDK (Get-PinnedToolchainSDK -OS $Platform.OS) ` -Defines @{ BUILD_SHARED_LIBS = "YES"; CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib"; @@ -3612,8 +3611,8 @@ function Build-Crypto([Hashtable] $Platform) { -Src $SourceCache\swift-crypto ` -Bin (Get-ProjectBinaryCache $Platform Crypto) ` -Platform $Platform ` - -UseBuiltCompilers ASM, C, CXX, Swift ` - -SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) ` + -UsePinnedCompilers ASM,C,CXX,Swift ` + -SwiftSDK (Get-PinnedToolchainSDK -OS $Platform.OS) ` -BuildTargets default ` -Defines @{ BUILD_SHARED_LIBS = "NO"; @@ -3628,8 +3627,8 @@ function Build-Collections([Hashtable] $Platform) { -Bin (Get-ProjectBinaryCache $Platform Collections) ` -InstallTo "$($Platform.ToolchainInstallRoot)\usr" ` -Platform $Platform ` - -UseBuiltCompilers C,Swift ` - -SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) ` + -UsePinnedCompilers C,Swift ` + -SwiftSDK (Get-PinnedToolchainSDK -OS $Platform.OS) ` -Defines @{ BUILD_SHARED_LIBS = "YES"; CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib"; @@ -3641,8 +3640,8 @@ function Build-ASN1([Hashtable] $Platform) { -Src $SourceCache\swift-asn1 ` -Bin (Get-ProjectBinaryCache $Platform ASN1) ` -Platform $Platform ` - -UseBuiltCompilers Swift ` - -SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) ` + -UsePinnedCompilers Swift ` + -SwiftSDK (Get-PinnedToolchainSDK -OS $Platform.OS) ` -BuildTargets default ` -Defines @{ BUILD_SHARED_LIBS = "NO"; @@ -3655,8 +3654,8 @@ function Build-Certificates([Hashtable] $Platform) { -Src $SourceCache\swift-certificates ` -Bin (Get-ProjectBinaryCache $Platform Certificates) ` -Platform $Platform ` - -UseBuiltCompilers Swift ` - -SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) ` + -UsePinnedCompilers Swift ` + -SwiftSDK (Get-PinnedToolchainSDK -OS $Platform.OS) ` -BuildTargets default ` -Defines @{ BUILD_SHARED_LIBS = "NO"; @@ -3678,8 +3677,8 @@ function Build-PackageManager([Hashtable] $Platform) { -Bin (Get-ProjectBinaryCache $Platform PackageManager) ` -InstallTo "$($Platform.ToolchainInstallRoot)\usr" ` -Platform $Platform ` - -UseBuiltCompilers C,Swift ` - -SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) ` + -UsePinnedCompilers C,Swift ` + -SwiftSDK (Get-PinnedToolchainSDK -OS $Platform.OS) ` -Defines @{ BUILD_SHARED_LIBS = "YES"; CMAKE_Swift_FLAGS = @("-DCRYPTO_v2"); @@ -3727,8 +3726,8 @@ function Build-Markdown([Hashtable] $Platform) { -Bin (Get-ProjectBinaryCache $Platform Markdown) ` -InstallTo "$($Platform.ToolchainInstallRoot)\usr" ` -Platform $Platform ` - -UseBuiltCompilers C,Swift ` - -SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) ` + -UsePinnedCompilers C,Swift ` + -SwiftSDK (Get-PinnedToolchainSDK -OS $Platform.OS) ` -Defines @{ BUILD_SHARED_LIBS = "NO"; CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib"; @@ -3744,9 +3743,8 @@ function Build-Format([Hashtable] $Platform) { -InstallTo "$($Platform.ToolchainInstallRoot)\usr" ` -Platform $Platform ` -UseMSVCCompilers $(if ($UseHostToolchain) { @("C") } else { @("") }) ` - -UsePinnedCompilers $(if ($UseHostToolchain) { @("") } else { @("C") }) ` - -UseBuiltCompilers Swift ` - -SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) ` + -UsePinnedCompilers $(if ($UseHostToolchain) { @("Swift") } else { @("C", "Swift") }) ` + -SwiftSDK (Get-PinnedToolchainSDK -OS $Platform.OS) ` -Defines @{ BUILD_SHARED_LIBS = "YES"; ArgumentParser_DIR = (Get-ProjectCMakeModules $Platform ArgumentParser); @@ -3805,12 +3803,12 @@ function Build-LMDB([Hashtable] $Platform) { } function Build-IndexStoreDB([Hashtable] $Platform) { - $SDKROOT = Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK + $SDKROOT = Get-PinnedToolchainSDK -OS $Platform.OS Build-CMakeProject ` -Src $SourceCache\indexstore-db ` -Bin (Get-ProjectBinaryCache $Platform IndexStoreDB) ` -Platform $Platform ` - -UseBuiltCompilers C,CXX,Swift ` + -UsePinnedCompilers C,CXX,Swift ` -SwiftSDK $SDKROOT ` -BuildTargets default ` -Defines @{ @@ -3828,8 +3826,8 @@ function Build-SourceKitLSP([Hashtable] $Platform) { -Bin (Get-ProjectBinaryCache $Platform SourceKitLSP) ` -InstallTo "$($Platform.ToolchainInstallRoot)\usr" ` -Platform $Platform ` - -UseBuiltCompilers C,Swift ` - -SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) ` + -UsePinnedCompilers C,Swift ` + -SwiftSDK (Get-PinnedToolchainSDK -OS $Platform.OS) ` -Defines @{ CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib"; SwiftSyntax_DIR = (Get-ProjectCMakeModules $Platform Compilers); @@ -3940,13 +3938,61 @@ function Build-TestingMacros([Hashtable] $Platform) { -Bin (Get-ProjectBinaryCache $Platform TestingMacros) ` -InstallTo "$($Platform.ToolchainInstallRoot)\usr" ` -Platform $Platform ` - -UseBuiltCompilers Swift ` - -SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) ` + -UsePinnedCompilers Swift ` + -SwiftSDK (Get-PinnedToolchainSDK -OS $Platform.OS) ` -Defines @{ SwiftSyntax_DIR = (Get-ProjectCMakeModules $Platform Compilers); } } +function Extract-MSM([String] $MSM, [String] $Destination) { + Push-Location $Destination + + $Installer = New-Object -ComObject WindowsInstaller.Installer + $DB = $Installer.OpenDatabase($MSM, 0) # ReadOnly + + $View = $DB.OpenView("SELECT File, FileName FROM File") + $View.Execute() + + $FileMap = @{} + while ($Record = $View.Fetch()) { + $FileKey = $Record.StringData(1) + $FileName = $Record.StringData(2) + + # Handle long filename format (shortname|longname) + if ($FileName.Contains("|")) { + $FileName = $FileName.Split("|")[1] + } + + $FileMap[$FileKey] = $FileName + } + + $View.Close() + + $CAB = [System.IO.Path]::GetTempFileName() ` + | Rename-Item -NewName { $_ -replace "tmp$", "cab" } -PassThru + + Invoke-IsolatingEnvVars { + Invoke-VsDevShell $BuildPlatform + Remove-Item MergeModule.CABinet -ErrorAction SilentlyContinue -Force | Out-Null + Start-Process -FilePath "${env:WindowsSdkVerBinPath}\x86\MsiDb.exe" -ArgumentList @("-d", "`"$MSM`"", "-x", "MergeModule.CABinet") -Wait + Write-Host Move-Item MergeModule.CABinet $CAB -Force | Out-Null + Move-Item MergeModule.CABinet $CAB -Force | Out-Null + } + + # Extract CAB + foreach ($FileKey in $FileMap.Keys) { + $FileName = $FileMap[$FileKey] + $TargetPath = Join-Path $Destination $FileName + $TargetDirectory = Split-Path $TargetPath -Parent + Invoke-Program expand.exe "$CAB" "-F:$FileKey" $Destination.TrimEnd("\\") | Out-Null + Move-Item (Join-Path $Destination $FileKey) $TargetPath -Force | Out-Null + } + + Remove-Item $CAB -ErrorAction SilentlyContinue | Out-Null + Pop-Location +} + function Install-HostToolchain() { if ($ToBatch) { return } @@ -3985,14 +4031,18 @@ function Build-Inspect([Hashtable] $Platform) { $InstallPath = "$(Get-PlatformRoot $Platform.OS)\Developer\Library\$(Get-ModuleTriple $Platform)" } - $SDKROOT = Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK + $SDKROOT = if ($Platform.OS -eq [OS]::Android) { + Get-PinnedToolchainSDK -OS $Platform.OS -Identifier $Platform.OS + } else { + Get-PinnedToolchainSDK -OS $Platform.OS + } Build-CMakeProject ` -Src $SourceCache\swift\tools\swift-inspect ` -Bin (Get-ProjectBinaryCache $Platform SwiftInspect)` -InstallTo $InstallPath ` -Platform $Platform ` - -UseBuiltCompilers C,CXX,Swift ` + -UsePinnedCompilers C,CXX,Swift ` -SwiftSDK $SDKROOT ` -Defines @{ CMAKE_Swift_FLAGS = @( @@ -4011,8 +4061,8 @@ function Build-SymbolKit([hashtable] $Platform) { -Bin $(Get-ProjectBinaryCache $Platform SymbolKit) ` -BuildTargets default ` -Platform $Platform ` - -UseBuiltCompilers C,Swift ` - -SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) ` + -UsePinnedCompilers C,Swift ` + -SwiftSDK (Get-PinnedToolchainSDK -OS $Platform.OS) ` -Defines @{ CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib"; } @@ -4021,11 +4071,11 @@ function Build-SymbolKit([hashtable] $Platform) { function Build-DocC([hashtable] $Platform) { Build-CMakeProject ` -Src $SourceCache\swift-docc ` - -Bin (Get-ProjectBinaryCache $BuildPlatform DocC) ` + -Bin (Get-ProjectBinaryCache $Platform DocC) ` -InstallTo "$($Platform.ToolchainInstallRoot)\usr" ` -Platform $Platform ` - -UseBuiltCompilers C,Swift ` - -SwiftSDK (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) ` + -UsePinnedCompilers C,Swift ` + -SwiftSDK (Get-PinnedToolchainSDK -OS $Platform.OS) ` -Defines @{ BUILD_SHARED_LIBS = "YES"; CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib"; @@ -4064,6 +4114,7 @@ function Build-Installer([Hashtable] $Platform) { BundleFlavor = "offline"; ImageRoot = "$(Get-InstallDir $Platform)\"; IncludeLegacySDK = if ($HostPlatform.DefaultSDK -match "Experimental") { "False" } else { "True" }; + RedistributablesDirectory = (Get-PinnedToolchainRedistributables); INCLUDE_SWIFT_DOCC = $INCLUDE_SWIFT_DOCC; SWIFT_DOCC_BUILD = "$(Get-ProjectBinaryCache $HostPlatform DocC)\release"; SWIFT_DOCC_RENDER_ARTIFACT_ROOT = "${SourceCache}\swift-docc-render-artifact"; @@ -4182,6 +4233,9 @@ if (-not $SkipBuild) { Invoke-BuildStep Build-XML2 $HostPlatform Invoke-BuildStep Build-CDispatch $HostPlatform Invoke-BuildStep Build-Compilers $HostPlatform -Variant "Asserts" + + Extract-MSM "$(Get-PinnedToolchainRedistributables)\rtl.shared.$($HostPlatform.Architecture.VSName).msm" "$($HostPlatform.ToolchainInstallRoot)\usr\bin\" + $KnownPlatforms.Values | Where-Object { switch ($_.OS) { Windows { $Windows } From 1fb4efe8713dc7c4cfe464ec6f551a7b5f0c15af Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Wed, 8 Oct 2025 15:01:47 -0700 Subject: [PATCH 3/7] build.ps1: remove support the legacy SDK Drop the support for the legacy build system for the runtime. This reduces the complexity in the build script as well as helps reduce the overall build times. --- cmake/caches/Runtime-Android-aarch64.cmake | 24 -- cmake/caches/Runtime-Android-armv7.cmake | 24 -- cmake/caches/Runtime-Android-i686.cmake | 24 -- cmake/caches/Runtime-Android-x86_64.cmake | 24 -- cmake/caches/Runtime-Windows-aarch64.cmake | 20 -- cmake/caches/Runtime-Windows-i686.cmake | 20 -- cmake/caches/Runtime-Windows-x86_64.cmake | 19 - utils/build.ps1 | 397 ++++++--------------- 8 files changed, 106 insertions(+), 446 deletions(-) delete mode 100644 cmake/caches/Runtime-Android-aarch64.cmake delete mode 100644 cmake/caches/Runtime-Android-armv7.cmake delete mode 100644 cmake/caches/Runtime-Android-i686.cmake delete mode 100644 cmake/caches/Runtime-Android-x86_64.cmake delete mode 100644 cmake/caches/Runtime-Windows-aarch64.cmake delete mode 100644 cmake/caches/Runtime-Windows-i686.cmake delete mode 100644 cmake/caches/Runtime-Windows-x86_64.cmake diff --git a/cmake/caches/Runtime-Android-aarch64.cmake b/cmake/caches/Runtime-Android-aarch64.cmake deleted file mode 100644 index f622e900c935..000000000000 --- a/cmake/caches/Runtime-Android-aarch64.cmake +++ /dev/null @@ -1,24 +0,0 @@ - -set(SWIFT_HOST_VARIANT_SDK ANDROID CACHE STRING "") -set(SWIFT_HOST_VARIANT_ARCH aarch64 CACHE STRING "") - -# NOTE(compnerd) disable the tools, we are trying to build just the standard -# library. -set(SWIFT_INCLUDE_TOOLS NO CACHE BOOL "") - -# NOTE(compnerd) cannot build tests since the tests require the toolchain -set(SWIFT_INCLUDE_TESTS NO CACHE BOOL "") - -# NOTE(compnerd) cannot build docs since that requires perl -set(SWIFT_INCLUDE_DOCS NO CACHE BOOL "") - -# NOTE(compnerd) these are part of the toolchain, not the runtime. -set(SWIFT_BUILD_SOURCEKIT NO CACHE BOOL "") - -# NOTE(compnerd) build with the compiler specified, not a just built compiler. -set(SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER YES CACHE BOOL "") - -set(SWIFT_SDK_ANDROID_ARCHITECTURES aarch64 CACHE STRING "") - -# NOTE(compnerd) this is lollipop, which seems to still have decent usage. -set(SWIFT_ANDROID_API_LEVEL 21 CACHE STRING "") diff --git a/cmake/caches/Runtime-Android-armv7.cmake b/cmake/caches/Runtime-Android-armv7.cmake deleted file mode 100644 index a9c3b23e7519..000000000000 --- a/cmake/caches/Runtime-Android-armv7.cmake +++ /dev/null @@ -1,24 +0,0 @@ - -set(SWIFT_HOST_VARIANT_SDK ANDROID CACHE STRING "") -set(SWIFT_HOST_VARIANT_ARCH armv7 CACHE STRING "") - -# NOTE(compnerd) disable the tools, we are trying to build just the standard -# library. -set(SWIFT_INCLUDE_TOOLS NO CACHE BOOL "") - -# NOTE(compnerd) cannot build tests since the tests require the toolchain -set(SWIFT_INCLUDE_TESTS NO CACHE BOOL "") - -# NOTE(compnerd) cannot build docs since that requires perl -set(SWIFT_INCLUDE_DOCS NO CACHE BOOL "") - -# NOTE(compnerd) these are part of the toolchain, not the runtime. -set(SWIFT_BUILD_SOURCEKIT NO CACHE BOOL "") - -# NOTE(compnerd) build with the compiler specified, not a just built compiler. -set(SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER YES CACHE BOOL "") - -set(SWIFT_SDK_ANDROID_ARCHITECTURES armv7 CACHE STRING "") - -# NOTE(compnerd) this is lollipop, which seems to still have decent usage. -set(SWIFT_ANDROID_API_LEVEL 21 CACHE STRING "") diff --git a/cmake/caches/Runtime-Android-i686.cmake b/cmake/caches/Runtime-Android-i686.cmake deleted file mode 100644 index 66d306370992..000000000000 --- a/cmake/caches/Runtime-Android-i686.cmake +++ /dev/null @@ -1,24 +0,0 @@ - -set(SWIFT_HOST_VARIANT_SDK ANDROID CACHE STRING "") -set(SWIFT_HOST_VARIANT_ARCH i686 CACHE STRING "") - -# NOTE(compnerd) disable the tools, we are trying to build just the standard -# library. -set(SWIFT_INCLUDE_TOOLS NO CACHE BOOL "") - -# NOTE(compnerd) cannot build tests since the tests require the toolchain -set(SWIFT_INCLUDE_TESTS NO CACHE BOOL "") - -# NOTE(compnerd) cannot build docs since that requires perl -set(SWIFT_INCLUDE_DOCS NO CACHE BOOL "") - -# NOTE(compnerd) these are part of the toolchain, not the runtime. -set(SWIFT_BUILD_SOURCEKIT NO CACHE BOOL "") - -# NOTE(compnerd) build with the compiler specified, not a just built compiler. -set(SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER YES CACHE BOOL "") - -set(SWIFT_SDK_ANDROID_ARCHITECTURES i686 CACHE STRING "") - -# NOTE(compnerd) this is lollipop, which seems to still have decent usage. -set(SWIFT_ANDROID_API_LEVEL 21 CACHE STRING "") diff --git a/cmake/caches/Runtime-Android-x86_64.cmake b/cmake/caches/Runtime-Android-x86_64.cmake deleted file mode 100644 index 8780313aaa3c..000000000000 --- a/cmake/caches/Runtime-Android-x86_64.cmake +++ /dev/null @@ -1,24 +0,0 @@ - -set(SWIFT_HOST_VARIANT_SDK ANDROID CACHE STRING "") -set(SWIFT_HOST_VARIANT_ARCH x86_64 CACHE STRING "") - -# NOTE(compnerd) disable the tools, we are trying to build just the standard -# library. -set(SWIFT_INCLUDE_TOOLS NO CACHE BOOL "") - -# NOTE(compnerd) cannot build tests since the tests require the toolchain -set(SWIFT_INCLUDE_TESTS NO CACHE BOOL "") - -# NOTE(compnerd) cannot build docs since that requires perl -set(SWIFT_INCLUDE_DOCS NO CACHE BOOL "") - -# NOTE(compnerd) these are part of the toolchain, not the runtime. -set(SWIFT_BUILD_SOURCEKIT NO CACHE BOOL "") - -# NOTE(compnerd) build with the compiler specified, not a just built compiler. -set(SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER YES CACHE BOOL "") - -set(SWIFT_SDK_ANDROID_ARCHITECTURES x86_64 CACHE STRING "") - -# NOTE(compnerd) this is lollipop, which seems to still have decent usage. -set(SWIFT_ANDROID_API_LEVEL 21 CACHE STRING "") diff --git a/cmake/caches/Runtime-Windows-aarch64.cmake b/cmake/caches/Runtime-Windows-aarch64.cmake deleted file mode 100644 index 4be155854c86..000000000000 --- a/cmake/caches/Runtime-Windows-aarch64.cmake +++ /dev/null @@ -1,20 +0,0 @@ - -set(SWIFT_HOST_VARIANT_SDK WINDOWS CACHE STRING "") -set(SWIFT_HOST_VARIANT_ARCH aarch64 CACHE STRING "") - -# NOTE(compnerd) disable the tools, we are trying to build just the standard -# library. -set(SWIFT_INCLUDE_TOOLS NO CACHE BOOL "") - -# NOTE(compnerd) cannot build tests since the tests require the toolchain -set(SWIFT_INCLUDE_TESTS NO CACHE BOOL "") - -# NOTE(compnerd) cannot build docs since that requires perl -set(SWIFT_INCLUDE_DOCS NO CACHE BOOL "") - -# NOTE(compnerd) these are part of the toolchain, not the runtime. -set(SWIFT_BUILD_SOURCEKIT NO CACHE BOOL "") - -# NOTE(compnerd) build with the compiler specified, not a just built compiler. -set(SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER YES CACHE BOOL "") - diff --git a/cmake/caches/Runtime-Windows-i686.cmake b/cmake/caches/Runtime-Windows-i686.cmake deleted file mode 100644 index f78742e603a8..000000000000 --- a/cmake/caches/Runtime-Windows-i686.cmake +++ /dev/null @@ -1,20 +0,0 @@ - -set(SWIFT_HOST_VARIANT_SDK WINDOWS CACHE STRING "") -set(SWIFT_HOST_VARIANT_ARCH i686 CACHE STRING "") - -# NOTE(compnerd) disable the tools, we are trying to build just the standard -# library. -set(SWIFT_INCLUDE_TOOLS NO CACHE BOOL "") - -# NOTE(compnerd) cannot build tests since the tests require the toolchain -set(SWIFT_INCLUDE_TESTS NO CACHE BOOL "") - -# NOTE(compnerd) cannot build docs since that requires perl -set(SWIFT_INCLUDE_DOCS NO CACHE BOOL "") - -# NOTE(compnerd) these are part of the toolchain, not the runtime. -set(SWIFT_BUILD_SOURCEKIT NO CACHE BOOL "") - -# NOTE(compnerd) build with the compiler specified, not a just built compiler. -set(SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER YES CACHE BOOL "") - diff --git a/cmake/caches/Runtime-Windows-x86_64.cmake b/cmake/caches/Runtime-Windows-x86_64.cmake deleted file mode 100644 index 687c62a2b643..000000000000 --- a/cmake/caches/Runtime-Windows-x86_64.cmake +++ /dev/null @@ -1,19 +0,0 @@ - -set(SWIFT_HOST_VARIANT_SDK WINDOWS CACHE STRING "") -set(SWIFT_HOST_VARIANT_ARCH x86_64 CACHE STRING "") - -# NOTE(compnerd) disable the tools, we are trying to build just the standard -# library. -set(SWIFT_INCLUDE_TOOLS NO CACHE BOOL "") - -# NOTE(compnerd) cannot build tests since the tests require the toolchain -set(SWIFT_INCLUDE_TESTS NO CACHE BOOL "") - -# NOTE(compnerd) cannot build docs since that requires perl -set(SWIFT_INCLUDE_DOCS NO CACHE BOOL "") - -# NOTE(compnerd) these are part of the toolchain, not the runtime. -set(SWIFT_BUILD_SOURCEKIT NO CACHE BOOL "") - -# NOTE(compnerd) build with the compiler specified, not a just built compiler. -set(SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER YES CACHE BOOL "") diff --git a/utils/build.ps1 b/utils/build.ps1 index 186dac25a5fe..bfc20c546ab3 100644 --- a/utils/build.ps1 +++ b/utils/build.ps1 @@ -85,7 +85,7 @@ Default: 28 .PARAMETER AndroidSDKVersions An array of SDKs to build for the Android OS. -Default: @("Android", "AndroidExperimental") +Default: @("Android") .PARAMETER AndroidSDKArchitectures An array of architectures for which the Android Swift SDK should be built. @@ -101,7 +101,7 @@ If no such Windows SDK is installed, it will be downloaded from nuget. .PARAMETER WindowsSDKVersions An array of SDKs to build for the Windows OS. -Default: @("Windows", "WindowsExperimental") +Default: @("Windows") .PARAMETER WindowsSDKArchitectures An array of architectures for which the Windows Swift SDK should be built. @@ -195,7 +195,8 @@ param [string[]] $AndroidSDKArchitectures = @("aarch64", "armv7", "i686", "x86_64"), [ValidateSet("dynamic", "static")] [string[]] $AndroidSDKLinkModes = @("dynamic", "static"), - [string[]] $AndroidSDKVersions = @("Android", "AndroidExperimental"), + [string[]] $AndroidSDKVersions = @("Android"), + [ValidateSet("Android")] [string] $AndroidSDKVersionDefault = "Android", # Windows SDK Options @@ -205,7 +206,8 @@ param [string[]] $WindowsSDKArchitectures = @("X64","X86","Arm64"), [ValidateSet("dynamic", "static")] [string[]] $WindowsSDKLinkModes = @("dynamic", "static"), - [string[]] $WindowsSDKVersions = @("Windows", "WindowsExperimental"), + [string[]] $WindowsSDKVersions = @("Windows"), + [ValidateSet("Windows")] [string] $WindowsSDKVersionDefault = "Windows", # Incremental Build Support @@ -871,35 +873,31 @@ enum Project { DocC brotli - LLVM - Runtime - Dispatch - DynamicFoundation XCTest Testing ClangBuiltins ClangRuntime SwiftInspect - ExperimentalDynamicRuntime - ExperimentalDynamicOverlay - ExperimentalDynamicStringProcessing - ExperimentalDynamicSynchronization - ExperimentalDynamicDistributed - ExperimentalDynamicObservation - ExperimentalDynamicDispatch - ExperimentalDynamicDifferentiation - ExperimentalDynamicVolatile - ExperimentalDynamicFoundation - ExperimentalStaticRuntime - ExperimentalStaticOverlay - ExperimentalStaticStringProcessing - ExperimentalStaticSynchronization - ExperimentalStaticDistributed - ExperimentalStaticObservation - ExperimentalStaticDifferentiation - ExperimentalStaticVolatile - ExperimentalStaticDispatch - ExperimentalStaticFoundation + DynamicRuntime + DynamicOverlay + DynamicStringProcessing + DynamicSynchronization + DynamicDistributed + DynamicObservation + DynamicDispatch + DynamicDifferentiation + DynamicVolatile + DynamicFoundation + StaticRuntime + StaticOverlay + StaticStringProcessing + StaticSynchronization + StaticDistributed + StaticObservation + StaticDifferentiation + StaticVolatile + StaticDispatch + StaticFoundation } function Get-ProjectBinaryCache([Hashtable] $Platform, [Project] $Project) { @@ -2328,21 +2326,20 @@ function Test-Compilers([Hashtable] $Platform, [string] $Variant, [switch] $Test Load-LitTestOverrides ([IO.Path]::GetFullPath([IO.Path]::Combine($PSScriptRoot, "..", "..", "llvm-project", "lldb", "test", "windows-swift-llvm-lit-test-overrides.txt"))) # Transitive dependency of _lldb.pyd - $RuntimeBinaryCache = Get-ProjectBinaryCache $BuildPlatform Runtime Copy-Item ` - -Path $RuntimeBinaryCache\bin\swiftCore.dll ` - -Destination "$(Get-ProjectBinaryCache $BuildPlatform Compilers)\lib\site-packages\lldb" + -Path "$(Get-ProjectBinaryCache $BuildPlatform DynamicRuntime)\core\swiftCore.dll" ` + -Destination "$(Get-ProjectBinaryCache $BuildPlatform Compilers)\lib\site-packages\lldb" # Runtime dependencies of repl_swift.exe - $SwiftRTSubdir = "lib\swift\windows" - Write-Host "Copying '$RuntimeBinaryCache\$SwiftRTSubdir\$($Platform.Architecture.LLVMName)\swiftrt.obj' to '$(Get-ProjectBinaryCache $BuildPlatform Compilers)\$SwiftRTSubdir'" + Write-Host "Copying '$(Get-ProjectBinaryCache $BuildPlatform DynamicRuntime)\runtime\CMakeFiles\swiftrt.dir\SwiftRT-COFF.cpp.obj' to '$(Get-ProjectBinaryCache $BuildPlatform Compilers)\lib\swift\windows\swiftrt.obj'" Copy-Item ` - -Path "$RuntimeBinaryCache\$SwiftRTSubdir\$($Platform.Architecture.LLVMName)\swiftrt.obj" ` - -Destination "$(Get-ProjectBinaryCache $BuildPlatform Compilers)\$SwiftRTSubdir" - Write-Host "Copying '$RuntimeBinaryCache\bin\swiftCore.dll' to '$(Get-ProjectBinaryCache $BuildPlatform Compilers)\bin'" + -Path "$(Get-ProjectBinaryCache $BuildPlatform DynamicRuntime)\runtime\CMakeFiles\swiftrt.dir\SwiftRT-COFF.cpp.obj" ` + -Destination "$(Get-ProjectBinaryCache $BuildPlatform Compilers)\lib\swift\windows\swiftrt.obj" + + Write-Host "Copying '$(Get-ProjectBinaryCache $BuildPlatform DynamicRuntime)\core\swiftCore.dll' to '$(Get-ProjectBinaryCache $BuildPlatform Compilers)\bin'" Copy-Item ` - -Path "$RuntimeBinaryCache\bin\swiftCore.dll" ` - -Destination "$(Get-ProjectBinaryCache $BuildPlatform Compilers)\bin" + -Path "$(Get-ProjectBinaryCache $BuildPlatform DynamicRuntime)\core\swiftCore.dll" ` + -Destination "$(Get-ProjectBinaryCache $BuildPlatform Compilers)\bin\" $TestingDefines += @{ LLDB_INCLUDE_TESTS = "YES"; @@ -2353,7 +2350,7 @@ function Test-Compilers([Hashtable] $Platform, [string] $Variant, [switch] $Test # gtest sharding breaks llvm-lit's --xfail and LIT_XFAIL inputs: https://github.com/llvm/llvm-project/issues/102264 LLVM_LIT_ARGS = "-v --no-gtest-sharding --time-tests"; # LLDB Unit tests link against this library - LLVM_UNITTEST_LINK_FLAGS = "$(Get-PinnedToolchainSDK -OS Windows)\usr\lib\swift\windows\$($Platform.Architecture.LLVMName)\swiftCore.lib"; + LLVM_UNITTEST_LINK_FLAGS = "$(Get-ProjectBinaryCache $BuildPlatform DynamicRuntime)\core\swiftCore.lib"; } } @@ -2468,17 +2465,6 @@ function Patch-mimalloc() { } } -function Build-LLVM([Hashtable] $Platform) { - Build-CMakeProject ` - -Src $SourceCache\llvm-project\llvm ` - -Bin (Get-ProjectBinaryCache $Platform LLVM) ` - -Platform $Platform ` - -UseBuiltCompilers C,CXX ` - -Defines @{ - LLVM_HOST_TRIPLE = $Platform.Triple; - } -} - function Build-CompilerRuntime([Hashtable] $Platform) { $LLVMBinaryCache = $(Get-ProjectBinaryCache $HostPlatform Compilers) @@ -2720,50 +2706,11 @@ function Build-CURL([Hashtable] $Platform) { }) } -function Build-Runtime([Hashtable] $Platform) { - $PlatformDefines = @{} - if ($Platform.OS -eq [OS]::Android) { - $PlatformDefines += @{ - LLVM_ENABLE_LIBCXX = "YES"; - SWIFT_USE_LINKER = "lld"; - } - - if ((Get-AndroidNDK).ClangVersion -lt 18) { - $PlatformDefines += @{ - SWIFT_BUILD_CLANG_OVERLAYS_SKIP_BUILTIN_FLOAT = "YES"; - } - } - } - - Build-CMakeProject ` - -Src $SourceCache\swift ` - -Bin (Get-ProjectBinaryCache $Platform Runtime) ` - -InstallTo "$(Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK)\usr" ` - -Platform $Platform ` - -UseBuiltCompilers C,CXX,Swift ` - -SwiftSDK $null ` - -CacheScript $SourceCache\swift\cmake\caches\Runtime-$($Platform.OS.ToString())-$($Platform.Architecture.LLVMName).cmake ` - -Defines ($PlatformDefines + @{ - LLVM_DIR = "$(Get-ProjectBinaryCache $Platform LLVM)\lib\cmake\llvm"; - SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY = "YES"; - SWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP = "YES"; - SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING = "YES"; - SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED = "YES"; - SWIFT_ENABLE_EXPERIMENTAL_OBSERVATION = "YES"; - SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING = "YES"; - SWIFT_ENABLE_SYNCHRONIZATION = "YES"; - SWIFT_ENABLE_VOLATILE = "YES"; - SWIFT_NATIVE_SWIFT_TOOLS_PATH = ([IO.Path]::Combine((Get-ProjectBinaryCache $BuildPlatform Compilers), "bin")); - SWIFT_PATH_TO_LIBDISPATCH_SOURCE = "$SourceCache\swift-corelibs-libdispatch"; - SWIFT_PATH_TO_STRING_PROCESSING_SOURCE = "$SourceCache\swift-experimental-string-processing"; - }) -} - function Test-Runtime([Hashtable] $Platform) { if ($IsCrossCompiling) { throw "Swift runtime tests are not supported when cross-compiling" } - if (-not (Test-Path (Get-ProjectBinaryCache $Platform Runtime))) { + if (-not (Test-Path (Get-ProjectBinaryCache $Platform DynamicRuntime))) { throw "Swift runtime tests are supposed to reconfigure the existing build" } $CompilersBinaryCache = Get-ProjectBinaryCache $BuildPlatform Compilers @@ -2778,7 +2725,7 @@ function Test-Runtime([Hashtable] $Platform) { $env:Path = "$(Get-CMarkBinaryCache $Platform)\src;$(Get-PinnedToolchainRuntime);${env:Path};$UnixToolsBinDir" Build-CMakeProject ` -Src $SourceCache\swift ` - -Bin (Get-ProjectBinaryCache $Platform Runtime) ` + -Bin (Get-ProjectBinaryCache $Platform DynamicRuntime) ` -Platform $Platform ` -UseBuiltCompilers C,CXX,Swift ` -SwiftSDK $null ` @@ -2793,7 +2740,7 @@ function Test-Runtime([Hashtable] $Platform) { } } -function Build-ExperimentalRuntime([Hashtable] $Platform, [switch] $Static = $false) { +function Build-Runtime([Hashtable] $Platform, [switch] $Static = $false) { # TODO: remove this once the migration is completed. Invoke-IsolatingEnvVars { Invoke-VsDevShell $BuildPlatform @@ -2805,54 +2752,54 @@ function Build-ExperimentalRuntime([Hashtable] $Platform, [switch] $Static = $fa Invoke-IsolatingEnvVars { # $env:Path = "$(Get-CMarkBinaryCache $Platform)\src;$(Get-PinnedToolchainRuntime);${env:Path}" - $SDKRoot = Get-SwiftSDK -OS $Platform.OS -Identifier "$($Platform.OS)Experimental" + $SDKRoot = Get-SwiftSDK -OS $Platform.OS $RuntimeBinaryCache = if ($Static) { - Get-ProjectBinaryCache $Platform ExperimentalStaticRuntime + Get-ProjectBinaryCache $Platform StaticRuntime } else { - Get-ProjectBinaryCache $Platform ExperimentalDynamicRuntime + Get-ProjectBinaryCache $Platform DynamicRuntime } $OverlayBinaryCache = if ($Static) { - Get-ProjectBinaryCache $Platform ExperimentalStaticOverlay + Get-ProjectBinaryCache $Platform StaticOverlay } else { - Get-ProjectBinarycache $Platform ExperimentalDynamicOverlay + Get-ProjectBinarycache $Platform DynamicOverlay } $StringProcessingBinaryCache = if ($Static) { - Get-ProjectBinarycache $Platform ExperimentalStaticStringProcessing + Get-ProjectBinarycache $Platform StaticStringProcessing } else { - Get-ProjectBinarycache $Platform ExperimentalDynamicStringProcessing + Get-ProjectBinarycache $Platform DynamicStringProcessing } $SynchronizationBinaryCache = if ($Static) { - Get-ProjectBinarycache $Platform ExperimentalStaticSynchronization + Get-ProjectBinarycache $Platform StaticSynchronization } else { - Get-ProjectBinarycache $Platform ExperimentalDynamicSynchronization + Get-ProjectBinarycache $Platform DynamicSynchronization } $DistributedBinaryCache = if ($Static) { - Get-ProjectBinarycache $Platform ExperimentalStaticDistributed + Get-ProjectBinarycache $Platform StaticDistributed } else { - Get-ProjectBinarycache $Platform ExperimentalDynamicDistributed + Get-ProjectBinarycache $Platform DynamicDistributed } $ObservationBinaryCache = if ($Static) { - Get-ProjectBinarycache $Platform ExperimentalStaticObservation + Get-ProjectBinarycache $Platform StaticObservation } else { - Get-ProjectBinaryCache $Platform ExperimentalDynamicObservation + Get-ProjectBinaryCache $Platform DynamicObservation } $DifferentiationBinaryCache = if ($Static) { - Get-ProjectBinarycache $Platform ExperimentalStaticDifferentiation + Get-ProjectBinarycache $Platform StaticDifferentiation } else { - Get-ProjectBinarycache $Platform ExperimentalDynamicDifferentiation + Get-ProjectBinarycache $Platform DynamicDifferentiation } $VolatileBinaryCache = if ($Static) { - Get-ProjectBinarycache $Platform ExperimentalStaticVolatile + Get-ProjectBinarycache $Platform StaticVolatile } else { - Get-ProjectBinaryCache $Platform ExperimentalDynamicVolatile + Get-ProjectBinaryCache $Platform DynamicVolatile } Build-CMakeProject ` @@ -3058,28 +3005,13 @@ function Write-SDKSettings([OS] $OS, [string] $Identifier = $OS.ToString()) { Write-PList -Settings $SDKSettings -Path "$(Get-SwiftSDK -OS $OS -Identifier $Identifier)\SDKSettings.plist" } -function Build-Dispatch([Hashtable] $Platform) { - $SwiftSDK = Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK - Build-CMakeProject ` - -Src $SourceCache\swift-corelibs-libdispatch ` - -Bin (Get-ProjectBinaryCache $Platform Dispatch) ` - -InstallTo "${SwiftSDK}\usr" ` - -Platform $Platform ` - -UseBuiltCompilers C,CXX,Swift ` - -SwiftSDK $SwiftSDK ` - -Defines @{ - ENABLE_SWIFT = "YES"; - dispatch_INSTALL_ARCH_SUBDIR = "YES"; - } -} - function Test-Dispatch { Invoke-IsolatingEnvVars { $env:CTEST_OUTPUT_ON_FAILURE = "YES" Build-CMakeProject ` -Src $SourceCache\swift-corelibs-libdispatch ` - -Bin (Get-ProjectBinaryCache $BuildPlatform Dispatch) ` + -Bin (Get-ProjectBinaryCache $BuildPlatform DynamicDispatch) ` -Platform $BuildPlatform ` -UseBuiltCompilers C,CXX,Swift ` -SwiftSDK (Get-SwiftSDK -OS $BuildPlatform.OS -Identifier $BuildPlatform.DefaultSDK) ` @@ -3090,48 +3022,6 @@ function Test-Dispatch { } } -function Build-Foundation([Hashtable] $Platform) { - $SwiftSDK = Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK - Build-CMakeProject ` - -Src $SourceCache\swift-corelibs-foundation ` - -Bin (Get-ProjectBinaryCache $Platform DynamicFoundation) ` - -InstallTo "${SwiftSDK}\usr" ` - -Platform $Platform ` - -UseBuiltCompilers C,CXX,Swift ` - -SwiftSDK $SwiftSDK ` - -Defines @{ - BUILD_SHARED_LIBS = "YES"; - # FIXME(compnerd) - workaround ARM64 build failure when cross-compiling. - CMAKE_NINJA_FORCE_RESPONSE_FILE = "YES"; - CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib"; - BROTLI_INCLUDE_DIR = "$SourceCache\brotli\c\include"; - BROTLICOMMON_LIBRARY = if ($Platform.OS -eq [OS]::Windows) { - "$(Get-ProjectBinaryCache $Platform brotli)\brotlicommon.lib" - } else { - "$(Get-ProjectBinaryCache $Platform brotli)\libbrotlicommon.a" - }; - BROTLIDEC_LIBRARY = if ($Platform.OS -eq [OS]::Windows) { - "$(Get-ProjectBinaryCache $Platform brotli)\brotlidec.lib" - } else { - "$(Get-ProjectBinaryCache $Platform brotli)\libbrotlidec.a" - } - FOUNDATION_BUILD_TOOLS = if ($Platform.OS -eq [OS]::Windows) { "YES" } else { "NO" }; - CURL_DIR = "$BinaryCache\$($Platform.Triple)\usr\lib\cmake\CURL"; - LibXml2_DIR = "$BinaryCache\$($Platform.Triple)\usr\lib\cmake\libxml2-2.11.5"; - ZLIB_LIBRARY = if ($Platform.OS -eq [OS]::Windows) { - "$BinaryCache\$($Platform.Triple)\usr\lib\zlibstatic.lib" - } else { - "$BinaryCache\$($Platform.Triple)\usr\lib\libz.a" - }; - ZLIB_INCLUDE_DIR = "$BinaryCache\$($Platform.Triple)\usr\include"; - dispatch_DIR = (Get-ProjectCMakeModules $Platform Dispatch); - _SwiftFoundation_SourceDIR = "$SourceCache\swift-foundation"; - _SwiftFoundationICU_SourceDIR = "$SourceCache\swift-foundation-icu"; - _SwiftCollections_SourceDIR = "$SourceCache\swift-collections"; - SwiftFoundation_MACRO = "$(Get-ProjectBinaryCache $BuildPlatform BootstrapFoundationMacros)\bin" - } -} - function Test-Foundation { $ScratchPath = "$BinaryCache\$($BuildPlatform.Triple)\FoundationTests" @@ -3205,23 +3095,9 @@ function Build-XCTest([Hashtable] $Platform) { function Test-XCTest { Invoke-IsolatingEnvVars { - $SwiftRuntime = if ($BuildPlatform.DefaultSDK -match "Experimental") { - [IO.Path]::Combine((Get-InstallDir $BuildPlatform), "Runtimes", "$ProductVersion.experimental"); - } else { - [IO.Path]::Combine((Get-InstallDir $BuildPlatform), "Runtimes", "$ProductVersion"); - } - - $DispatchBinaryCache = if ($BuildPlatform.DefaultSDK -match "Experimental") { - Get-ProjectBinaryCache $BuildPlatform ExperimentalDynamicDispatch - } else { - Get-ProjectBinaryCache $BuildPlatform Dispatch - } - - $FoundationBinaryCache = if ($BuildPlatform.DefaultSDK -match "Experimental") { - Get-ProjectBinaryCache $BuildPlatform ExperimentalDynamicFoundation - } else { - Get-ProjectBinaryCache $BuildPlatform DynamicFoundation - } + $SwiftRuntime = [IO.Path]::Combine((Get-InstallDir $BuildPlatform), "Runtimes", "$ProductVersion"); + $DispatchBinaryCache = Get-ProjectBinaryCache $BuildPlatform DynamicDispatch + $FoundationBinaryCache = Get-ProjectBinaryCache $BuildPlatform DynamicFoundation $env:Path = "$(Get-ProjectBinaryCache $BuildPlatform XCTest);${FoundationBinaryCache}\bin;${DispatchBinaryCache};${SwiftRuntime}\usr\bin;${env:Path};$UnixToolsBinDir" $env:SDKROOT = Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK @@ -3235,9 +3111,9 @@ function Test-XCTest { -BuildTargets default,check-xctest ` -Defines @{ ENABLE_TESTING = "YES"; - LLVM_DIR = "$(Get-ProjectBinaryCache $BuildPlatform LLVM)\lib\cmake\llvm"; + LLVM_DIR = "$(Get-ProjectBinaryCache $BuildPlatform Compilers)\lib\cmake\llvm"; XCTEST_PATH_TO_FOUNDATION_BUILD = $(Get-ProjectBinaryCache $BuildPlatform DynamicFoundation); - XCTEST_PATH_TO_LIBDISPATCH_BUILD = $(Get-ProjectBinaryCache $BuildPlatform Dispatch); + XCTEST_PATH_TO_LIBDISPATCH_BUILD = $(Get-ProjectBinaryCache $BuildPlatform DynamicDispatch); XCTEST_PATH_TO_LIBDISPATCH_SOURCE = "$SourceCache\swift-corelibs-libdispatch"; } } @@ -3313,32 +3189,22 @@ function Install-SDK([Hashtable[]] $Platforms, [OS] $OS = $Platforms[0].OS, [str } function Build-SDK([Hashtable] $Platform) { - # Third Party Dependencies - Invoke-BuildStep Build-LLVM $Platform - - # Libraries - Invoke-BuildStep Build-Runtime $Platform - Invoke-BuildStep Build-Dispatch $Platform - Invoke-BuildStep Build-Foundation $Platform -} - -function Build-ExperimentalSDK([Hashtable] $Platform) { Invoke-BuildStep Build-CDispatch $Platform if ($Platform.LinkModes.Contains("dynamic")) { - Invoke-BuildStep Build-ExperimentalRuntime $Platform + Invoke-BuildStep Build-Runtime $Platform } if ($Platform.LinkModes.Contains("static")) { - Invoke-BuildStep Build-ExperimentalRuntime $Platform -Static + Invoke-BuildStep Build-Runtime $Platform -Static } - $SDKROOT = Get-SwiftSDK -OS $Platform.OS -Identifier "$($Platform.OS)Experimental" + $SDKROOT = Get-SwiftSDK -OS $Platform.OS if ($Platform.LinkModes.Contains("dynamic")) { - Record-OperationTime $Platform "Build-ExperimentalDynamicDispatch" { + Record-OperationTime $Platform "Build-DynamicDispatch" { Build-CMakeProject ` -Src $SourceCache\swift-corelibs-libdispatch ` - -Bin (Get-ProjectBinaryCache $Platform ExperimentalDynamicDispatch) ` + -Bin (Get-ProjectBinaryCache $Platform DynamicDispatch) ` -InstallTo "${SDKROOT}\usr" ` -Platform $Platform ` -UseBuiltCompilers C,CXX,Swift ` @@ -3352,10 +3218,10 @@ function Build-ExperimentalSDK([Hashtable] $Platform) { } } - Record-OperationTime $Platform "Build-ExperimentalDynamicFoundation" { + Record-OperationTime $Platform "Build-DynamicFoundation" { Build-CMakeProject ` -Src $SourceCache\swift-corelibs-foundation ` - -Bin (Get-ProjectBinaryCache $Platform ExperimentalDynamicFoundation) ` + -Bin (Get-ProjectBinaryCache $Platform DynamicFoundation) ` -InstallTo "${SDKROOT}\usr" ` -Platform $Platform ` -UseBuiltCompilers ASM,C,CXX,Swift ` @@ -3376,7 +3242,7 @@ function Build-ExperimentalSDK([Hashtable] $Platform) { } else { "$BinaryCache\$($Platform.Triple)\usr\lib\libz.a" }; - dispatch_DIR = $(Get-ProjectCMakeModules $Platform ExperimentalDynamicDispatch); + dispatch_DIR = $(Get-ProjectCMakeModules $Platform DynamicDispatch); SwiftSyntax_DIR = (Get-ProjectBinaryCache $HostPlatform Compilers); _SwiftFoundation_SourceDIR = "$SourceCache\swift-foundation"; _SwiftFoundationICU_SourceDIR = "$SourceCache\swift-foundation-icu"; @@ -3387,10 +3253,10 @@ function Build-ExperimentalSDK([Hashtable] $Platform) { } if ($Platform.LinkModes.Contains("static")) { - Record-OperationTime $Platform "Build-ExperimentalStaticDispatch" { + Record-OperationTime $Platform "Build-StaticDispatch" { Build-CMakeProject ` -Src $SourceCache\swift-corelibs-libdispatch ` - -Bin (Get-ProjectBinaryCache $Platform ExperimentalStaticDispatch) ` + -Bin (Get-ProjectBinaryCache $Platform StaticDispatch) ` -InstallTo "${SDKROOT}\usr" ` -Platform $Platform ` -UseBuiltCompilers C,CXX,Swift ` @@ -3404,10 +3270,10 @@ function Build-ExperimentalSDK([Hashtable] $Platform) { } } - Record-OperationTime $Platform "Build-ExperimentalStaticFoundation" { + Record-OperationTime $Platform "Build-StaticFoundation" { Build-CMakeProject ` -Src $SourceCache\swift-corelibs-foundation ` - -Bin (Get-ProjectBinaryCache $Platform ExperimentalStaticFoundation) ` + -Bin (Get-ProjectBinaryCache $Platform StaticFoundation) ` -InstallTo "${SDKROOT}\usr" ` -Platform $Platform ` -UseBuiltCompilers ASM,C,CXX,Swift ` @@ -3429,7 +3295,7 @@ function Build-ExperimentalSDK([Hashtable] $Platform) { } else { "$BinaryCache\$($Platform.Triple)\usr\lib\libz.a" }; - dispatch_DIR = $(Get-ProjectCMakeModules $Platform ExperimentalStaticDispatch); + dispatch_DIR = (Get-ProjectCMakeModules $Platform StaticDispatch); SwiftSyntax_DIR = (Get-ProjectBinaryCache $HostPlatform Compilers); _SwiftFoundation_SourceDIR = "$SourceCache\swift-foundation"; _SwiftFoundationICU_SourceDIR = "$SourceCache\swift-foundation-icu"; @@ -4113,7 +3979,6 @@ function Build-Installer([Hashtable] $Platform) { $Properties = @{ BundleFlavor = "offline"; ImageRoot = "$(Get-InstallDir $Platform)\"; - IncludeLegacySDK = if ($HostPlatform.DefaultSDK -match "Experimental") { "False" } else { "True" }; RedistributablesDirectory = (Get-PinnedToolchainRedistributables); INCLUDE_SWIFT_DOCC = $INCLUDE_SWIFT_DOCC; SWIFT_DOCC_BUILD = "$(Get-ProjectBinaryCache $HostPlatform DocC)\release"; @@ -4140,7 +4005,6 @@ function Build-Installer([Hashtable] $Platform) { $Properties["ToolchainVariants"] = "`"asserts$(if ($IncludeNoAsserts) { ";noasserts" })`""; foreach ($Build in $WindowsSDKBuilds) { $Properties["WindowsRuntime$($Build.Architecture.ShortName.ToUpperInvariant())"] = [IO.Path]::Combine((Get-InstallDir $Build), "Runtimes", "$ProductVersion"); - $Properties["WindowsExperimentalRuntime$($Build.Architecture.ShortName.ToUpperInvariant())"] = [IO.Path]::Combine((Get-InstallDir $Build), "Runtimes", "$ProductVersion.experimental"); } Build-WiXProject bundle\installer.wixproj -Platform $Platform -Bundle -Properties $Properties @@ -4281,51 +4145,26 @@ if (-not $SkipBuild) { Invoke-BuildStep Build-CURL $Build } - foreach ($SDK in $WindowsSDKVersions) { - switch ($SDK) { - Windows { - $SDKROOT = Get-SwiftSDK -OS Windows -Identifier Windows - foreach ($Build in $WindowsSDKBuilds) { - Invoke-BuildStep Build-SDK $Build - - Get-ChildItem "${SDKROOT}\usr\lib\swift\windows" -Filter "*.lib" -File -ErrorAction Ignore | ForEach-Object { - Write-Host -BackgroundColor DarkRed -ForegroundColor White "$($_.FullName) is not nested in an architecture directory" - Move-Item $_.FullName "${SDKROOT}\usr\lib\swift\windows\$($Build.Architecture.LLVMName)\" | Out-Null - } - - # FIXME(compnerd) how do we select which SDK is meant to be re-distributed? - Copy-Directory "${SDKROOT}\usr\bin" "$([IO.Path]::Combine((Get-InstallDir $Build), "Runtimes", $ProductVersion, "usr"))" - } - - Install-SDK $WindowsSDKBuilds - Write-SDKSettings Windows - } - - WindowsExperimental { - $SDKROOT = Get-SwiftSDK -OS Windows -Identifier WindowsExperimental - foreach ($Build in $WindowsSDKBuilds) { - Invoke-BuildStep Build-ExperimentalSDK $Build - - Get-ChildItem "${SDKROOT}\usr\lib\swift\windows" -Filter "*.lib" -File -ErrorAction Ignore | ForEach-Object { - Write-Host -BackgroundColor DarkRed -ForegroundColor White "$($_.FullName) is not nested in an architecture directory" - Move-Item $_.FullName "${SDKROOT}\usr\lib\swift\windows\$($Build.Architecture.LLVMName)\" | Out-Null - } - - Get-ChildItem "${SDKROOT}\usr\lib\swift_static\windows" -Filter "*.lib" -File -ErrorAction Ignore | ForEach-Object { - Write-Host -BackgroundColor DarkRed -ForegroundColor White "$($_.FullName) is not nested in an architecture directory" - Move-Item $_.FullName "${SDKROOT}\usr\lib\swift_static\windows\$($Build.Architecture.LLVMName)\" | Out-Null - } + $SDKROOT = Get-SwiftSDK -OS Windows + foreach ($Build in $WindowsSDKBuilds) { + Invoke-BuildStep Build-SDK $Build - # FIXME(compnerd) how do we select which SDK is meant to be re-distributed? - Copy-Directory "${SDKROOT}\usr\bin" "$([IO.Path]::Combine((Get-InstallDir $Build), "Runtimes", "$ProductVersion.experimental", "usr"))" - } + Get-ChildItem -ErrorAction Ignore "${SDKROOT}\usr\lib\swift\windows" -Filter "*.lib" -File | ForEach-Object { + Write-Host -BackgroundColor DarkRed -ForegroundColor White "$($_.FullName) is not nested in an architecture directory" + Move-Item $_.FullName "${SDKROOT}\usr\lib\swift\windows\$($Build.Architecture.LLVMName)\" | Out-Null + } - Install-SDK $WindowsSDKBuilds -Identifier WindowsExperimental - Write-SDKSettings Windows -Identifier WindowsExperimental - } + Get-ChildItem -ErrorAction Ignore "${SDKROOT}\usr\lib\swift_static\windows" -Filter "*.lib" -File | ForEach-Object { + Write-Host -BackgroundColor DarkRed -ForegroundColor White "$($_.FullName) is not nested in an architecture directory" + Move-Item $_.FullName "${SDKROOT}\usr\lib\swift_static\windows\$($Build.Architecture.LLVMName)\" | Out-Null } + + Copy-Directory "${SDKROOT}\usr\bin" "$([IO.Path]::Combine((Get-InstallDir $Build), "Runtimes", "$ProductVersion", "usr"))" } + Install-SDK $WindowsSDKBuilds + Write-SDKSettings Windows + foreach ($Build in $WindowsSDKBuilds) { Invoke-BuildStep Build-XCTest $Build Invoke-BuildStep Build-Testing $Build @@ -4337,10 +4176,8 @@ if (-not $SkipBuild) { # Copy static dependencies foreach ($Build in $WindowsSDKBuilds) { - if (-not $Build.LinkModes.Contains("static")) { continue } - - $SDKROOT = Get-SwiftSDK -OS $Build.OS -Identifier "$($Build.OS)Experimental" $SwiftResourceDir = "${SDKROOT}\usr\lib\swift_static\$($Build.OS.ToString().ToLowerInvariant())\$($Build.Architecture.LLVMName)" + New-Item -ErrorAction Ignore -ItemType Directory -Path "${SwiftResourceDir}" | Out-Null Copy-Item -Force -Path "$(Get-ProjectBinaryCache $Build brotli)\brotlicommon.lib" -Destination "${SwiftResourceDir}\brotlicommon.lib" | Out-Null Copy-Item -Force -Path "$(Get-ProjectBinaryCache $Build brotli)\brotlidec.lib" -Destination "${SwiftResourceDir}\brotlidec.lib" | Out-Null Copy-Item -Force -Path "${BinaryCache}\$($Build.Triple)\curl\lib\libcurl.lib" -Destination "${SwiftResourceDir}\libcurl.lib" | Out-Null @@ -4361,45 +4198,24 @@ if (-not $SkipBuild) { Invoke-BuildStep Build-CURL $Build } - foreach ($SDK in $AndroidSDKVersions) { - switch ($SDK) { - Android { - $SDKROOT = Get-SwiftSDK -OS Android -Identifier Android - foreach ($Build in $AndroidSDKBuilds) { - Invoke-BuildStep Build-SDK $Build - - Get-ChildItem "${SDKROOT}\usr\lib\swift\android" -File | Where-Object { $_.Name -match ".a$|.so$" } | ForEach-Object { - Write-Host -BackgroundColor DarkRed -ForegroundColor White "$($_.FullName) is not nested in an architecture directory" - Move-Item $_.FullName "${SDKROOT}\usr\lib\swift\android\$($Build.Architecture.LLVMName)\" | Out-Null - } - } - - Install-SDK $AndroidSDKBuilds - Write-SDKSettings Android - } - - AndroidExperimental { - $SDKROOT = Get-SwiftSDK Android -Identifier AndroidExperimental - foreach ($Build in $AndroidSDKBuilds) { - Invoke-BuildStep Build-ExperimentalSDK $Build - - Get-ChildItem "${SDKROOT}\usr\lib\swift\android" -File | Where-Object { $_.Name -match ".a$|.so$" } | ForEach-Object { - Write-Host -BackgroundColor DarkRed -ForegroundColor White "$($_.FullName) is not nested in an architecture directory" - Move-Item $_.FullName "${SDKROOT}\usr\lib\swift\android\$($Build.Architecture.LLVMName)\" | Out-Null - } + $SDKROOT = Get-SwiftSDK Android + foreach ($Build in $AndroidSDKBuilds) { + Invoke-BuildStep Build-SDK $Build - Get-ChildItem "${SDKROOT}\usr\lib\swift_static\android" -File | Where-Object { $_.Name -match ".a$|.so$" } | ForEach-Object { - Write-Host -BackgroundColor DarkRed -ForegroundColor White "$($_.FullName) is not nested in an architecture directory" - Move-Item $_.FullName "${SDKROOT}\usr\lib\swift_static\android\$($Build.Architecture.LLVMName)\" | Out-Null - } - } + Get-ChildItem -ErrorAction Ignore "${SDKROOT}\usr\lib\swift\android" -File | Where-Object { $_.Name -match ".a$|.so$" } | ForEach-Object { + Write-Host -BackgroundColor DarkRed -ForegroundColor White "$($_.FullName) is not nested in an architecture directory" + Move-Item $_.FullName "${SDKROOT}\usr\lib\swift\android\$($Build.Architecture.LLVMName)\" | Out-Null + } - Install-SDK $AndroidSDKBuilds -Identifiers AndroidExperimental - Write-SDKSettings Android -Identifier AndroidExperimental - } + Get-ChildItem -ErrorAction Ignore "${SDKROOT}\usr\lib\swift_static\android" -File | Where-Object { $_.Name -match ".a$|.so$" } | ForEach-Object { + Write-Host -BackgroundColor DarkRed -ForegroundColor White "$($_.FullName) is not nested in an architecture directory" + Move-Item $_.FullName "${SDKROOT}\usr\lib\swift_static\android\$($Build.Architecture.LLVMName)\" | Out-Null } } + Install-SDK $AndroidSDKBuilds + Write-SDKSettings Android + foreach ($Build in $AndroidSDKBuilds) { Invoke-BuildStep Build-XCTest $Build Invoke-BuildStep Build-Testing $Build @@ -4414,10 +4230,8 @@ if (-not $SkipBuild) { # Copy static dependencies foreach ($Build in $AndroidSDKBuilds) { - if (-not $Build.LinkModes.Contains("static")) { continue } - - $SDKROOT = Get-SwiftSDK -OS $Build.OS -Identifier "$($Build.OS)Experimental" $SwiftResourceDir = "${SDKROOT}\usr\lib\swift_static\$($Build.OS.ToString().ToLowerInvariant())\$($Build.Architecture.LLVMName)" + New-Item -ErrorAction Ignore -ItemType Directory -Path "${SwiftResourceDir}" | Out-Null Copy-Item -Force -Path "$(Get-ProjectBinaryCache $Build brotli)\libbrotlicommon.a" -Destination "${SwiftResourceDir}\libbrotlicommon.a" | Out-Null Copy-Item -Force -Path "$(Get-ProjectBinaryCache $Build brotli)\libbrotlidec.a" -Destination "${SwiftResourceDir}\libbrotlidec.a" | Out-Null Copy-Item -Force -Path "${BinaryCache}\$($Build.Triple)\curl\lib\libcurl.a" -Destination "${SwiftResourceDir}\libcurl.a" | Out-Null @@ -4426,6 +4240,7 @@ if (-not $SkipBuild) { } } + # Build Macros for distribution Invoke-BuildStep Build-FoundationMacros $HostPlatform Invoke-BuildStep Build-TestingMacros $HostPlatform From 337892d065a94da2a33f425541cdc8ed71bb63be Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Thu, 9 Oct 2025 18:16:31 -0700 Subject: [PATCH 4/7] build.ps1: shuffle build order Build the complete toolchain before we build the SDK. This delays a certain class of errors, however, the resulting build order is much easier to reason about. --- utils/build.ps1 | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/utils/build.ps1 b/utils/build.ps1 index bfc20c546ab3..e9805c89def1 100644 --- a/utils/build.ps1 +++ b/utils/build.ps1 @@ -4264,24 +4264,18 @@ if (-not $SkipBuild) { Invoke-BuildStep Build-IndexStoreDB $HostPlatform Invoke-BuildStep Build-SourceKitLSP $HostPlatform Invoke-BuildStep Build-Inspect $HostPlatform -} -Install-HostToolchain + Install-HostToolchain -if (-not $SkipBuild) { Invoke-BuildStep Build-mimalloc $HostPlatform -} -if (-not $SkipBuild -and $IncludeNoAsserts) { - Build-NoAssertsToolchain -} + if ($IncludeNoAsserts) { + Build-NoAssertsToolchain + } -if (-not $SkipBuild) { Invoke-BuildStep Build-SymbolKit $HostPlatform Invoke-BuildStep Build-DocC $HostPlatform -} -if (-not $SkipBuild) { Invoke-BuildStep Patch-mimalloc $HostPlatform } From 573a019f64b5a00111c957142943c13c80f9d8ca Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Wed, 14 May 2025 17:35:36 -0700 Subject: [PATCH 5/7] utils: build early swift-driver on Windows This prepares the swift-driver building on Windows. By statically linking the runtime and its dependencies, this will allow us to avoid the runtime shuffling that is required to get the runtime required to get the swift-driver working. --- utils/build.ps1 | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/utils/build.ps1 b/utils/build.ps1 index e9805c89def1..8126c1af07a3 100644 --- a/utils/build.ps1 +++ b/utils/build.ps1 @@ -845,6 +845,7 @@ enum Project { RegsGen2 BootstrapFoundationMacros BootstrapTestingMacros + EarlySwiftDriver CDispatch Compilers @@ -2151,6 +2152,26 @@ function Build-BuildTools([Hashtable] $Platform) { } } +function Build-EarlySwiftDriver { + Build-CMakeProject ` + -Src $SourceCache\swift-driver ` + -Bin (Get-ProjectBinaryCache $Platform EarlySwiftDriver) ` + -Platform $BuildPlatform ` + -UsePinnedCompilers C,CXX,Swift ` + -SwiftSDK (Get-PinnedToolchainSDK -OS $BuildPlatform.OS -Identifier "$($BuildPlatform.OS)Experimental") ` + -BuildTargets default ` + -Defines @{ + BUILD_SHARED_LIBS = "NO"; + BUILD_TESTING = "NO"; + CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib"; + # TODO(compnerd) - remove `-Xfrontend -use-static-resource-dir` - this is inferred by the `-static-stdlib`. + CMAKE_Swift_FLAGS = @("-static-stdlib", "-Xfrontend", "-use-static-resource-dir"); + SWIFT_DRIVER_BUILD_TOOLS = "NO"; + SQLite3_INCLUDE_DIR = "$SourceCache\swift-toolchain-sqlite\Sources\CSQLite\include"; + SQLite3_LIBRARY = "$(Get-ProjectBinaryCache $Platform SQLite)\SQLite3.lib"; + } +} + function Write-PList { [CmdletBinding(PositionalBinding = $false)] param @@ -4085,6 +4106,8 @@ if (-not $SkipBuild) { Invoke-BuildStep Build-CMark $BuildPlatform Invoke-BuildStep Build-BuildTools $BuildPlatform + Invoke-BuildStep Build-SQLite $BuildPlatform + Invoke-BuildStep Build-EarlySwiftDriver $BuildPlatform if ($IsCrossCompiling) { Invoke-BuildStep Build-XML2 $BuildPlatform Invoke-BuildStep Build-Compilers $BuildPlatform -Variant "Asserts" From c40d883534a7939a4993bec8bd6660e10c1d5703 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Wed, 9 Jul 2025 14:42:42 -0700 Subject: [PATCH 6/7] utils: enable the early swift-driver for Windows Enable the use of the early swift-driver to build the Swift toolchain. This is the first step towards removing the accumulated debt and workarounds when building the toolchain on Windows. --- utils/build.ps1 | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/utils/build.ps1 b/utils/build.ps1 index 8126c1af07a3..a044483ac102 100644 --- a/utils/build.ps1 +++ b/utils/build.ps1 @@ -1716,9 +1716,6 @@ function Build-CMakeProject { Add-KeyValueIfNew $Defines CMAKE_Swift_COMPILER $SWIFTC Add-KeyValueIfNew $Defines CMAKE_Swift_COMPILER_TARGET $Platform.Triple - # TODO(compnerd): remove this once we have the early swift-driver - Add-KeyValueIfNew $Defines CMAKE_Swift_COMPILER_USE_OLD_DRIVER "YES" - [string[]] $SwiftFlags = @(); $SwiftFlags += if ($SwiftSDK) { @@ -1835,9 +1832,6 @@ function Build-CMakeProject { Add-KeyValueIfNew $Defines CMAKE_Swift_COMPILER $SWIFTC Add-KeyValueIfNew $Defines CMAKE_Swift_COMPILER_TARGET $Platform.Triple - # TODO(compnerd) remove this once we have the early swift-driver - Add-KeyValueIfNew $Defines CMAKE_Swift_COMPILER_USE_OLD_DRIVER "YES" - [string[]] $SwiftFlags = @() $SwiftFlags += if ($SwiftSDK) { @@ -2292,6 +2286,7 @@ function Get-CompilersDefines([Hashtable] $Platform, [string] $Variant, [switch] SWIFT_TOOLCHAIN_VERSION = "${ToolchainIdentifier}"; SWIFT_BUILD_SWIFT_SYNTAX = "YES"; SWIFT_CLANG_LOCATION = (Get-PinnedToolchainToolsDir); + SWIFT_EARLY_SWIFT_DRIVER_BUILD = "$(Get-ProjectBinaryCache $BuildPlatform EarlySwiftDriver)\bin"; SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY = "YES"; SWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP = "YES"; SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING = "YES"; From 10ddf0782e56687bf95fd8b7b6f584528dd3a294 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Wed, 5 Nov 2025 11:00:56 -0800 Subject: [PATCH 7/7] fixup! utils: update toolchain snapshot to permit use of the experimental SDK --- utils/build.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/build.ps1 b/utils/build.ps1 index a044483ac102..b5391590a491 100644 --- a/utils/build.ps1 +++ b/utils/build.ps1 @@ -276,7 +276,7 @@ if ($UseHostToolchain -is [string]) { $DefaultPinned = @{ AMD64 = @{ PinnedBuild = "https://download.swift.org/development/windows10/swift-DEVELOPMENT-SNAPSHOT-2025-11-03-a/swift-DEVELOPMENT-SNAPSHOT-2025-11-03-a-windows10.exe"; - PinnedSHA256 = ""; + PinnedSHA256 = "1B93C9B419070925E5ABCD1A273C510121E9928554876EC0DCA530121D8C93D3"; PinnedVersion = "0.0.0"; }; ARM64 = @{