Skip to main content

internal_target_features

Function internal_target_features 

Source
pub fn internal_target_features<'a, const N: usize>(
    sess: &Session,
    to_backend_features: impl Fn(&'a str) -> SmallVec<[&'a str; N]>,
    target_base_has_feature: impl FnMut(&str) -> bool,
) -> UnordSet<Symbol>
Expand description

Utility function for a codegen backend to compute the set of all actually enabled Rust target features (which will be stored in sess.internal_target_features).

to_backend_features converts a Rust feature name into a list of backend feature names; this is used for diagnostic purposes only.

target_base_has_feature should check whether the given feature (a Rust feature name!) is enabled in the “base” target machine, i.e., without applying -Ctarget-feature. Note that LLVM may consider features to be implied that we do not and vice-versa. We want cfg to be entirely consistent with Rust feature implications, and thus only consult LLVM to expand the target CPU to target features.

We do not have to worry about RUSTC_SPECIFIC_FEATURES here, those are handled elsewhere.