Skip to content

Windows CI: building natively on windows-11-arm past MAX_PATH, the Swift runtime, and rules_swift's proto actions - #230

Merged
logan-shire-agent[bot] merged 8 commits into
mainfrom
ci-windows-paths
Nov 16, 2026
Merged

logan-shire-agent[bot] merged 8 commits into
mainfrom
ci-windows-paths

Conversation

@logan-shire-agent

@logan-shire-agent logan-shire-agent Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

A follow-up to #226. container-windows (not a required check) failed on its first run with LNK1181. This changes tools/ci/windows_build.ps1, with comments in two BUILD files and no workflow change. It supersedes #227, which closed when #226's branch was deleted.

container-windows passed on run 43925426116 (head 54ea57d): the Windows Storybook and the headful Storybook test, built natively on windows-11-arm.

What the runner showed, and what changed:

  • Paths past 260 characters: MSVC's lib.exe and link.exe can't open them even with LongPathsEnabled=1; HostX64 and HostARM64 both fail at 283 characters, while LLVM's llvm-lib opens them. Bazel's archive inputs for swift-syntax and swift-protobuf, built for the exec configuration, reach 283 from C:/b/<hash>/execroot/_main, and no shorter output base fits them. So C:\v mirrors Visual Studio, with llvm-lib as its arm64 lib.exe, and BAZEL_VC points there.
  • The target's C and C++ by clang-cl, the exec tools' by MSVC. LLVM's whole toolchain (USE_CLANG_CL) for both fails: rules_swift's tools pass clang-cl -fno-split-cold-code, and its ARM64 backend fails on upb's code. The target side alone builds (SwiftNIO's C compiles with warnings about unknown flags only).
  • The Swift target triple: with clang-cl as the target's cc toolchain, rules_swift took aarch64-pc-windows-msvc from it, for which the SDK has no Swift module. --define=CC_TARGET_TRIPLE=aarch64-unknown-windows-msvc on build and test.
  • The test toolchain: Bazel 9's default test toolchain wants an execution platform with every constraint of the target platform, which the clang-cl platform isn't. --@bazel_tools//tools/test:incompatible_use_default_test_toolchain=false, as windows_tests_on_linux in examples/.bazelrc already has.
  • The Swift runtime's folder goes on PATH (Runtimes\<version>\usr\bin), and Swift Testing's (Library\Testing-<version>\usr\bin).
  • rules_swift, patched in the build's own copy (--override_repository, anchored edits that fail loudly if upstream moves):
    • proto/swift_proto_compiler.bzl runs protoc with no environment, so protoc-gen-swift ends with 0xC0000135 (a DLL not found): both actions get the default shell environment.
    • It runs copy_swift_sources.sh as an executable, which Windows can't start (error 193): the script runs through the shell.
    • It joins --descriptor_set_in with :, which protoc on Windows splits on ;: joined with ; there.
    • swift/toolchains/swift_toolchain.bzl gives XCTest an -I and a -LIBPATH under Library\XCTest-<version>, and Swift Testing, beside it, nothing (no such module 'Testing'): the same two for Library\Testing-<version>.
    • All four belong upstream in rules_swift.

…ift runtime, and rules_swift's proto actions

container-windows failed on its first run (LNK1181). What it took, found
on the runner by probing and by its runs:

- MSVC's lib.exe and link.exe can't open a path past 260 characters even
  with LongPathsEnabled=1 (a probe on windows-11-arm: HostX64 and HostARM64
  alike failed at 283; LLVM's llvm-lib opened it), and Bazel's object paths
  for swift-syntax's and swift-protobuf's exec-tool archives reach 283 from
  C:/b/<hash>/execroot/_main. Shortening can't fit them. LLVM's whole
  toolchain (USE_CLANG_CL) failed: rules_swift's tools pass clang-cl
  -fno-split-cold-code, and its ARM64 backend fails on upb's code. So
  C:\v mirrors Visual Studio by junctions but for
  Tools\MSVC\<version>\bin\HostX64\arm64, copied with lib.exe replaced by
  llvm-lib, and BAZEL_VC points there.
- The Swift runtime's folder (Runtimes\<version>\usr\bin) is put on PATH:
  the arm64 installer doesn't always.
- rules_swift's proto/swift_proto_compiler.bzl runs protoc with no
  environment (protoc-gen-swift then finds no runtime: 0xC0000135) and
  runs copy_swift_sources.sh as an executable, which Windows can't start
  (error 193). The build's copy of rules_swift (--override_repository) gets
  both the default shell environment and the script run by the shell; an
  upstream fix for rules_swift to take.
- A failed build lists what protoc-gen-swift loads and whether PATH has it.
…r Windows

swift.org's Swift for Windows is an assertions build (6.4.2+Asserts),
whose SIL verifiers run on every compile, unlike Linux's and the Mac's.
One stopped the SwiftUI module: "SIL memory lifetime failure" in
_GuideOffset's init (memory is initialized, but shouldn't be). CI's
Windows build passes -sil-verify-none to the target's and the exec tools'
compiles; the finding is reported apart.
The Windows Storybook now builds; its headful build stopped in SwiftNIO's
C (CNIOAtomics: C11 atomics; CNIOWindows.h: __attribute__), which needs
clang, as SwiftPM compiles a package's C on Windows. clang-cl for
everything fails (rules_swift's tools pass it -Xclang=-fno-split-cold-code,
and its ARM64 backend fails on protobuf's upb), so the target platform is
the host with rules_cc's clang-cl constraint (@isomer//tools/windows:
windows_arm64_clang_cl), and clang_cl_for_targets, rules_cc's clang-cl
toolchain asking that constraint of the target rather than of the
execution platform, takes the target's C alone. BAZEL_LLVM names Visual
Studio's LLVM.
…s_cc's clang-cl reports aarch64-pc-windows-msvc, the SDK's modules are aarch64-unknown-windows-msvc's)
…n the host (Bazel 9's default test toolchain found no execution platform for the clang-cl target platform)
…'s in rules_swift's Windows toolchain, its DLLs on PATH (the headful test's import Testing)
@logan-shire-agent
logan-shire-agent Bot marked this pull request as ready for review November 16, 2026 19:42
@logan-shire-agent
logan-shire-agent Bot merged commit eed46dd into main Nov 16, 2026
25 checks passed
@logan-shire-agent
logan-shire-agent Bot deleted the ci-windows-paths branch November 16, 2026 19:42
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.

1 participant