msvc-dev-cmd icon indicating copy to clipboard operation
msvc-dev-cmd copied to clipboard

Native ARM support

Open henryiii opened this issue 8 months ago • 4 comments

Does this support the new Windows ARM runners? If so, then the readme should be updated, as it only lists the Intel archs under native. ~~If not, then it should then the readme should be updated. :)~~

(Edit: this does not support native running)

henryiii avatar Apr 17 '25 02:04 henryiii

Hi! I've seen the "windows-11-arm" GitHub runner in About GitHub-hosted runners - GitHub Docs. However, there does not seem to be any instruction about ARM64 native building in Use the Microsoft C++ toolset from the command line | Microsoft Learn. I haven't played with VC++ recently, so please correct me if I'm wrong.

pzhlkj6612 avatar Apr 18 '25 09:04 pzhlkj6612

I think you currently want to use amd64_arm64 if you are on arm64, from what I understand. It's okay to use an emulated compiler targeting the native architecture. Because it works just fine without a large performance issue, there isn't a native build from my undertanding. (More info in https://github.com/pypa/cibuildwheel/issues/2364, I'm just guessing based on that issue plus the above MS learn link) I think the problem is this action is trying to target amd64 from arm64 by default.

henryiii avatar Apr 18 '25 15:04 henryiii

I also noticed the Microsoft documentation page doesn't mention native ARM64, but inspecting the contents of the vcvarsall.bat file for VS2022 reveals:

if /I "%1"=="arm64" (
    set __VCVARSALL_TARGET_ARCH=arm64
    set __VCVARSALL_HOST_ARCH=arm64
    set __local_ARG_FOUND=1
)

I made use of it in a build script and it seemed to work fine. Note that $env:buildArch is something I define manually in my workflow YAML, it's not automatically set.

jdpurcell avatar Apr 18 '25 19:04 jdpurcell

Here is the blog post announcing native arm support in 2022: https://devblogs.microsoft.com/visualstudio/arm64-visual-studio-is-officially-here/. You can also see it referenced in the docs here: https://learn.microsoft.com/en-us/visualstudio/install/visual-studio-on-arm-devices?view=vs-2022. It looks like the installer should automatically tell if you're running arm and use that build from this snippet of the documentation:

With the Visual Studio 2022 version 17.4 release or later, you can access the new native Arm64 MSVC (Microsoft Visual C++) compiler toolset, including C++ Code Analysis, while still targeting all platforms currently supported by MSVC.

I tried:

      - name: Setup MSVC
        uses: ilammy/msvc-dev-cmd@v1
        with:
          arch: arm64

and it seemed to use the arm build of msvc

streetpea avatar Apr 18 '25 20:04 streetpea