-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Description
The feature gate for the issue is #![feature(cpuid_target_feature)]
.
Motivation
The x86 CPUID instruction is extremely useful in determining what CPU features are available during runtime. core::arch::x86::__cpuid
and friends are a useful tool to call CPUID without writing the ASM yourself, but these are marked unsafe
, and can't be made safe currently because
- very old CPUs that don't support it
target_env = "sgx"
doesn't support it
So, we introduce a detection-only (no codegen effects) target feature cpuid
, which will guard the core::arch::x86::__cpuid
function and friends. It is implied from all other x86 target features (except for soft-float
), so for most cases __cpuid
will be safe to call, and in general, users will be able to check if it is callable by is_x86_feature_detected!("cpuid")
.
About tracking issues
Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Discussion comments will get marked as off-topic or deleted.
Repeated discussions on the tracking issue may lead to the tracking issue getting locked.
Steps
- Implement the target feature
- Adjust documentation (see instructions on rustc-dev-guide)
- Style updates for any new syntax (nightly-style-procedure)
- Style team decision on new formatting
- Formatting for new syntax has been added to the Style Guide
- (non-blocking) Formatting has been implemented in
rustfmt
- Stabilization PR (see instructions on rustc-dev-guide)
Unresolved Questions
- Should
x87
andsoft-float
implycpuid
?
Implementation history
@rustbot label O-x86_32 O-x86_64 T-libs-api A-target-feature