Expand description
Declares Rust’s target feature names for each target. Note that these are similar to but not always identical to LLVM’s feature names, and Rust adds some features that do not correspond to LLVM features at all.
The target features listed here can be used in #[target_feature] and #[cfg(target_feature)].
They also do not trigger any warnings when used with -Ctarget-feature.
Note that even unstable (and even entirely unlisted) features can be used with -Ctarget-feature
on stable. Using a feature not on the list of Rust target features only emits a warning.
Only cfg(target_feature) and #[target_feature] actually do any stability gating.
cfg(target_feature) for unstable features just works on nightly without any feature gate.
#[target_feature] requires a feature gate.
When adding features to the below lists check whether they’re named already elsewhere in rust e.g. in stdarch and whether the given name matches LLVM’s if it doesn’t, to_llvm_feature in llvm_util in rustc_codegen_llvm needs to be adapted. Additionally, if the feature is not available in older version of LLVM supported by the current rust, the same function must be updated to filter out these features to avoid triggering warnings.
Also note that all target features listed here must be purely additive: for target_feature 1.1 to
be sound, we can never allow features like +soft-float (on x86) to be controlled on a
per-function level, since we would then allow safe calls from functions with +soft-float to
functions without that feature!
It is important for soundness to consider the interaction of target features and the function
call ABI. For example, disabling the x87 feature on x86 changes how scalar floats are passed as
arguments, so letting people toggle that feature would be unsound. To this end, the
Target::abi_required_features function computes which target features must and must not be
enabled for any given target, and individual features can also be marked as Forbidden. See
https://github.com/rust-lang/rust/issues/116344 for some more context.
The one exception to features that change the ABI is features that enable larger vector
registers. Those are permitted to be listed here. The *_FOR_CORRECT_VECTOR_ABI arrays store
information about which target feature is ABI-required for which vector size; this is used to
ensure that vectors can only be passed via extern "C" when the right feature is enabled. (For
the “Rust” ABI we generally pass vectors by-ref exactly to avoid these issues.)
Also see https://github.com/rust-lang/rust/issues/116558.
Stabilizing a target feature requires t-lang approval.
Structs§
Enums§
- Stability
- Stability information for target features.
Constants§
- AARC
H64_ 🔒FEATURES_ FOR_ CORRECT_ FIXED_ LENGTH_ VECTOR_ ABI - AARC
H64_ 🔒TIED_ FEATURES - AMDGPU_
FEATURES_ 🔒FOR_ CORRECT_ FIXED_ LENGTH_ VECTOR_ ABI - ARM_
FEATURES_ 🔒FOR_ CORRECT_ FIXED_ LENGTH_ VECTOR_ ABI - BPF_
FEATURES 🔒 - CSKY_
FEATURES_ 🔒FOR_ CORRECT_ FIXED_ LENGTH_ VECTOR_ ABI - HEXAGON_
FEATURES 🔒 - HEXAGON_
FEATURES_ 🔒FOR_ CORRECT_ FIXED_ LENGTH_ VECTOR_ ABI - IBMZ_
FEATURES 🔒 - LOONGARCH_
FEATURES_ 🔒FOR_ CORRECT_ FIXED_ LENGTH_ VECTOR_ ABI - MIPS_
FEATURES 🔒 - MIPS_
FEATURES_ 🔒FOR_ CORRECT_ FIXED_ LENGTH_ VECTOR_ ABI - NVPTX_
FEATURES 🔒 - POWERPC_
FEATURES_ 🔒FOR_ CORRECT_ FIXED_ LENGTH_ VECTOR_ ABI - RISCV_
FEATURES_ 🔒FOR_ CORRECT_ FIXED_ LENGTH_ VECTOR_ ABI - RUSTC_
SPECIFIC_ FEATURES - Features that control behaviour of rustc, rather than the codegen. These exist globally and are not in the target-specific lists below.
- S390X_
FEATURES_ 🔒FOR_ CORRECT_ FIXED_ LENGTH_ VECTOR_ ABI - SPARC_
FEATURES 🔒 - SPARC_
FEATURES_ 🔒FOR_ CORRECT_ FIXED_ LENGTH_ VECTOR_ ABI - WASM_
FEATURES_ 🔒FOR_ CORRECT_ FIXED_ LENGTH_ VECTOR_ ABI - X86_
FEATURES_ 🔒FOR_ CORRECT_ FIXED_ LENGTH_ VECTOR_ ABI - XTENSA_
FEATURES 🔒
Statics§
- AARC
H64_ 🔒FEATURES - ARM_
FEATURES 🔒 - AVR_
FEATURES 🔒 - CSKY_
FEATURES 🔒 - LOONGARCH_
FEATURES 🔒 - M68K_
FEATURES 🔒 - POWERPC_
FEATURES 🔒 - RISCV_
FEATURES 🔒 - WASM_
FEATURES 🔒 - X86_
FEATURES 🔒
Functions§
- all_
rust_ features - When rustdoc is running, provide a list of all known features so that all their respective primitives may be documented.
Type Aliases§
- Implied
Features 🔒 - If feature A “implies” feature B, then: