rust-lang / cc-rs

Rust library for build scripts to compile C/C++ code into a Rust library
https://docs.rs/cc
Apache License 2.0
1.86k stars 445 forks source link

Support native ARM64 MSVC toolchain, and fallback to x64 if emulation is available #957

Closed dpaoliello closed 8 months ago

dpaoliello commented 8 months ago

VS 17.4 introduced a native ARM64 toolchain (https://devblogs.microsoft.com/visualstudio/arm64-visual-studio-is-officially-here/), and Windows 11 supports running x64 binaries on ARM64 devices.

As such, we should try to use the ARM64 toolchain if it is available, fallback to x64 if support is available on the device (as performance is better than x86) and use x86 as a last resort.

This supersedes https://github.com/rust-lang/cc-rs/pull/732 (but thanks to @Alovchin91 for working on that PR, as it is the basis for this PR).

Tested on a Surface Pro X running Windows 11.