# Windows ARM64EC support

**URL:** <https://internals.rust-lang.org/t/windows-arm64ec-support/14949>\
**Category:** compiler\
**Created:** [June 29, 2021, 6:36pm UTC](https://internals.rust-lang.org/t/windows-arm64ec-support/14949 "2021-06-29T18:36:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alovchin91](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/alovchin91/32/8311_2.png) [@Alovchin91](https://internals.rust-lang.org/u/Alovchin91)\
**Post date:** [June 29, 2021, 6:36pm UTC](https://internals.rust-lang.org/t/windows-arm64ec-support/14949/1 "2021-06-29T18:36:37Z")

</div>

Hi Rust team,

Microsoft has just announced [ARM64EC](https://blogs.windows.com/windowsdeveloper/2021/06/28/announcing-arm64ec-building-native-and-interoperable-apps-for-windows-11-on-arm/) - a new binary format that carries ARM64 native code but has x64 ABI, thus allowing ARM64 native binaries reference x64 emulated ones. (that's my understanding 😬)

I'd like to ask, does `rustc` need a new toolchain to support ARM64EC, or is it possible to use the existing `aarch64-pc-windows-msvc` toolchain?

If it needs a new toolchain, I would like to help build it. Are there any resources on adding a new toolchain to the compiler?

Thanks!

---

<div class="post-metadata">

**Author:** ![josh](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/josh/32/5934_2.png) [@josh](https://internals.rust-lang.org/u/josh)\
**Post date:** [June 29, 2021, 6:51pm UTC](https://internals.rust-lang.org/t/windows-arm64ec-support/14949/2 "2021-06-29T18:51:25Z")

</div>

In theory, it'd be possible to have an `extern "arm64ec" fn` the same way we have `extern "stdcall" fn`. We don't have to have a separate target for calling functions differently.

However, if this changes the required signature of `extern "C"`, or the required signature or calling convention of the program entry point, or the sizes or alignments of types, it'd probably be easiest to use a new target.

---

<div class="post-metadata">

**Author:** ![bjorn3](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/bjorn3/32/2736_2.png) [@bjorn3](https://internals.rust-lang.org/u/bjorn3)\
**Post date:** [June 29, 2021, 7:00pm UTC](https://internals.rust-lang.org/t/windows-arm64ec-support/14949/3 "2021-06-29T19:00:14Z")

</div>

> [@josh](#):
>
> or the sizes or alignments of types

I would guess it does. As far as I understand ARM64EC is basically the x86\_64 abi for windows changed to use aarch64 registers instead. It uses the same **type** and stack layouts.

It may also be necessary to mark the object files as targeting the ARM64EC abi to allow windows to link it (statically or dynamically) with x86\_64 code.

---

<div class="post-metadata">

**Author:** ![Alovchin91](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/alovchin91/32/8311_2.png) [@Alovchin91](https://internals.rust-lang.org/u/Alovchin91)\
**Post date:** [June 29, 2021, 7:15pm UTC](https://internals.rust-lang.org/t/windows-arm64ec-support/14949/4 "2021-06-29T19:15:12Z")

</div>

I don't know much about how it's implemented but from my understanding there is no new calling convention (please pardon my ignorance):

> Specifically, the ARM64EC ABI follows x64 software conventions including calling convention, stack usage, and data alignment, making ARM64EC and x64 interoperable.

This is implemented, apparently, by a single compiler flag which is `/MACHINE:ARM64EC`. I don't know the specifics of this magic but it's aimed at developers who would like to gradually migrate their code to support arm64, thus allowing them (us) to keep using x64 libraries from arm64 code without changing those x64 libraries (as far as I understand).

Thus I don't think there is a need for a new calling convention in Rust but rather a toolchain that passes necessary flags to the compiler. The question is - is there a need for a new toolchain at all? 🤔

---

<div class="post-metadata">

**Author:** ![bjorn3](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/bjorn3/32/2736_2.png) [@bjorn3](https://internals.rust-lang.org/u/bjorn3)\
**Post date:** [June 29, 2021, 8:06pm UTC](https://internals.rust-lang.org/t/windows-arm64ec-support/14949/5 "2021-06-29T20:06:44Z")

</div>

> [@Alovchin91](#):
>
> I don't know much about how it's implemented but from my understanding there is no new calling convention (please pardon my ignorance):

There is. On AArch64 normally the AArch64 calling convention is used. What ARM64EC does is instead take the calling convention from x86\_64 and remap it onto AArch64 registers. This is fundamentally incompatible with the AArch64 calling convention, but makes translation of x86\_64 code to this calling convention trivial.

The compiler flag causes a different calling convention to be used and likely a different object file architecture specification or something like that. The latter prevents ARM64 and ARM64EC code from being linked against each other, so it has to be a new target triple.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/system/32/14092_2.png) [@system](https://internals.rust-lang.org/u/system)\
**Post date:** [September 27, 2021, 8:07pm UTC](https://internals.rust-lang.org/t/windows-arm64ec-support/14949/6 "2021-09-27T20:07:28Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
