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

cpufeatures: support compiling on non-Linux/macOS aarch64 targets #408

Merged

Conversation

tarcieri
Copy link
Member

ARM CPU feature detection is unfortunately tied to OS APIs, as the registers containing information about CPU features are not accessible to unprivileged userspace programs.

However, the previous setup which gated support on Linux/macOS only means that OS-specific gating needs to be repeated in every downstream consumer of cpufeatures, and also that if support for new environments is added in cpufeatures that downstream consumers don't receive it automatically.

This commit adds a fallback for non-Linux/macOS aarch64 environments, similarly to how we handle SGX, which always returns false unless the corresponding target_feature(s) are explicitly enabled in RUSTFLAGS. This allows cpufeatures to provide the mechanism for target_feature-based gating on these other platforms, even if it can't
provide runtime feature detection support.

ARM CPU feature detection is unfortunately tied to OS APIs, as the
registers containing information about CPU features are not accessible
to unprivileged userspace programs.

However, the previous setup which gated support on Linux/macOS only
means that OS-specific gating needs to be repeated in every downstream
consumer of `cpufeatures`, and also that if support for new environments
is added in `cpufeatures` that downstream consumers don't receive it
automatically.

This commit adds a fallback for non-Linux/macOS aarch64 environments,
similarly to how we handle SGX, which always returns `false` unless the
corresponding `target_feature`(s) are explicitly enabled in `RUSTFLAGS`.
This allows `cpufeatures` to provide the mechanism for
`target_feature`-based gating on these other platforms, even if it can't
provide runtime feature detection support.
@tarcieri tarcieri merged commit 359fd6c into master May 15, 2021
@tarcieri tarcieri deleted the cpufeatres/allow-compiling-on-non-linux-macos-aarch64-targets branch May 15, 2021 15:36
@tarcieri tarcieri mentioned this pull request May 15, 2021
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.

1 participant