Skip to content

Adding cross-compilation support for Windows on Arm #32582

Closed
@richard-townsend-arm

Description

@richard-townsend-arm

Is your feature request related to a problem? Please describe.
Follow on #25998 (Support ARM64 Windows Desktop).

The current solution to build for Windows on Arm is to build on the device itself due to host-only tools (e.g. mksnapshot) in the build process. Catch is that because Microsoft have not (yet) released a native toolchain for Windows on Arm, building Node.js is hard because you have to use an x86 toolchain running under emulation, which is slow and bumps up against 32-bit memory limitations. As a result, the Windows on Arm build has bit-rotted and doesn't currently build out of the box.

Describe the solution you'd like
To make Windows on Arm easier to support, I'd like to add cross-compilation support to node-gyp and teach Node.js' build system how to cross-compile for Arm. GYP already makes the distinction between host and target, so the idea is to generate two versions of some projects:
image

Each host target is renamed to produce a _host.exe. Each action is then re-written to call the _host.exe version, so e.g. actions which involve mksnapshot.exe are fixed up to call mksnapshot_host.exe instead. These host-only targets need to be built for x64, so we introduce a host-only node_host.sln which is built first. Then, node.sln (which contains both host and target projects) is built for ARM64. I'd also like to backport some recent V8 changes which fix support for MSVC (Microsoft's compiler) on Arm systems.

Describe alternatives you've considered
Some possible alternatives are:

  • Continue trying to build on-device connecting devices to Node.js' build infrastructure.
  • Continue trying to build on-device using a pre-built, native Clang toolchain.

The second option is quite viable, but risks introducing ABI issues for native modules and would still require changes to node-gyp.

CC @jkunkee, @refack, if you're happy with the general outline of this approach, I'll clean up my patches, get them through internal review and open some PRs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    armIssues and PRs related to the ARM platform.buildIssues and PRs related to build files or the CI.windowsIssues and PRs related to the Windows platform.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions