Skip to content

Commit 0f87b48

Browse files
authored
Overwrite the bootstrap Swift toolchain module maps (#980)
* Following installation of the bootstrap toolchain, this adds a step to update the installed module maps for their upstream versions, which are compatible with the latest Windows SDKs. * As a result, remove the workaround Windows SDK version.
1 parent 6ce60bb commit 0f87b48

File tree

2 files changed

+59
-29
lines changed

2 files changed

+59
-29
lines changed

.github/actions/setup-build/action.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,3 +310,60 @@ runs:
310310
github-token: ${{ github.token }}
311311
release-asset-name: ${{ steps.sanitize-input.outputs.swift-release-asset }}
312312
release-tag-name: ${{ steps.sanitize-input.outputs.swift-release-tag }}
313+
314+
- name: Update Swift toolchain module maps
315+
if: steps.sanitize-input.outputs.build-os == 'windows' && inputs.swift-version != ''
316+
shell: pwsh
317+
run: |
318+
$SwiftBinFolder = Split-Path -Path (Get-Command swift).Source -Parent
319+
$SwiftUsrFolder = Split-Path -Path $SwiftBinFolder -Parent
320+
$SwiftClangIncludeFolder = Join-Path $SwiftUsrFolder "lib" "swift" "clang" "include"
321+
$SwiftClangModuleMap = Join-Path $SwiftClangIncludeFolder "module.modulemap"
322+
curl -s `
323+
-H "Authorization: Bearer ${{ github.token }}" `
324+
https://raw.githubusercontent.com/llvm/llvm-project/main/clang/lib/Headers/module.modulemap `
325+
-o SwiftClangModuleMap
326+
if ($LASTEXITCODE -eq 0) {
327+
Write-Output "ℹ️ Updated Swift Clang module map."
328+
} else {
329+
Write-Output "::error::Failed to update Swift Clang module map. curl failed with exit code $LASTEXITCODE."
330+
exit 1
331+
}
332+
333+
$WindowsSdkShareFolder = Join-Path ${env:SDKROOT} "usr" "share"
334+
335+
$WinSdkModuleMap = Join-Path $WindowsSdkShareFolder "winsdk.modulemap"
336+
curl -s `
337+
-H "Authorization: Bearer ${{ github.token }}" `
338+
https://raw.githubusercontent.com/swiftlang/swift/main/stdlib/public/Platform/winsdk.modulemap `
339+
-o $WinSdkModuleMap
340+
if ($LASTEXITCODE -eq 0) {
341+
Write-Output "ℹ️ Updated Windows SDK module map."
342+
} else {
343+
Write-Output "::error::Failed to update Windows SDK module map. curl failed with exit code $LASTEXITCODE."
344+
exit 1
345+
}
346+
347+
$UCRTModuleMap = Join-Path $WindowsSdkShareFolder "ucrt.modulemap"
348+
curl -s `
349+
-H "Authorization: Bearer ${{ github.token }}" `
350+
https://raw.githubusercontent.com/swiftlang/swift/main/stdlib/public/Platform/ucrt.modulemap `
351+
-o $UCRTModuleMap
352+
if ($LASTEXITCODE -eq 0) {
353+
Write-Output "ℹ️ Updated UCRT module map."
354+
} else {
355+
Write-Output "::error::Failed to update UCRT module map. curl failed with exit code $LASTEXITCODE."
356+
exit 1
357+
}
358+
359+
$VCRuntimeModuleMap = Join-Path $WindowsSdkShareFolder "vcruntime.modulemap"
360+
curl -s `
361+
-H "Authorization: Bearer ${{ github.token }}" `
362+
https://raw.githubusercontent.com/swiftlang/swift/main/stdlib/public/Platform/vcruntime.modulemap `
363+
-o $VCRuntimeModuleMap
364+
if ($LASTEXITCODE -eq 0) {
365+
Write-Output "ℹ️ Updated VCRuntime module map."
366+
} else {
367+
Write-Output "::error::Failed to update VCRuntime module map. curl failed with exit code $LASTEXITCODE."
368+
exit 1
369+
}

.github/workflows/swift-toolchain.yml

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -284,12 +284,9 @@ env:
284284
WORKAROUND_WINDOWS_PINNED_BOOTSTRAP_TOOLCHAIN_REPO: thebrowsercompany/swift-build
285285
WORKAROUND_WINDOWS_PINNED_BOOTSTRAP_TOOLCHAIN_VERSION: 6.0.0-20241216.0
286286

287-
# Workaround for issues with building with SDK version 26100.
288-
# See https://github.com/compnerd/swift-build/issues/909 for details.
289-
WORKAROUND_BOOTSTRAP_WINDOWS_SDK_VERSION: 10.0.22621.0
290-
291287
# Workaround for issues with building with MSVC 14.43.
292288
# See https://github.com/swiftlang/swift/issues/79852 for details.
289+
# TODO: Remove this once the bootstrap toolchain is updated to 6.1.
293290
WORKAROUND_BOOTSTRAP_WINDOWS_MSVC_VERSION: 14.42
294291

295292
defaults:
@@ -317,7 +314,6 @@ jobs:
317314
show-progress: false
318315
- uses: ./SourceCache/ci-build/.github/actions/setup-build
319316
with:
320-
windows-sdk-version: ${{ env.WORKAROUND_BOOTSTRAP_WINDOWS_SDK_VERSION }}
321317
setup-vs-dev-env: true
322318
host-arch: ${{ matrix.arch }}
323319

@@ -389,7 +385,6 @@ jobs:
389385
show-progress: false
390386
- uses: ./SourceCache/ci-build/.github/actions/setup-build
391387
with:
392-
windows-sdk-version: ${{ env.WORKAROUND_BOOTSTRAP_WINDOWS_SDK_VERSION }}
393388
setup-vs-dev-env: true
394389

395390
- uses: actions/[email protected]
@@ -488,8 +483,7 @@ jobs:
488483
- uses: ./SourceCache/ci-build/.github/actions/setup-build
489484
if: inputs.build_android
490485
with:
491-
windows-sdk-version: ${{ env.WORKAROUND_BOOTSTRAP_WINDOWS_SDK_VERSION }}
492-
setup-vs-dev-env: ${{ matrix.os == 'Windows' }}
486+
setup-vs-dev-env: ${{ matrix.os == 'Windows' }}
493487
host-arch: ${{ matrix.arch }}
494488

495489
- uses: actions/[email protected]
@@ -572,7 +566,6 @@ jobs:
572566
show-progress: false
573567
- uses: ./SourceCache/ci-build/.github/actions/setup-build
574568
with:
575-
windows-sdk-version: ${{ env.WORKAROUND_BOOTSTRAP_WINDOWS_SDK_VERSION }}
576569
setup-vs-dev-env: true
577570
host-arch: ${{ matrix.arch }}
578571
- uses: seanmiddleditch/gha-setup-ninja@96bed6edff20d1dd61ecff9b75cc519d516e6401 # master
@@ -648,7 +641,6 @@ jobs:
648641
show-progress: false
649642
- uses: ./SourceCache/ci-build/.github/actions/setup-build
650643
with:
651-
windows-sdk-version: ${{ env.WORKAROUND_BOOTSTRAP_WINDOWS_SDK_VERSION }}
652644
setup-vs-dev-env: true
653645
host-arch: ${{ matrix.arch }}
654646
- uses: seanmiddleditch/gha-setup-ninja@96bed6edff20d1dd61ecff9b75cc519d516e6401 # master
@@ -791,7 +783,6 @@ jobs:
791783
id: setup-build
792784
with:
793785
msvc-version: ${{ env.WORKAROUND_BOOTSTRAP_WINDOWS_MSVC_VERSION }}
794-
windows-sdk-version: ${{ env.WORKAROUND_BOOTSTRAP_WINDOWS_SDK_VERSION }}
795786
host-arch: ${{ matrix.arch }}
796787
swift-version: ${{ inputs.build_os == 'Windows' && env.WORKAROUND_WINDOWS_PINNED_BOOTSTRAP_TOOLCHAIN_VERSION || env.PINNED_BOOTSTRAP_TOOLCHAIN_VERSION }}
797788
swift-repo: ${{ inputs.build_os == 'Windows' && env.WORKAROUND_WINDOWS_PINNED_BOOTSTRAP_TOOLCHAIN_REPO || '' }}
@@ -832,14 +823,7 @@ jobs:
832823
$env:SWIFTCI_USE_LOCAL_DEPS=1
833824
$BuildToolsVersion = "${{ steps.setup-build.outputs.windows-build-tools-version }}"
834825
$ExtraFlags = if ($BuildToolsVersion -ne "") {
835-
$Win10SdkRoot = Get-ItemPropertyValue `
836-
-Path "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Kits\Installed Roots" `
837-
-Name "KitsRoot10"
838826
@("-Xlinker", "${env:SDKROOT}/usr/lib/swift/windows/${{ matrix.cpu }}/swiftCore.lib",
839-
"-Xswiftc", "-windows-sdk-version", "-Xswiftc", "${env:WORKAROUND_BOOTSTRAP_WINDOWS_SDK_VERSION}",
840-
"-Xswiftc", "-windows-sdk-root", "-Xswiftc", "${Win10SdkRoot}",
841-
"-Xbuild-tools-swiftc", "-windows-sdk-version", "-Xbuild-tools-swiftc", "${env:WORKAROUND_BOOTSTRAP_WINDOWS_SDK_VERSION}",
842-
"-Xbuild-tools-swiftc", "-windows-sdk-root", "-Xbuild-tools-swiftc", "${Win10SdkRoot}",
843827
"-Xswiftc", "-visualc-tools-version", "-Xswiftc", "${BuildToolsVersion}",
844828
"-Xbuild-tools-swiftc", "-visualc-tools-version", "-Xbuild-tools-swiftc", "${BuildToolsVersion}",
845829
"-Xcc", "-Xmicrosoft-visualc-tools-version", "-Xcc", "${BuildToolsVersion}",
@@ -911,7 +895,6 @@ jobs:
911895
- uses: ./SourceCache/ci-build/.github/actions/setup-build
912896
with:
913897
msvc-version: ${{ env.WORKAROUND_BOOTSTRAP_WINDOWS_MSVC_VERSION }}
914-
windows-sdk-version: ${{ env.WORKAROUND_BOOTSTRAP_WINDOWS_SDK_VERSION }}
915898
setup-vs-dev-env: true
916899
host-arch: ${{ matrix.arch }}
917900
swift-version: ${{ inputs.build_os == 'Windows' && env.WORKAROUND_WINDOWS_PINNED_BOOTSTRAP_TOOLCHAIN_VERSION || env.PINNED_BOOTSTRAP_TOOLCHAIN_VERSION }}
@@ -1275,7 +1258,6 @@ jobs:
12751258
show-progress: false
12761259
- uses: ./SourceCache/ci-build/.github/actions/setup-build
12771260
with:
1278-
windows-sdk-version: ${{ env.WORKAROUND_BOOTSTRAP_WINDOWS_SDK_VERSION }}
12791261
setup-vs-dev-env: ${{ matrix.os == 'Windows' }}
12801262
host-arch: ${{ matrix.arch }}
12811263
- uses: seanmiddleditch/gha-setup-ninja@96bed6edff20d1dd61ecff9b75cc519d516e6401 # master
@@ -1370,7 +1352,6 @@ jobs:
13701352

13711353
- uses: ./SourceCache/ci-build/.github/actions/setup-build
13721354
with:
1373-
windows-sdk-version: ${{ env.WORKAROUND_BOOTSTRAP_WINDOWS_SDK_VERSION }}
13741355
setup-vs-dev-env: ${{ matrix.os == 'Windows' }}
13751356
host-arch: ${{ matrix.arch }}
13761357
- uses: seanmiddleditch/gha-setup-ninja@96bed6edff20d1dd61ecff9b75cc519d516e6401 # master
@@ -1545,7 +1526,6 @@ jobs:
15451526
show-progress: false
15461527
- uses: ./SourceCache/ci-build/.github/actions/setup-build
15471528
with:
1548-
windows-sdk-version: ${{ env.WORKAROUND_BOOTSTRAP_WINDOWS_SDK_VERSION }}
15491529
setup-vs-dev-env: ${{ matrix.os == 'Windows' }}
15501530
host-arch: ${{ matrix.arch }}
15511531
- uses: seanmiddleditch/gha-setup-ninja@96bed6edff20d1dd61ecff9b75cc519d516e6401 # master
@@ -1647,7 +1627,6 @@ jobs:
16471627
- uses: ./SourceCache/ci-build/.github/actions/setup-build
16481628
if: matrix.os != 'Android' || inputs.build_android
16491629
with:
1650-
windows-sdk-version: ${{ env.WORKAROUND_BOOTSTRAP_WINDOWS_SDK_VERSION }}
16511630
setup-vs-dev-env: ${{ matrix.os == 'Windows' }}
16521631
host-arch: ${{ matrix.arch }}
16531632
swift-version: ${{ inputs.build_os == 'Windows' && env.WORKAROUND_WINDOWS_PINNED_BOOTSTRAP_TOOLCHAIN_VERSION || env.PINNED_BOOTSTRAP_TOOLCHAIN_VERSION }}
@@ -1839,7 +1818,6 @@ jobs:
18391818
show-progress: false
18401819
- uses: ./SourceCache/ci-build/.github/actions/setup-build
18411820
with:
1842-
windows-sdk-version: ${{ env.WORKAROUND_BOOTSTRAP_WINDOWS_SDK_VERSION }}
18431821
setup-vs-dev-env: true
18441822
host-arch: ${{ matrix.arch }}
18451823

@@ -2114,8 +2092,6 @@ jobs:
21142092
- uses: ./SourceCache/ci-build/.github/actions/setup-build
21152093
if: matrix.os != 'Android' || inputs.build_android
21162094
with:
2117-
msvc-version: ${{ env.WORKAROUND_BOOTSTRAP_WINDOWS_MSVC_VERSION }}
2118-
windows-sdk-version: ${{ env.WORKAROUND_BOOTSTRAP_WINDOWS_SDK_VERSION }}
21192095
setup-vs-dev-env: ${{ matrix.os == 'Windows' }}
21202096
host-arch: ${{ matrix.arch }}
21212097

@@ -2659,8 +2635,6 @@ jobs:
26592635
show-progress: false
26602636
- uses: ./SourceCache/ci-build/.github/actions/setup-build
26612637
with:
2662-
msvc-version: ${{ env.WORKAROUND_BOOTSTRAP_WINDOWS_MSVC_VERSION }}
2663-
windows-sdk-version: ${{ env.WORKAROUND_BOOTSTRAP_WINDOWS_SDK_VERSION }}
26642638
setup-vs-dev-env: true
26652639
host-arch: ${{ matrix.arch }}
26662640

@@ -3430,7 +3404,6 @@ jobs:
34303404
show-progress: false
34313405
- uses: ./SourceCache/ci-build/.github/actions/setup-build
34323406
with:
3433-
windows-sdk-version: ${{ env.WORKAROUND_BOOTSTRAP_WINDOWS_SDK_VERSION }}
34343407
setup-vs-dev-env: true
34353408
host-arch: ${{ matrix.arch }}
34363409

0 commit comments

Comments
 (0)