Skip to content

Add Windows ARM64 build - #299

Open
ndabas wants to merge 4 commits into
google:masterfrom
ndabas:windows-arm64
Open

ndabas wants to merge 4 commits into
google:masterfrom
ndabas:windows-arm64

Conversation

@ndabas

@ndabas ndabas commented Oct 27, 2026

Copy link
Copy Markdown

As the title says -- some notes on the changes:

  • bazelisk.py now allows arm64 on Windows.
  • Third-party fixes for MSVC on ARM64:
    • zlib and dav1d are built using clang-cl to enable NEON SIMD optimizations on ARM64. (Everything else is still on MSVC.)
      • New pieces: the --//:windows_arm64_clang_cl_simd flag in BUILD.bazel, the cc_platform_transition.bzl rule, and a clang-cl platform and toolchain in tools/bazel_platforms/BUILD.bazel, registered in WORKSPACE.
    • libaom: the -march flags are no longer passed to MSVC.
    • aws_checksums: /arch:arm8.1 is corrected to /arch:armv8.1.
  • CI cache keys now include runner.arch.
  • c-blosc: win32/pthread.c is now only included into blosc.c (via textual_hdrs), not also compiled on its own. It used to be compiled twice, with the duplicate symbols silently tolerated. Now it's compiled once with the same code.
  • dav1d: public dav1d now wraps a private dav1d_impl No change for users of the public label. Anything that pointed at dav1d's internal targets would need updating.
  • dav1d: clang-cl now gets MSVC-style compiler options. It previously got GCC-style flags.
  • zlib: cpu_features.h declared for all builds; Windows-aware defines for the portable path. No behavior change on x64, Linux or macOS. It also fixes a missing header on other non-SIMD platforms.
  • clang-cl toolchain registered in WORKSPACE. Bazel only looks it up when the flag is on. Projects that use TensorStore as a dependency don't get the registration, but the flag is off by default.
  • bazelisk.py patch -- This vendored file now differs from upstream bazelisk, so re-apply the patch if you update it.

Linux, macOS and x86_64 Windows otherwise build the same sources with the same flags, and their CI jobs passed as well.

Some other fixes:

  • clang-cl warnings: setup.py now passes /d2FH4- as --cxxopt instead of --copt. The flag only affects C++ exception handling, so MSVC builds of C++ are unchanged. zlib and dav1d are C, so clang-cl no longer sees the flag.
  • Windows doctest_test targets (all 7 now pass): Bazel's Python test wrapper uses a venv holding only a symlink to python.exe. Windows can't find python314.dll from there, so Python exited with STATUS_DLL_NOT_FOUND. In local_runtime_repo_setup.bzl, the local Python runtime now sets supports_build_time_venv = False on Windows only. rules_python then creates the venv at runtime and links in Python's DLLs. Linux and macOS are unchanged.
  • variable_substitution_test: It built its paths with backslashes and mixed Windows and posix path types, while the real code uses native path types. I fixed the fixture in variable_substitution_test.py. On Linux the changes do nothing, and all bazel_to_cmake tests now pass.
  • CMake NASM: a new may_target_x86() in platforms.py enables ASM_NASM only when targeting x86, like the existing MSVC-only check for ASM_MASM. Unrecognized processor names keep NASM enabled, so other platforms are unaffected.
    • NASM can only produce x86 code, so on non-x86 processors rules_nasm.py generates them as empty libraries.
    • Golden tests can now override CMake variables in config.json. A new rules_nasm_arm64 golden test covers the ARM64 output, and the existing x86 golden output is unchanged.
    • Result: a configure on Windows ARM64 succeeds with no NASM installed.

@laramiel

Copy link
Copy Markdown
Collaborator

I don't think that we're going to do continuous builds internally on windows + arm64. I'll probably take some patches to make it easier.

zlib and dav1d are built using clang-cl to enable NEON SIMD optimizations on ARM64. (Everything else is still on MSVC.)

If you have clang-cl, why build the rest with msvc? It might be useful if we support clang-cl generally instead of mingw-gcc.

copybara-service Bot pushed a commit that referenced this pull request Oct 28, 2026
PR #299 (contributed by
Nikhil Dabas) requests Windows + ARM64 builds. We're not ready to
do that on our continuous build pipeline, but some of the changes/fixes
are reasonable to adopt. Additional cleanups added:

- `aws_checksums`: Fix MSVC ARM64 flag typo (`/arch:arm8.1` ->
  `/arch:armv8.1`).

- `libaom`: Gate `-march=armv8*` compiler flags behind non-MSVC so
  `cl.exe` does not receive unrecognized GCC architecture flags.

- `c-blosc`: Move `blosc/win32/pthread.c` from `srcs` to
  `textual_hdrs` in `:win32` since `blosc/blosc.c` `#include`s it
   directly on Windows, avoiding duplicate compilation.

- `dav1d`, `zlib`, `libaom`, `zstd`, `aws_checksums`, `aws_c_common`,
  and `libpng`: Fall back to portable C implementations on MSVC ARM64
  (`cl.exe` cannot assemble GNU-syntax ARM64 assembly in `dav1d` or
  compile GCC-specific ARM64 SIMD in Chromium `zlib`), declare
  `cpu_features.h` in `zlib` `hdrs` for non-SIMD builds, and
  standardize architecture/compiler selection on
  `:use_{x86,arm64}_{gcc,msvc}`.

- `setup.py`: Pass `/d2FH4-` via `--cxxopt` instead of `--copt` so C
  translation units compiled with `clang-cl` do not warn on a C++-only
  exception handling flag.

- `local_runtime_repo_setup.bzl`: Disable `supports_build_time_venv` on
  Windows so `rules_python` links interpreter DLLs (`python3XX.dll`)
  into runtime venvs, fixing `STATUS_DLL_NOT_FOUND` in `doctest_test`
  targets.

- `bazel_to_cmake`: Add `("Windows", "ARM64")` platform mapping and
  `may_target_x86()` so `ASM_NASM` is not enabled and `nasm_library` /
  `nasm_cc_library` emit empty/header-only targets when targeting
  known non-x86 processors; normalize path types in
  `variable_substitution_test.py` for Windows.

- `bazelisk.py`: Allow `arm64` on Windows for Bazel >= 5.4.0.

PiperOrigin-RevId: 1008950701
Change-Id: If338d65f53a769f4f344708970af6fb29845610c
@laramiel

Copy link
Copy Markdown
Collaborator

If you can rebase off e24c768 I'll look and see what else I can adopt

@ndabas

ndabas commented Oct 28, 2026

Copy link
Copy Markdown
Author

Excellent, thanks, I'll do that tonight and can also look into building everything with clang-cl.

@ndabas
ndabas force-pushed the windows-arm64 branch 2 times, most recently from 02eca53 to 2d998eb Compare October 29, 2026 09:34
@ndabas

ndabas commented Oct 29, 2026

Copy link
Copy Markdown
Author

I have rebased on the commit you specified, and have moved the entire Windows ARM64 build to clang-cl, which required a couple of minor fixes. Everything will still build with MSVC for local developer workflows if needed.

@laramiel

laramiel commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator

I've added more clang-cl build config pieces.
13c24dd

@ndabas

ndabas commented Nov 6, 2026

Copy link
Copy Markdown
Author

Great, thanks -- I removed the commit and other pieces that have been merged with that, and rebased. Let me know how you'd like to proceed with the rest.

This branch has not been deployed

No deployments
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