Skip to content

Commit 74b4b5d

Browse files
committed
Temporarily specify Windows SDK and MSVC versions
This is necessary to work around an issue with the latest version (26100) of the Windows SDK where changes in headers result in circular module dependencies. For the compilers build, this installs and uses MSVC 14.42 because the current build does not work with MSVC 14.43. In addition, this removes the 26100 Windows SDK to get the compilers to build until the bootstrap toolchain supports the new SDK. See #909 for details.
1 parent 409d1d9 commit 74b4b5d

File tree

1 file changed

+93
-3
lines changed

1 file changed

+93
-3
lines changed

.github/workflows/swift-toolchain.yml

Lines changed: 93 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,16 @@ env:
276276
WORKAROUND_WINDOWS_PINNED_BOOTSTRAP_TOOLCHAIN_REPO: thebrowsercompany/swift-build
277277
WORKAROUND_WINDOWS_PINNED_BOOTSTRAP_TOOLCHAIN_RELEASE: swift-6.0.0-20241216.0
278278

279+
# Workaround for issues with building with SDK version 26100.
280+
# See https://github.com/compnerd/swift-build/issues/909 for details.
281+
WORKAROUND_WINDOWS_SDK_VERSION: 10.0.22621.0
282+
UNSUPPORTED_WINDOWS_SDK_VERSION: 10.0.26100.0
283+
284+
# Workaround for issues with building with MSVC 14.43.
285+
# See https://github.com/swiftlang/swift/issues/79852 for details.
286+
WORKAROUND_WINDOWS_COMPILER_VERSION: 14.42.34433
287+
WORKAROUND_WINDOWS_COMPILER_VERSION_PACKAGE: 14.42.17.12
288+
279289
defaults:
280290
run:
281291
shell: pwsh
@@ -308,6 +318,7 @@ jobs:
308318
host_arch: ${{ inputs.build_arch }}
309319
components: 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64;Microsoft.VisualStudio.Component.VC.Tools.ARM64'
310320
arch: ${{ matrix.arch }}
321+
winsdk: ${{ env.WORKAROUND_WINDOWS_SDK_VERSION }}
311322

312323
- uses: seanmiddleditch/gha-setup-ninja@96bed6edff20d1dd61ecff9b75cc519d516e6401 # master
313324
if: inputs.build_os == 'Darwin'
@@ -378,6 +389,7 @@ jobs:
378389
host_arch: ${{ inputs.build_arch }}
379390
components: 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64;Microsoft.VisualStudio.Component.VC.Tools.ARM64'
380391
arch: amd64
392+
winsdk: ${{ env.WORKAROUND_WINDOWS_SDK_VERSION }}
381393

382394
# TODO(issues/205): Preload Chocolatey package manager on Azure images so we can remove this step.
383395
- uses: andrurogerz/ensure-chocolatey@v1
@@ -470,6 +482,7 @@ jobs:
470482
host_arch: ${{ inputs.build_arch }}
471483
components: 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64;Microsoft.VisualStudio.Component.VC.Tools.ARM64'
472484
arch: ${{ matrix.arch }}
485+
winsdk: ${{ env.WORKAROUND_WINDOWS_SDK_VERSION }}
473486

474487
# TODO(issues/205): Preload Chocolatey package manager on Azure images so we can remove this step.
475488
- uses: andrurogerz/ensure-chocolatey@v1
@@ -546,6 +559,7 @@ jobs:
546559
host_arch: ${{ inputs.build_arch }}
547560
components: 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64;Microsoft.VisualStudio.Component.VC.Tools.ARM64'
548561
arch: ${{ matrix.arch }}
562+
winsdk: ${{ env.WORKAROUND_WINDOWS_SDK_VERSION }}
549563

550564
- uses: seanmiddleditch/gha-setup-ninja@96bed6edff20d1dd61ecff9b75cc519d516e6401 # master
551565
if: inputs.build_os == 'Darwin'
@@ -629,6 +643,7 @@ jobs:
629643
host_arch: ${{ inputs.build_arch }}
630644
components: 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64;Microsoft.VisualStudio.Component.VC.Tools.ARM64'
631645
arch: ${{ matrix.arch }}
646+
winsdk: ${{ env.WORKAROUND_WINDOWS_SDK_VERSION }}
632647

633648
- uses: seanmiddleditch/gha-setup-ninja@96bed6edff20d1dd61ecff9b75cc519d516e6401 # master
634649
if: inputs.build_os == 'Darwin'
@@ -790,11 +805,44 @@ jobs:
790805
release-asset-name: installer-${{ inputs.build_arch }}.exe
791806
release-tag-name: ${{ env.WORKAROUND_WINDOWS_PINNED_BOOTSTRAP_TOOLCHAIN_RELEASE }}
792807

808+
# This is a workaround for not being able to build with MSVC 14.43.
809+
# See https://github.com/swiftlang/swift/issues/79852 for details.
810+
- name: Install MSVC ${{ env.WORKAROUND_WINDOWS_COMPILER_VERSION }}
811+
if: matrix.os == 'Windows'
812+
run: |
813+
$InstallerLocation = Join-Path "${env:ProgramFiles(x86)}" "Microsoft Visual Studio" "Installer"
814+
$VsWhere = Join-Path "${InstallerLocation}" "vswhere.exe"
815+
$VsInstaller = Join-Path "${InstallerLocation}" "vs_installer.exe"
816+
$InstallPath = (& "$VsWhere" -latest -products * -format json | ConvertFrom-Json).installationPath
817+
$process = Start-Process "$VsInstaller" `
818+
-PassThru `
819+
-ArgumentList "modify", `
820+
"--installPath", "`"$InstallPath`"", `
821+
"--channelId", "https://aka.ms/vs/17/release/channel", `
822+
"--quiet", "--norestart", "--nocache", `
823+
"--add", "Microsoft.VisualStudio.Component.VC.${env:WORKAROUND_WINDOWS_COMPILER_VERSION_PACKAGE}.x86.x64", `
824+
"--add", "Microsoft.VisualStudio.Component.VC.${env:WORKAROUND_WINDOWS_COMPILER_VERSION_PACKAGE}.ATL", `
825+
"--add", "Microsoft.VisualStudio.Component.VC.${env:WORKAROUND_WINDOWS_COMPILER_VERSION_PACKAGE}.ARM64", `
826+
"--add", "Microsoft.VisualStudio.Component.VC.${env:WORKAROUND_WINDOWS_COMPILER_VERSION_PACKAGE}.ATL.ARM64"
827+
$process.WaitForExit()
828+
793829
- name: Build early swift-driver
794830
run: |
795831
$env:SWIFTCI_USE_LOCAL_DEPS=1
796-
$LinkerFlags = if ("${{ matrix.os }}" -eq "Windows") {
797-
@("-Xlinker", "${env:SDKROOT}/usr/lib/swift/windows/${{ matrix.cpu }}/swiftCore.lib")
832+
$ExtraFlags = if ("${{ matrix.os }}" -eq "Windows") {
833+
$Win10SdkRoot = Get-ItemPropertyValue `
834+
-Path "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots" `
835+
-Name "KitsRoot10"
836+
@("-Xlinker", "${env:SDKROOT}/usr/lib/swift/windows/${{ matrix.cpu }}/swiftCore.lib",
837+
"-Xswiftc", "-windows-sdk-version", "-Xswiftc", "${env:WORKAROUND_WINDOWS_SDK_VERSION}",
838+
"-Xswiftc", "-windows-sdk-root", "-Xswiftc", "${Win10SdkRoot}",
839+
"-Xbuild-tools-swiftc", "-windows-sdk-version", "-Xbuild-tools-swiftc", "${env:WORKAROUND_WINDOWS_SDK_VERSION}",
840+
"-Xbuild-tools-swiftc", "-windows-sdk-root", "-Xbuild-tools-swiftc", "${Win10SdkRoot}",
841+
"-Xswiftc", "-visualc-tools-version", "-Xswiftc", "${env:WORKAROUND_WINDOWS_COMPILER_VERSION}",
842+
"-Xbuild-tools-swiftc", "-visualc-tools-version", "-Xbuild-tools-swiftc", "${env:WORKAROUND_WINDOWS_COMPILER_VERSION}",
843+
"-Xcc", "-Xmicrosoft-visualc-tools-version", "-Xcc", "${env:WORKAROUND_WINDOWS_COMPILER_VERSION}",
844+
"-Xcxx", "-Xmicrosoft-visualc-tools-version", "-Xcxx", "${env:WORKAROUND_WINDOWS_COMPILER_VERSION}"
845+
)
798846
} else {
799847
@()
800848
}
@@ -804,7 +852,7 @@ jobs:
804852
--package-path ${{ github.workspace }}/SourceCache/swift-driver `
805853
--build-path ${{ github.workspace }}/BinaryCache/swift-driver `
806854
--triple ${{ matrix.compiler_target }} `
807-
@LinkerFlags
855+
@ExtraFlags
808856
809857
- name: Copy binaries
810858
run: |
@@ -934,11 +982,41 @@ jobs:
934982
echo "PYTHON_LOCATION_amd64=$env:pythonLocation" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
935983
echo "PYTHON_LOCATION_arm64=${{ github.workspace }}\pythonarm64.${{ env.PYTHON_VERSION_WINDOWS }}\tools" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
936984
985+
# This is a workaround for not being able to build with MSVC 14.43.
986+
# See https://github.com/swiftlang/swift/issues/79852 for details.
987+
- name: Install MSVC ${{ env.WORKAROUND_WINDOWS_COMPILER_VERSION }}
988+
if: matrix.os == 'Windows'
989+
run: |
990+
$InstallerLocation = Join-Path "${env:ProgramFiles(x86)}" "Microsoft Visual Studio" "Installer"
991+
$VsWhere = Join-Path "${InstallerLocation}" "vswhere.exe"
992+
$VsInstaller = Join-Path "${InstallerLocation}" "vs_installer.exe"
993+
$InstallPath = (& "$VsWhere" -latest -products * -format json | ConvertFrom-Json).installationPath
994+
$process = Start-Process "$VsInstaller" `
995+
-PassThru `
996+
-ArgumentList "modify", `
997+
"--installPath", "`"$InstallPath`"", `
998+
"--channelId", "https://aka.ms/vs/17/release/channel", `
999+
"--quiet", "--norestart", "--nocache", `
1000+
"--add", "Microsoft.VisualStudio.Component.VC.${env:WORKAROUND_WINDOWS_COMPILER_VERSION_PACKAGE}.x86.x64", `
1001+
"--add", "Microsoft.VisualStudio.Component.VC.${env:WORKAROUND_WINDOWS_COMPILER_VERSION_PACKAGE}.ATL", `
1002+
"--add", "Microsoft.VisualStudio.Component.VC.${env:WORKAROUND_WINDOWS_COMPILER_VERSION_PACKAGE}.ARM64", `
1003+
"--add", "Microsoft.VisualStudio.Component.VC.${env:WORKAROUND_WINDOWS_COMPILER_VERSION_PACKAGE}.ATL.ARM64"
1004+
$process.WaitForExit()
1005+
1006+
# Delete the unsupported directory version in the `Lib` and `Include` directories.
1007+
$Win10SdkRoot = Get-ItemPropertyValue `
1008+
-Path "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots" `
1009+
-Name "KitsRoot10"
1010+
Remove-Item -Path "${Win10SdkRoot}\Lib\${env:UNSUPPORTED_WINDOWS_SDK_VERSION}" -Recurse -Force
1011+
Remove-Item -Path "${Win10SdkRoot}\Include\${env:UNSUPPORTED_WINDOWS_SDK_VERSION}" -Recurse -Force
1012+
9371013
- uses: compnerd/gha-setup-vsdevenv@f1ba60d553a3216ce1b89abe0201213536bc7557 # main
9381014
with:
9391015
host_arch: ${{ inputs.build_arch }}
9401016
components: 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64;Microsoft.VisualStudio.Component.VC.Tools.ARM64'
9411017
arch: ${{ matrix.arch }}
1018+
winsdk: ${{ env.WORKAROUND_WINDOWS_SDK_VERSION }}
1019+
toolset_version: ${{ env.WORKAROUND_WINDOWS_COMPILER_VERSION }}
9421020

9431021
- uses: seanmiddleditch/gha-setup-ninja@96bed6edff20d1dd61ecff9b75cc519d516e6401 # master
9441022
if: inputs.build_os == 'Darwin'
@@ -1235,6 +1313,7 @@ jobs:
12351313
host_arch: ${{ inputs.build_arch }}
12361314
components: 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64;Microsoft.VisualStudio.Component.VC.Tools.ARM64'
12371315
arch: ${{ matrix.arch }}
1316+
winsdk: ${{ env.WORKAROUND_WINDOWS_SDK_VERSION }}
12381317

12391318
- uses: seanmiddleditch/gha-setup-ninja@96bed6edff20d1dd61ecff9b75cc519d516e6401 # master
12401319
if: inputs.build_os == 'Darwin'
@@ -1329,6 +1408,7 @@ jobs:
13291408
host_arch: ${{ inputs.build_arch }}
13301409
components: 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64;Microsoft.VisualStudio.Component.VC.Tools.ARM64'
13311410
arch: ${{ matrix.arch }}
1411+
winsdk: ${{ env.WORKAROUND_WINDOWS_SDK_VERSION }}
13321412

13331413
- uses: seanmiddleditch/gha-setup-ninja@96bed6edff20d1dd61ecff9b75cc519d516e6401 # master
13341414
if: inputs.build_os == 'Darwin'
@@ -1494,6 +1574,7 @@ jobs:
14941574
host_arch: ${{ inputs.build_arch }}
14951575
components: 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64;Microsoft.VisualStudio.Component.VC.Tools.ARM64'
14961576
arch: ${{ matrix.arch }}
1577+
winsdk: ${{ env.WORKAROUND_WINDOWS_SDK_VERSION }}
14971578

14981579
- uses: seanmiddleditch/gha-setup-ninja@96bed6edff20d1dd61ecff9b75cc519d516e6401 # master
14991580
if: inputs.build_os == 'Darwin'
@@ -1635,6 +1716,7 @@ jobs:
16351716
host_arch: ${{ inputs.build_arch }}
16361717
components: 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64;Microsoft.VisualStudio.Component.VC.Tools.ARM64'
16371718
arch: ${{ matrix.arch }}
1719+
winsdk: ${{ env.WORKAROUND_WINDOWS_SDK_VERSION }}
16381720

16391721
- uses: seanmiddleditch/gha-setup-ninja@96bed6edff20d1dd61ecff9b75cc519d516e6401 # master
16401722
if: inputs.build_os == 'Darwin'
@@ -1835,6 +1917,7 @@ jobs:
18351917
host_arch: ${{ inputs.build_arch }}
18361918
components: 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64;Microsoft.VisualStudio.Component.VC.Tools.ARM64'
18371919
arch: ${{ matrix.arch }}
1920+
winsdk: ${{ env.WORKAROUND_WINDOWS_SDK_VERSION }}
18381921

18391922
- run: |
18401923
$RTLPath = cygpath -w ${{ github.workspace }}/BinaryCache/Library/Developer/Platforms/Windows.platform/Developer/SDKs/Windows.sdk/usr/bin
@@ -2126,6 +2209,7 @@ jobs:
21262209
host_arch: ${{ inputs.build_arch }}
21272210
components: 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64;Microsoft.VisualStudio.Component.VC.Tools.ARM64'
21282211
arch: ${{ matrix.arch }}
2212+
winsdk: ${{ env.WORKAROUND_WINDOWS_SDK_VERSION }}
21292213

21302214
# FIXME(compnerd): workaround CMake 3.29-3.30 issue
21312215
- uses: lukka/get-cmake@aa1df13cce8c30d2cb58efa871271c5a764623f8 # main
@@ -2647,6 +2731,7 @@ jobs:
26472731
host_arch: ${{ inputs.build_arch }}
26482732
components: 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64;Microsoft.VisualStudio.Component.VC.Tools.ARM64'
26492733
arch: ${{ matrix.arch }}
2734+
winsdk: ${{ env.WORKAROUND_WINDOWS_SDK_VERSION }}
26502735

26512736
- run: |
26522737
Move-Item ${env:SDKROOT}/usr/lib/swift/dispatch ${env:SDKROOT}/usr/include/
@@ -3253,6 +3338,7 @@ jobs:
32533338
host_arch: amd64
32543339
components: 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64;Microsoft.VisualStudio.Component.VC.Tools.ARM64'
32553340
arch: ${{ matrix.arch }}
3341+
winsdk: ${{ env.WORKAROUND_WINDOWS_SDK_VERSION }}
32563342

32573343
- run: |
32583344
Move-Item ${env:SDKROOT}/usr/lib/swift/dispatch ${env:SDKROOT}/usr/include/
@@ -3358,6 +3444,7 @@ jobs:
33583444
host_arch: ${{ inputs.build_arch }}
33593445
components: 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64;Microsoft.VisualStudio.Component.VC.Tools.ARM64'
33603446
arch: ${{ matrix.arch }}
3447+
winsdk: ${{ env.WORKAROUND_WINDOWS_SDK_VERSION }}
33613448

33623449
- run: |
33633450
$CertificatePath = Join-Path -Path ${env:RUNNER_TEMP} -ChildPath CodeSign.b64
@@ -3540,6 +3627,7 @@ jobs:
35403627
host_arch: ${{ inputs.build_arch }}
35413628
components: 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64;Microsoft.VisualStudio.Component.VC.Tools.ARM64'
35423629
arch: ${{ matrix.arch }}
3630+
winsdk: ${{ env.WORKAROUND_WINDOWS_SDK_VERSION }}
35433631

35443632
- run: |
35453633
$CertificatePath = Join-Path -Path ${env:RUNNER_TEMP} -ChildPath CodeSign.b64
@@ -3658,6 +3746,7 @@ jobs:
36583746
host_arch: ${{ inputs.build_arch }}
36593747
components: 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64;Microsoft.VisualStudio.Component.VC.Tools.ARM64'
36603748
arch: ${{ matrix.arch }}
3749+
winsdk: ${{ env.WORKAROUND_WINDOWS_SDK_VERSION }}
36613750

36623751
- run: |
36633752
$CertificatePath = Join-Path -Path ${env:RUNNER_TEMP} -ChildPath CodeSign.b64
@@ -3795,6 +3884,7 @@ jobs:
37953884
host_arch: ${{ inputs.build_arch }}
37963885
components: 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64;Microsoft.VisualStudio.Component.VC.Tools.ARM64'
37973886
arch: ${{ matrix.arch }}
3887+
winsdk: ${{ env.WORKAROUND_WINDOWS_SDK_VERSION }}
37983888

37993889
- run: |
38003890
$CertificatePath = Join-Path -Path ${env:RUNNER_TEMP} -ChildPath CodeSign.b64

0 commit comments

Comments
 (0)