Skip to content

Build and test Swift natively on a Windows host#1819

Merged
keith merged 3 commits into
bazelbuild:mainfrom
AttilaTheFun:windows-support
Jul 6, 2026
Merged

Build and test Swift natively on a Windows host#1819
keith merged 3 commits into
bazelbuild:mainfrom
AttilaTheFun:windows-support

Conversation

@AttilaTheFun

@AttilaTheFun AttilaTheFun commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Windows host toolchain support + miscellaneous fixes, part of the #1809 split, on
top of the now-merged foundation PRs #1820 (swift_binary(linkshared)) and #1821
(Swift-SDK framework).

What this adds

Native Windows host toolchain support on the standalone toolchain path (the
<arch>-unknown-windows-msvc triple, MSVC link.exe semantics, auto-configuring
a toolchain from an installed swiftc), plus independent test_observer /
worker fixes (extended-length paths, space-in-path object names, corelibs-xctest
runner) that were bundled into the original combined PR. CI gains a Windows task
building //tools/... + the xplatform examples and running the xctest example.

Open questions

  • MSVC vs. hermetic LLVM: the Windows path assumes an MSVC-compatible linker;
    both link.exe and a hermetic lld-link accept the /ALTERNATENAME /
    /IGNORE:4217 flags used here. I can key the flags off the linker rather than
    the OS if you want it to compose with clang-cl explicitly. (@dzbarsky)
  • Python in swift_autoconfiguration parses the SDK Info.plist (a plist,
    not JSON) in a repository rule. The clean fix is to parse XCTEST_VERSION in
    Starlark and drop Python; I'd do it in a follow-up CI can validate, since I
    can't exercise the Windows path locally. (@dzbarsky)

Comment thread swift/internal/compiling.bzl Outdated
Comment thread swift/internal/swift_autoconfiguration.bzl Outdated
Comment thread swift/internal/swift_autoconfiguration.bzl Outdated
Comment thread swift/internal/swift_autoconfiguration.bzl Outdated
Comment thread swift/internal/swift_autoconfiguration.bzl Outdated
Comment thread swift/internal/swift_autoconfiguration.bzl Outdated
Comment thread swift/toolchains/swift_toolchain.bzl Outdated
Comment thread swift/toolchains/swift_toolchain.bzl Outdated
Comment thread swift/swift_test.bzl
Comment thread swift/toolchains/swift_toolchain.bzl
Builds on the linkshared and Swift SDK framework PRs. Adds native Windows host
toolchain support to the standalone toolchain path (the <arch>-unknown-windows-msvc
triple, MSVC link.exe semantics, auto-configuring a toolchain from an installed
swiftc), plus independent test_observer / worker fixes (extended-length paths,
space-in-path object names, corelibs-xctest runner) that were bundled into the
original combined PR.

CI gains a Windows task building //tools/... and the xplatform examples and
running the xctest example.
- Probe Python interpreters more robustly: drop the in-function nil guard (the
  caller now checks `candidate and ...`), prefer python3-named binaries before
  unsuffixed ones, and confirm the interpreter is Python 3 (the caller needs the
  Python 3 plistlib API), addressing the "could `python` be Python 2?" concern.
- Trim several over-long comments (object-file space sanitization, the Windows
  triple synthesis, the cc-toolchain clang requirement, and the Info.plist /
  ProgramData notes) per review.
Trim the target-triple and clang-carve-out comments per review.

Claude-Session: https://claude.ai/code/session_01SmG1kqA3qB4WsLGU2xavuJ
@keith keith enabled auto-merge (squash) July 6, 2026 17:52
@keith keith merged commit 69751d5 into bazelbuild:main Jul 6, 2026
16 checks passed
@AttilaTheFun AttilaTheFun deleted the windows-support branch July 6, 2026 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants