From b6cf1f0877eb87311162ace2b306670012c8a537 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 153664da6d11..798befec98c7 100644 --- a/utils/build.ps1 +++ b/utils/build.ps1 @@ -269,14 +269,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://ci-external.swift.org/job/swift-main-windows-toolchain/1656/artifact/build/artifacts/installer.exe"; + PinnedSHA256 = "13841E44438D4EF1C40544B5AD97B8D549C0B2DA0E66BAEC5039EE48404D0D9A"; + 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-09-21-a/swift-DEVELOPMENT-SNAPSHOT-2025-09-21-a-windows10-arm64.exe" + PinnedSHA256 = ""; + PinnedVersion = "0.0.0"; }; } @@ -2191,6 +2191,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 e8c82d9bc5b327d18b00e9e83f6fc96a505dac1f 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 | 170 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 115 insertions(+), 55 deletions(-) diff --git a/utils/build.ps1 b/utils/build.ps1 index 798befec98c7..c95cab13c155 100644 --- a/utils/build.ps1 +++ b/utils/build.ps1 @@ -1421,7 +1421,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, @@ -1437,6 +1437,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 @@ -1662,7 +1670,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" } @@ -1782,7 +1790,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" } @@ -1893,9 +1901,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 "" @@ -1965,8 +1973,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 = @( @@ -1974,6 +1982,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") @@ -2305,7 +2314,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"; } } @@ -2481,7 +2490,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"; @@ -2755,8 +2765,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) { @@ -3126,8 +3135,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; } @@ -3411,8 +3420,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"; @@ -3425,8 +3434,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"; @@ -3443,8 +3452,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"; @@ -3464,14 +3473,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); } } @@ -3482,9 +3488,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"; @@ -3512,7 +3517,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"; @@ -3531,8 +3536,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"; @@ -3546,8 +3551,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"; @@ -3568,8 +3573,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"; @@ -3584,8 +3589,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"; @@ -3597,8 +3602,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"; @@ -3611,8 +3616,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"; @@ -3634,8 +3639,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"); @@ -3683,8 +3688,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"; @@ -3700,9 +3705,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); @@ -3761,12 +3765,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 @{ @@ -3784,8 +3788,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); @@ -3896,13 +3900,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 } @@ -3941,14 +3993,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 = @( @@ -3995,6 +4051,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"; @@ -4113,6 +4170,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 eb87abe0e089eb53a488abcc99d8bb9f7e11f0f0 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. --- utils/build.ps1 | 397 +++++++++++++----------------------------------- 1 file changed, 106 insertions(+), 291 deletions(-) diff --git a/utils/build.ps1 b/utils/build.ps1 index c95cab13c155..2e9e6ee84a08 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. @@ -191,7 +191,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 @@ -201,7 +202,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 @@ -863,35 +865,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) { @@ -2289,21 +2287,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"; @@ -2314,7 +2311,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"; } } @@ -2429,17 +2426,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) @@ -2681,50 +2667,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 @@ -2739,7 +2686,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 ` @@ -2754,7 +2701,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 @@ -2766,54 +2713,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 ` @@ -3020,28 +2967,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) ` @@ -3052,48 +2984,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" @@ -3167,23 +3057,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 @@ -3197,9 +3073,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"; } } @@ -3275,32 +3151,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 ` @@ -3314,10 +3180,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 ` @@ -3338,7 +3204,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"; @@ -3349,10 +3215,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 ` @@ -3366,10 +3232,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 ` @@ -3391,7 +3257,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"; @@ -4050,7 +3916,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"; @@ -4077,7 +3942,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 @@ -4218,51 +4082,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 @@ -4274,10 +4113,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 @@ -4298,45 +4135,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 @@ -4351,10 +4167,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 @@ -4363,6 +4177,7 @@ if (-not $SkipBuild) { } } + # Build Macros for distribution Invoke-BuildStep Build-FoundationMacros $HostPlatform Invoke-BuildStep Build-TestingMacros $HostPlatform From 340f8f2e5f1e30ab47803e51618a52763df0c1ab Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Thu, 9 Oct 2025 14:25:50 -0700 Subject: [PATCH 4/7] cmake: remove caches --- 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 ----------------- 7 files changed, 155 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 "") From e47c73f6b99611d8087fb00479468abd344d0297 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Thu, 9 Oct 2025 18:16:31 -0700 Subject: [PATCH 5/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 | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/utils/build.ps1 b/utils/build.ps1 index 2e9e6ee84a08..a33821b346b6 100644 --- a/utils/build.ps1 +++ b/utils/build.ps1 @@ -4201,23 +4201,19 @@ 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 -and -not $IsCrossCompiling) { - Invoke-BuildStep Build-DocC $HostPlatform -} + if (-not $IsCrossCompiling) { + Invoke-BuildStep Build-DocC $HostPlatform + } -if (-not $SkipBuild) { Invoke-BuildStep Patch-mimalloc $HostPlatform } From 211bf63a0310a935cf37b60f1b866ac8ac95fcd9 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Wed, 14 May 2025 17:35:36 -0700 Subject: [PATCH 6/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 a33821b346b6..0f9f0b2160c7 100644 --- a/utils/build.ps1 +++ b/utils/build.ps1 @@ -837,6 +837,7 @@ enum Project { RegsGen2 BootstrapFoundationMacros BootstrapTestingMacros + EarlySwiftDriver CDispatch Compilers @@ -2112,6 +2113,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 @@ -4022,6 +4043,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 cfdd5e0c2f91b098f88afd9e83f56c40d26c3c6f Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Wed, 9 Jul 2025 14:42:42 -0700 Subject: [PATCH 7/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 0f9f0b2160c7..0ed9b8578919 100644 --- a/utils/build.ps1 +++ b/utils/build.ps1 @@ -1677,9 +1677,6 @@ function Build-CMakeProject { Add-KeyValueIfNew $Defines CMAKE_Swift_COMPILER $SWIFTC Add-KeyValueIfNew $Defines CMAKE_Swift_COMPILER_TARGET (Get-ModuleTriple $Platform) - # 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) { @@ -1796,9 +1793,6 @@ function Build-CMakeProject { Add-KeyValueIfNew $Defines CMAKE_Swift_COMPILER $SWIFTC Add-KeyValueIfNew $Defines CMAKE_Swift_COMPILER_TARGET (Get-ModuleTriple $Platform) - # 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) { @@ -2253,6 +2247,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";