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

Run-time feature detection for Aarch64 on Windows. #829

Merged
merged 1 commit into from
Dec 11, 2019

Conversation

makotokato
Copy link
Contributor

Windows has API to detect CPU features for crc32 and ARM crypto extension.

@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @gnzlbg (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@@ -25,6 +25,9 @@ maintenance = { status = "experimental" }
libc = { version = "0.2", optional = true, default-features = false }
cfg-if = "0.1.10"

[target.'cfg(target_os="windows")'.dependencies]
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
[target.'cfg(target_os="windows")'.dependencies]
[target.'cfg(all(target_os = "windows", target_arch = "aarch64"))'.dependencies]

Copy link
Contributor

@gnzlbg gnzlbg left a comment

Choose a reason for hiding this comment

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

Beyond the Cargo.toml nitpick this looks fine to me.

I don't know how complex the implementation of the FFI wrappers for this API is in winapi, but it might speed things up to remove the winapi dependency for now, and re-implementing it ourselves here.

We can then remove that and move towards using winapi in libstd as part of a future refactoring, that only needs to deal with the "organizational" issues of adding a new dependency to the Rust language runtime.

EDIT: the winapi wrapper without the definitions looks quite simple, and we only need to make sure this works for the aarch64 target, so it might be worth it to just copy paste what we need: https://github.com/retep998/winapi-rs/blob/a6dd5510212a2f0f5aae66e60949bd6fdaa0a44d/src/um/processthreadsapi.rs#L337

@makotokato
Copy link
Contributor Author

If I shouldn't use winapi, I remove this, then I add FFI to call Win32 API without winapi.

@gnzlbg
Copy link
Contributor

gnzlbg commented Nov 27, 2019

If I shouldn't use winapi, I remove this, then I add FFI to call Win32 API without winapi.

I think this feature is important, and removing winapi would definitely help landing this faster. After this has landed on rust-lang/rust, you can submit another PR that changes this to use winapi, and we can slowly work out through all organizational issues - that would usually take on the order of weeks if an FCP turns out to be required.

Copy link
Contributor

@gnzlbg gnzlbg left a comment

Choose a reason for hiding this comment

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

Modulo nitpicks, this looks great!

crates/std_detect/src/detect/os/windows/aarch64.rs Outdated Show resolved Hide resolved
crates/std_detect/src/detect/os/windows/aarch64.rs Outdated Show resolved Hide resolved
@gnzlbg
Copy link
Contributor

gnzlbg commented Dec 11, 2019

Thank you!

@gnzlbg gnzlbg merged commit ef62c8e into rust-lang:master Dec 11, 2019
@makotokato makotokato deleted the windows-aarch64-detection branch December 12, 2019 10:50
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.

5 participants