Skip to content

CI: Add a Windows ARM64 build and test workflow - #510

Merged
bashtage merged 2 commits into
mainfrom
wip-ci-windows-arm64
Nov 4, 2026
Merged

bashtage merged 2 commits into
mainfrom
wip-ci-windows-arm64

Conversation

@bashtage

@bashtage bashtage commented Nov 4, 2026 •

Copy link
Copy Markdown
Owner

Adds a GitHub Actions workflow, windows-arm.yml, that builds and tests randomgen on Windows ARM64. It also fixes the two headers that stopped MSVC from compiling for ARM64.

Workflow

  • Runner: windows-11-arm, with Python set up as arm64.
  • Python 3.11, 3.15 and free-threaded 3.14t. Python 3.11 is the oldest version with a Windows ARM64 build, so there is no 3.10 job.
  • Build: pip install -v . -Csetup-args=--vsenv, so meson activates the native ARM64 MSVC toolchain.
  • Tests: pip install --group test, then randomgen.test(['--skip-slow', '-n', 'auto', ...]) from outside the checkout, as linux-arm.yml does.

NumPy 2.5.4, SciPy 1.18.1, Cython 3.3.1 and ninja 1.13.2 all publish win_arm64 wheels for these versions, so only randomgen is compiled.

Fixes. The first run (c0e81e5) failed in ThreeFry with Random123's #error "This code has only been tested on x86 platforms.".

  • src/common/features/msvcfeatures.h (Random123, used by Philox and ThreeFry):
    • _M_ARM64 is now accepted.
    • SSE, CPUID and the SSE headers are used only on x86. They used to be on for every MSVC target.
    • On ARM64, the high half of a 64-bit product comes from __umulh, since _umul128 exists only on x64. So Philox stays 64-bit.
    • The x86 settings are unchanged.
  • src/common/randomgen_endian.h: MSVC on ARM64 defines neither __BYTE_ORDER__ nor _M_X64, so the byte order was not found (#error Unable to determine target endianness, in AES, dSFMT and SFMT). _M_ARM64 and _M_ARM are now treated as little-endian.

The rest of the x86-only code already checks _M_AMD64 or _M_X64 first: _umul128 in PCG64 and LCG128Mix, CPUID, RDRAND and the SIMD paths. MWCX already uses __umulh on _M_ARM64.

Checked locally. There is no MSVC ARM64 compiler on the machine I used. Instead, I compiled all 82 C files of an x64 meson build again with clang-cl --target=aarch64-pc-windows-msvc and the ARM64 flags from the CI log (no /arch:SSE4.2, so no HAVE_SSE2).

  • Before the fix, 13 files failed. After it, every file compiles.
  • With __clang__, __BYTE_ORDER__ and __aarch64__ undefined, so the headers take their MSVC branches, every file compiles except entropy.c. That failure is in windows.h itself and is caused by undefining __clang__; entropy.c has no architecture-specific code.
  • The preprocessor gives R123_USE_SSE 0 and R123_USE_PHILOX_64BIT 1 on ARM64, and mulhilo64 uses __umulh.
  • The x64 MSVC build still succeeds.

Not yet known: whether the tests pass on ARM64. This CI run is the first.

The README badge and the list of tested platforms can follow once the job passes.

🤖 Generated with Claude Code

Build randomgen on the windows-11-arm runner with the native ARM64 MSVC
toolchain (--vsenv), then run the test suite from outside the checkout
so the installed package is the one tested, as linux-arm.yml does.

Test Python 3.11, the oldest version with a Windows ARM64 build, 3.15
and free-threaded 3.14t. NumPy, SciPy, Cython and ninja all publish
win_arm64 wheels for these versions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.80%. Comparing base (77a0e70) to head (1312ffc).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #510   +/-   ##
=======================================
  Coverage   94.80%   94.80%           
=======================================
  Files          56       56           
  Lines        9922     9922           
  Branches      214      214           
=======================================
  Hits         9407     9407           
  Misses        495      495           
  Partials       20       20           
Flag Coverage Δ
adder 94.74% <ø> (ø)
subtractor 94.74% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Random123's MSVC header stopped the build on anything but x86, and
assumed SSE, CPUID and _umul128, none of which exist on ARM64. Accept
_M_ARM64, use SSE, CPUID and the SSE headers only on x86, and take the
high half of 64-bit products from __umulh on ARM64, so Philox stays
64-bit. The x86 settings are unchanged.

randomgen_endian.h could not find the byte order under MSVC on ARM64,
which defines neither __BYTE_ORDER__ nor _M_X64. Treat _M_ARM64 and
_M_ARM as little-endian, as Windows always is.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bashtage
bashtage marked this pull request as ready for review November 4, 2026 19:12
@bashtage
bashtage merged commit 8f56eb6 into main Nov 4, 2026
46 of 47 checks passed
@bashtage
bashtage deleted the wip-ci-windows-arm64 branch November 10, 2026 18:06
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