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

target-feature detection run-time #366

Open
gnzlbg opened this issue Jul 16, 2019 · 1 comment
Open

target-feature detection run-time #366

gnzlbg opened this issue Jul 16, 2019 · 1 comment

Comments

@gnzlbg
Copy link

gnzlbg commented Jul 16, 2019

I've submitted an RFC (rust-lang/rfcs#2725) that allows #![no_std] applications to use the target-feature detection macros, and customize the detection run-time. A

For embedded devices, you often know all features available at compile-time, so doing run-time detection is probably moot, unless you want to ship the same binary to different embedded devices, or have an heterogeneous device and want some code to use features of certain cores when available.

Either way, the RFC should cover these use cases, but thought some of you might be interesting in triple-checking that it would work for their use cases as well.

@tarcieri
Copy link

tarcieri commented May 26, 2021

For anyone looking for an interim/stopgap solution for portable CPU feature detection which is at least no_std on x86/x86-64, the RustCrypto Project's cpufeatures crate provides this:

https://github.com/RustCrypto/utils/tree/master/cpufeatures

We also support aarch64, but runtime CPU feature detection on ARM64 requires privileged instructions and thus can only be performed using operating system-provided APIs. We presently support runtime detection of a limited number of CPU features on these platforms (with runtime detection limited to Linux and macOS). If we don't support the feature you're interested in (or you're interested in e.g. 32-bit ARM) please open an issue with a request and we can get it added.

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

No branches or pull requests

2 participants