@@ -5,13 +5,17 @@ use rustc_codegen_ssa::errors::TargetFeatureDisableOrEnable;
55use rustc_data_structures:: fx:: FxHashMap ;
66use rustc_data_structures:: unord:: UnordSet ;
77use rustc_session:: Session ;
8+ use rustc_session:: features:: { StabilityExt , retpoline_features_by_flags} ;
89use rustc_target:: target_features:: RUSTC_SPECIFIC_FEATURES ;
910use smallvec:: { SmallVec , smallvec} ;
1011
11- use crate :: errors:: {
12- ForbiddenCTargetFeature , PossibleFeature , UnknownCTargetFeature , UnknownCTargetFeaturePrefix ,
13- UnstableCTargetFeature ,
14- } ;
12+ use crate :: errors:: { PossibleFeature , UnknownCTargetFeature , UnknownCTargetFeaturePrefix } ;
13+
14+ fn gcc_features_by_flags ( sess : & Session ) -> Vec < & str > {
15+ let mut features: Vec < & str > = Vec :: new ( ) ;
16+ retpoline_features_by_flags ( sess, & mut features) ;
17+ features
18+ }
1519
1620/// The list of GCC features computed from CLI flags (`-Ctarget-cpu`, `-Ctarget-feature`,
1721/// `--target` and similar).
@@ -45,7 +49,7 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri
4549
4650 // Compute implied features
4751 let mut all_rust_features = vec ! [ ] ;
48- for feature in sess. opts . cg . target_feature . split ( ',' ) {
52+ for feature in sess. opts . cg . target_feature . split ( ',' ) . chain ( gcc_features_by_flags ( sess ) ) {
4953 if let Some ( feature) = feature. strip_prefix ( '+' ) {
5054 all_rust_features. extend (
5155 UnordSet :: from ( sess. target . implied_target_features ( feature) )
@@ -94,18 +98,7 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri
9498 sess. dcx ( ) . emit_warn ( unknown_feature) ;
9599 }
96100 Some ( & ( _, stability, _) ) => {
97- if let Err ( reason) = stability. toggle_allowed ( ) {
98- sess. dcx ( ) . emit_warn ( ForbiddenCTargetFeature {
99- feature,
100- enabled : if enable { "enabled" } else { "disabled" } ,
101- reason,
102- } ) ;
103- } else if stability. requires_nightly ( ) . is_some ( ) {
104- // An unstable feature. Warn about using it. (It makes little sense
105- // to hard-error here since we just warn about fully unknown
106- // features above).
107- sess. dcx ( ) . emit_warn ( UnstableCTargetFeature { feature } ) ;
108- }
101+ stability. verify_feature_enabled_by_flag ( sess, enable, feature) ;
109102 }
110103 }
111104
0 commit comments