positron icon indicating copy to clipboard operation
positron copied to clipboard

R: Native support for ARM64 R on ARM64 builds of Windows

Open jmcphers opened this issue 1 year ago • 3 comments

R 4.4.0 adds experimental native binaries for ARM64 Windows:

https://blog.r-project.org/2024/04/23/r-on-64-bit-arm-windows/

As we already do on macOS, we should build a variant of ARK for ARM64 that can work natively with the matching architecture of R.

Windows doesn't support "universal" binaries, so this implies we'll likely need to ship two different ark.exe files on Windows, one x86-64 and one arm64, and match the binary to the version of R the user is using. Since it is possible (via emulation) to run x86-64 R on arm64 Windows, it is possible that a Windows machine could have several installations of R with differing architectures.

jmcphers avatar Apr 30 '24 00:04 jmcphers

I think this will also have implications for our R installation discovery code. Relevant bits of the blog post that caught my eye:

The directory layout is slightly different, because R “sub-architectures” are not used. Hence, e.g. Rgui.exe is located directly in bin, while it is in bin/x64 on x86_64.

R is by default installed to Program Files/R-aarch64 (unlike Program Files/R with an x86_64 build) and the default library directory is named aarch64-library (unlike win-library with an x86_64 build). This is to allow side-by-side installation with the x86_64 build, which can run on Windows/aarch64 via emulation.

jennybc avatar Apr 30 '24 15:04 jennybc

👍 for ARM builds on Windows for the macOS Parallel users out there!

coatless avatar Jun 28 '24 05:06 coatless

👍 for Windows ARM builds now that snapdragon x laptops are out (using one right now), and more ARM windows devices are planned for the future.

somethingp avatar Jul 03 '24 14:07 somethingp

First step would be building Ark for Windows ARM and publishing that ark.exe binary in our Ark releases

IIUC the way this works is that GitHub Actions runners are provided at 2 levels

GitHub itself natively hosts this list of runners https://github.com/actions/runner-images?tab=readme-ov-file#available-images

GitHub partners with a 3rd party to provide this list of runners https://github.com/actions/partner-runner-images?tab=readme-ov-file#available-images

As of April 2025, windows-11-arm looks to be publicly available through a 3rd party, I still can't totally tell if that means "totally free with the same usage limits as our native runners" or not.

https://github.blog/changelog/2025-04-14-windows-arm64-hosted-runners-now-available-in-public-preview/

We could try that and see if it magically just works for Ark

If it doesn't, we know how to build for Windows ARM by cross-compiling from Linux using cargo-xwin, which we do for Air, and could probably replicate the idea for Ark https://github.com/posit-dev/air/blob/e11b43d57cdc3b037b0ef6128fb9b7b191a97e42/dist-workspace.toml#L88-L90

DavisVaughan avatar Aug 29 '25 13:08 DavisVaughan

The windows-11-arm runner is working well (it's available for all public repos).

The immediate problem we're running into is that r-hub still doesn't support arm64 Windows (see https://github.com/r-hub/node-rversions/pull/35) which means we can't use rig to set up R, nor the setup-r action, nor the setup-r-dependencies.

Installing R manually is not too bad. It can be downloaded from the temporary location (until support becomes official): https://www.r-project.org/nosvn/winutf8/aarch64/R-4-signed/

There are no binaries for CRAN package so Rtools 4.5 is needed to install the dependencies of our tests. R-hub provides a stable URL: https://github.com/r-hub/rtools45

After installing R and Rtools manually, and adjusting where Ark is looking for R.dll (the folder hierarchy is flatter on arm64) all tests pass successfully without any further changes!

lionel- avatar Oct 06 '25 11:10 lionel-