@@ -16,15 +16,15 @@ use rustc_fs_util::path_to_c_string;
16
16
use rustc_middle:: bug;
17
17
use rustc_session:: Session ;
18
18
use rustc_session:: config:: { PrintKind , PrintRequest } ;
19
+ use rustc_session:: features:: { StabilityExt , retpoline_features_by_flags} ;
19
20
use rustc_span:: Symbol ;
20
21
use rustc_target:: spec:: { MergeFunctions , PanicStrategy , SmallDataThresholdSupport } ;
21
22
use rustc_target:: target_features:: { RUSTC_SPECIAL_FEATURES , RUSTC_SPECIFIC_FEATURES } ;
22
23
use smallvec:: { SmallVec , smallvec} ;
23
24
24
25
use crate :: back:: write:: create_informational_target_machine;
25
26
use crate :: errors:: {
26
- FixedX18InvalidArch , ForbiddenCTargetFeature , PossibleFeature , UnknownCTargetFeature ,
27
- UnknownCTargetFeaturePrefix , UnstableCTargetFeature ,
27
+ FixedX18InvalidArch , PossibleFeature , UnknownCTargetFeature , UnknownCTargetFeaturePrefix ,
28
28
} ;
29
29
use crate :: llvm;
30
30
@@ -707,6 +707,12 @@ pub(crate) fn target_cpu(sess: &Session) -> &str {
707
707
handle_native ( cpu_name)
708
708
}
709
709
710
+ fn llvm_features_by_flags ( sess : & Session ) -> Vec < & str > {
711
+ let mut features: Vec < & str > = Vec :: new ( ) ;
712
+ retpoline_features_by_flags ( sess, & mut features) ;
713
+ features
714
+ }
715
+
710
716
/// The list of LLVM features computed from CLI flags (`-Ctarget-cpu`, `-Ctarget-feature`,
711
717
/// `--target` and similar).
712
718
pub ( crate ) fn global_llvm_features (
@@ -787,7 +793,7 @@ pub(crate) fn global_llvm_features(
787
793
788
794
// Compute implied features
789
795
let mut all_rust_features = vec ! [ ] ;
790
- for feature in sess. opts . cg . target_feature . split ( ',' ) {
796
+ for feature in sess. opts . cg . target_feature . split ( ',' ) . chain ( llvm_features_by_flags ( sess ) ) {
791
797
if let Some ( feature) = feature. strip_prefix ( '+' ) {
792
798
all_rust_features. extend (
793
799
UnordSet :: from ( sess. target . implied_target_features ( feature) )
@@ -840,18 +846,7 @@ pub(crate) fn global_llvm_features(
840
846
sess. dcx ( ) . emit_warn ( unknown_feature) ;
841
847
}
842
848
Some ( ( _, stability, _) ) => {
843
- if let Err ( reason) = stability. toggle_allowed ( ) {
844
- sess. dcx ( ) . emit_warn ( ForbiddenCTargetFeature {
845
- feature,
846
- enabled : if enable { "enabled" } else { "disabled" } ,
847
- reason,
848
- } ) ;
849
- } else if stability. requires_nightly ( ) . is_some ( ) {
850
- // An unstable feature. Warn about using it. It makes little sense
851
- // to hard-error here since we just warn about fully unknown
852
- // features above.
853
- sess. dcx ( ) . emit_warn ( UnstableCTargetFeature { feature } ) ;
854
- }
849
+ stability. verify_feature_enabled_by_flag ( sess, enable, feature) ;
855
850
}
856
851
}
857
852
0 commit comments