-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement unwind support for ARM64 Windows #9266
Conversation
11ae3c4
to
76c7e35
Compare
At a high level this looks great, thanks for working on this! We'll probably be trusting you on the particulars of the table format here, and we unfortunately also probably won't be able to run this on CI (unless you know of way to run this and/or emulation on CI). That being said once you're able to run tests locally that's probably a good enough sign for now and should be good to land afterwards. It may also be worth noting that the test failures may not be related to unwinding necessarily, I believe Wasmtime has seen very little testing on Windows ARM64 meaning that there could be little other things here and there to overcome as well. |
24d6330
to
9804955
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made a pass over this code as well and it's generally very high-quality, thanks!
To confirm specifically: does the whole Wasmtime suite (cargo test
in the root) pass now on Windows/aarch64?
Echoing Alex's thoughts -- if we can test this somehow (WINE on qemu-aarch64? or does Windows/x64 support running aarch64 binaries with emulation somehow? or ...?) then we can add release binaries.
(There's precedent for adding release binaries before that, from the macOS/aarch64 case -- we just got GitHub runners for that a few months ago -- though in that case there was external CI run by a third party and those of us with new Macs also manually checked when able.)
const LARGE_STACK_ALLOC_MAX: u32 = (1 << 24) * 16; | ||
match size { | ||
0..SMALL_STACK_ALLOC_MAX => { | ||
unwind_codes.push(UnwindCode::SmallStackAlloc { size: size as u16 }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At least in new code, we're trying to avoid as
-casts; even though here it's infallibly correct, could we write u16::try_from(size).unwrap()
(or .expect("constant max size for this case exceeds u16")
or somesuch so that auditing for overflows is a little easier?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done: removed the as
casts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM modulo one nitpick below
/// The supported unwind codes for the Arm64 Windows ABI. | ||
/// | ||
/// See: <https://learn.microsoft.com/en-us/cpp/build/arm64-exception-handling> | ||
/// Only what is needed to describe the prologues generated by the Cranelift AArch64 ISA are represented here. | ||
#[allow(dead_code)] | ||
#[derive(Clone, Debug, PartialEq, Eq)] | ||
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))] | ||
pub(crate) enum UnwindCode { | ||
/// Save int register, or register pair. | ||
SaveReg { | ||
reg: u8, | ||
stack_offset: u16, | ||
is_pair: bool, | ||
}, | ||
/// Save floating point register, or register pair. | ||
SaveFReg { | ||
reg: u8, | ||
stack_offset: u16, | ||
is_pair: bool, | ||
}, | ||
/// Save frame-pointer register (X29) and LR register pair. | ||
SaveFpLrPair { | ||
stack_offset: u16, | ||
}, | ||
SmallStackAlloc { | ||
size: u16, | ||
}, | ||
MediumStackAlloc { | ||
size: u16, | ||
}, | ||
LargeStackAlloc { | ||
size: u32, | ||
}, | ||
/// PAC sign the LR register. | ||
PacSignLr, | ||
/// Set the frame-pointer register to the stack-pointer register. | ||
SetFp, | ||
/// Set the frame-pointer register to the stack-pointer register with an | ||
/// offset. | ||
AddFp { | ||
offset: u16, | ||
}, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can the names of each of these individual codes match the name in the link above? Specifically SmallStackAlloc
is called alloc_s
there so I'd expect it to be AllocS
here.
Also, it would be nice to have doc comments for the variants that are missing them. For example, the difference between small vs medium stack alloc isn't immediately clear to the reader because they have the same u16
data representation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done: Renamed the alloc items and added a comment to explain the max size of each one.
Correct:
That's a tough one. I've never tried WINE on AArch64 (emulated or physical), so I can't comment on that. Windows x64 can't run AArch64 binaries. GitHub does offer Windows ARM64 runners however the only image available is a clean Windows 11 install (No Visual Studio, no Git, etc.). The lack of an image with pre-installed tools is also blocking making aarch64-pc-windows-msvc a tier 1 Rust target, so it's high on my priority list to get the correct team at GitHub/Microsoft to make and support those images. |
9804955
to
1577f30
Compare
If you're interested @dpaoliello the "fully exhaustive test suite" can be run with I'm also happy to leave this untested on CI until it's easier to set up CI with tools and such. The likelihood of this regressing is relatively low and we can always ping you @dpaoliello (if you're ok with that) if something looks like it's changing. Otherwise I'm also happy to investigate adding ARM64 binaries for Windows to our CI to get release artifacts as well. |
Sure, I'll give it a go. Otherwise, I was starting to look into getting
I'll add it to my list of repos to setup CIs once the Windows ARM64 images are available...
Yes, please! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much!
Looks like this is failing on our MSRV of Rust 1.78:
|
1577f30
to
43926a3
Compare
Fixed |
With bytecodealliance#9266 Wasmtime should have full support for this platform. While not tested in CI it can still be useful to build artifacts nonetheless in case users are interested.
With bytecodealliance#9266 Wasmtime should have full support for this platform. While not tested in CI it can still be useful to build artifacts nonetheless in case users are interested. prtest:full
With bytecodealliance#9266 Wasmtime should have full support for this platform. While not tested in CI it can still be useful to build artifacts nonetheless in case users are interested. prtest:full
With #9266 Wasmtime should have full support for this platform. While not tested in CI it can still be useful to build artifacts nonetheless in case users are interested. prtest:full
Wasmtime recently completed Windows ARM64 support with bytecodealliance/wasmtime#9266 and added release artifacts with bytecodealliance/wasmtime#9283. Fixes bytecodealliance#298
Implements unwind support for ARM64 Windows.
This also fixes an issue with the current AArch64 ABI code where it wasn't emitting unwind instructions when adjusting the stack pointer (i.e., doing a stack alloc).
With this change,
cargo test
passes all tests on my Windows ARM64 device.Fixes #4992