@@ -5,13 +5,17 @@ use rustc_codegen_ssa::errors::TargetFeatureDisableOrEnable;
5
5
use rustc_data_structures:: fx:: FxHashMap ;
6
6
use rustc_data_structures:: unord:: UnordSet ;
7
7
use rustc_session:: Session ;
8
+ use rustc_session:: features:: { StabilityExt , retpoline_features_by_flags} ;
8
9
use rustc_target:: target_features:: RUSTC_SPECIFIC_FEATURES ;
9
10
use smallvec:: { SmallVec , smallvec} ;
10
11
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
+ }
15
19
16
20
/// The list of GCC features computed from CLI flags (`-Ctarget-cpu`, `-Ctarget-feature`,
17
21
/// `--target` and similar).
@@ -45,7 +49,7 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri
45
49
46
50
// Compute implied features
47
51
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 ) ) {
49
53
if let Some ( feature) = feature. strip_prefix ( '+' ) {
50
54
all_rust_features. extend (
51
55
UnordSet :: from ( sess. target . implied_target_features ( feature) )
@@ -94,18 +98,7 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri
94
98
sess. dcx ( ) . emit_warn ( unknown_feature) ;
95
99
}
96
100
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) ;
109
102
}
110
103
}
111
104
0 commit comments