cfg_target_feature

Function cfg_target_feature 

Source
pub fn cfg_target_feature(
    sess: &Session,
    target_base_has_feature: impl FnMut(&str) -> bool,
) -> (Vec<Symbol>, Vec<Symbol>)
Expand description

Utility function for a codegen backend to compute cfg(target_feature), or more specifically, to populate sess.unstable_target_features and sess.target_features (these are the first and 2nd component of the return value, respectively).

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.