cpufeatures: support compiling on non-Linux/macOS aarch64 targets #408
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 incpufeatures
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 correspondingtarget_feature
(s) are explicitly enabled inRUSTFLAGS
. This allowscpufeatures
to provide the mechanism fortarget_feature
-based gating on these other platforms, even if it can'tprovide runtime feature detection support.