-
Notifications
You must be signed in to change notification settings - Fork 467
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
Support native ARM64 MSVC toolchain, and fallback to x64 if emulation is available #957
Conversation
41f9b14
to
942d416
Compare
942d416
to
a8586d7
Compare
40defd6
to
0b1309a
Compare
0b1309a
to
bed9e3b
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.
Thanks!
LGTM
/// SAFETY: The caller must ensure that the function signature matches the actual function. | ||
/// The easiest way to do this is to add an entry to windows_sys_no_link.list and use the | ||
/// generated function for `func_signature`. | ||
unsafe fn get_proc_address<F>(&self, name: &[u8]) -> Option<F> { |
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.
This should be tying the lifetime of F to the lifetime of self, if any.
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, opened #1010 to update safety comment for the function.
I can't add lifetime to the return type directly, I can only add bound to the generic F.
However, I don't think we can add lifetime to function pointer, a newtype that dereferences to F would have the same problem since function pointer is copyable, so the only option is to add a safety comment for this unsafe function.
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 #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.