Skip to content
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

Merged
merged 4 commits into from
Feb 23, 2024

Conversation

dpaoliello
Copy link
Contributor

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.

src/windows/find_tools.rs Outdated Show resolved Hide resolved
src/windows/find_tools.rs Outdated Show resolved Hide resolved
@dpaoliello dpaoliello force-pushed the nativearm64 branch 2 times, most recently from 41f9b14 to 942d416 Compare February 21, 2024 17:43
src/windows/find_tools.rs Outdated Show resolved Hide resolved
src/windows/find_tools.rs Outdated Show resolved Hide resolved
src/windows/find_tools.rs Outdated Show resolved Hide resolved
src/windows/find_tools.rs Outdated Show resolved Hide resolved
@dpaoliello dpaoliello force-pushed the nativearm64 branch 2 times, most recently from 40defd6 to 0b1309a Compare February 22, 2024 22:13
dev-tools/gen-windows-sys-binding/src/main.rs Outdated Show resolved Hide resolved
src/windows/com.rs Outdated Show resolved Hide resolved
src/windows/find_tools.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@NobodyXu NobodyXu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

LGTM

@NobodyXu NobodyXu merged commit 012226e into rust-lang:main Feb 23, 2024
21 checks passed
@dpaoliello dpaoliello deleted the nativearm64 branch February 23, 2024 23:37
@NobodyXu NobodyXu mentioned this pull request Feb 24, 2024
3 tasks
/// 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> {
Copy link

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.

Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants