From 370584a3a364a054112d427d6d91a05879511890 Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Wed, 15 Oct 2025 09:50:37 -0700 Subject: [PATCH 1/6] Unskip building docc for cross-compiling on Windows This should be working now, let's try it... --- utils/build.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/build.ps1 b/utils/build.ps1 index d6de3c8a92010..7891887ab7a32 100644 --- a/utils/build.ps1 +++ b/utils/build.ps1 @@ -4322,7 +4322,7 @@ if (-not $SkipBuild -and $IncludeNoAsserts) { Build-NoAssertsToolchain } -if (-not $SkipBuild -and -not $IsCrossCompiling) { +if (-not $SkipBuild) { Invoke-BuildStep Build-DocC $HostPlatform } From 988e3d3e3201556d89e2ca9f8047916dad8e7fba Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Tue, 21 Oct 2025 17:26:17 -0700 Subject: [PATCH 2/6] Remove $RuntimeInstallRoot\usr\bin from the PATH used to find `swift build` --- utils/build.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/build.ps1 b/utils/build.ps1 index 7891887ab7a32..0179621ad4268 100644 --- a/utils/build.ps1 +++ b/utils/build.ps1 @@ -1965,7 +1965,7 @@ 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:Path = "$($BuildPlatform.ToolchainInstallRoot)\usr\bin;${env:Path}" $env:SDKROOT = (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) $env:SWIFTCI_USE_LOCAL_DEPS = "1" From 195662fa2f6e55b5b3b01178541503ed20e57495 Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Wed, 22 Oct 2025 09:57:20 -0700 Subject: [PATCH 3/6] Don't set PATH at all, and set --target --- utils/build.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/build.ps1 b/utils/build.ps1 index 0179621ad4268..75e20bd3d5065 100644 --- a/utils/build.ps1 +++ b/utils/build.ps1 @@ -1965,11 +1965,11 @@ function Build-SPMProject { Invoke-IsolatingEnvVars { $RuntimeInstallRoot = [IO.Path]::Combine((Get-InstallDir $BuildPlatform), "Runtimes", $ProductVersion) - $env:Path = "$($BuildPlatform.ToolchainInstallRoot)\usr\bin;${env:Path}" $env:SDKROOT = (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) $env:SWIFTCI_USE_LOCAL_DEPS = "1" $Arguments = @( + "--triple", "$($Platform.Triple)", "--scratch-path", $Bin, "--package-path", $Src, "-c", $Configuration From 8b5021508d822f2a9684fb9c309dab4700751f93 Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Wed, 22 Oct 2025 18:31:51 -0700 Subject: [PATCH 4/6] Try to set the PATH correctly again --- utils/build.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/utils/build.ps1 b/utils/build.ps1 index 75e20bd3d5065..2ef0ea00a113c 100644 --- a/utils/build.ps1 +++ b/utils/build.ps1 @@ -1965,6 +1965,7 @@ function Build-SPMProject { Invoke-IsolatingEnvVars { $RuntimeInstallRoot = [IO.Path]::Combine((Get-InstallDir $BuildPlatform), "Runtimes", $ProductVersion) + $env:Path = "$(Get-PinnedToolchainRuntime);$(Get-PinnedToolchainToolsDir);${env:Path}" $env:SDKROOT = (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) $env:SWIFTCI_USE_LOCAL_DEPS = "1" From 6cc5c12c6dede3abaa43e4b258a163d85355b6b4 Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Thu, 23 Oct 2025 03:10:34 -0700 Subject: [PATCH 5/6] Update SDKROOT environment variable assignment to use pinned toolchain SDK --- utils/build.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/build.ps1 b/utils/build.ps1 index 2ef0ea00a113c..c607d81407bbc 100644 --- a/utils/build.ps1 +++ b/utils/build.ps1 @@ -1966,7 +1966,7 @@ function Build-SPMProject { $RuntimeInstallRoot = [IO.Path]::Combine((Get-InstallDir $BuildPlatform), "Runtimes", $ProductVersion) $env:Path = "$(Get-PinnedToolchainRuntime);$(Get-PinnedToolchainToolsDir);${env:Path}" - $env:SDKROOT = (Get-SwiftSDK -OS $Platform.OS -Identifier $Platform.DefaultSDK) + $env:SDKROOT = (Get-PinnedToolchainSDK -OS $BuildPlatform.OS) $env:SWIFTCI_USE_LOCAL_DEPS = "1" $Arguments = @( From 5fd62a77370c8021fa4d4b5d251057b5a425c0c1 Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Thu, 23 Oct 2025 10:25:35 -0700 Subject: [PATCH 6/6] Refactor build script for environment variable handling Now we keep the old behavior for running tests, while using the pinned toolchain for builds --- utils/build.ps1 | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/utils/build.ps1 b/utils/build.ps1 index c607d81407bbc..bf4a014edeab4 100644 --- a/utils/build.ps1 +++ b/utils/build.ps1 @@ -1963,14 +1963,9 @@ function Build-SPMProject { $Stopwatch = [Diagnostics.Stopwatch]::StartNew() Invoke-IsolatingEnvVars { - $RuntimeInstallRoot = [IO.Path]::Combine((Get-InstallDir $BuildPlatform), "Runtimes", $ProductVersion) - - $env:Path = "$(Get-PinnedToolchainRuntime);$(Get-PinnedToolchainToolsDir);${env:Path}" - $env:SDKROOT = (Get-PinnedToolchainSDK -OS $BuildPlatform.OS) $env:SWIFTCI_USE_LOCAL_DEPS = "1" $Arguments = @( - "--triple", "$($Platform.Triple)", "--scratch-path", $Bin, "--package-path", $Src, "-c", $Configuration @@ -1998,6 +1993,18 @@ function Build-SPMProject { } } + if ($ActionName -eq "build") { + # For building, we are cross-compiling content using the pinned to ship as part of the toolchain + $env:Path = "$(Get-PinnedToolchainRuntime);$(Get-PinnedToolchainToolsDir);${env:Path}" + $env:SDKROOT = (Get-PinnedToolchainSDK -OS $BuildPlatform.OS) + $Arguments += @("--triple", "$($Platform.Triple)") + } else { + # For testing, we are doing this using the just-built toolchain and only when NOT cross-compiling + $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) + } + Invoke-Program swift $ActionName @Arguments @AdditionalArguments }