@@ -16,15 +16,15 @@ use rustc_fs_util::path_to_c_string;
1616use rustc_middle:: bug;
1717use rustc_session:: Session ;
1818use rustc_session:: config:: { PrintKind , PrintRequest } ;
19+ use rustc_session:: features:: { StabilityExt , retpoline_features_by_flags} ;
1920use rustc_span:: Symbol ;
2021use rustc_target:: spec:: { MergeFunctions , PanicStrategy , SmallDataThresholdSupport } ;
2122use rustc_target:: target_features:: { RUSTC_SPECIAL_FEATURES , RUSTC_SPECIFIC_FEATURES } ;
2223use smallvec:: { SmallVec , smallvec} ;
2324
2425use crate :: back:: write:: create_informational_target_machine;
2526use crate :: errors:: {
26- FixedX18InvalidArch , ForbiddenCTargetFeature , PossibleFeature , UnknownCTargetFeature ,
27- UnknownCTargetFeaturePrefix , UnstableCTargetFeature ,
27+ FixedX18InvalidArch , PossibleFeature , UnknownCTargetFeature , UnknownCTargetFeaturePrefix ,
2828} ;
2929use crate :: llvm;
3030
@@ -707,6 +707,12 @@ pub(crate) fn target_cpu(sess: &Session) -> &str {
707707 handle_native ( cpu_name)
708708}
709709
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+
710716/// The list of LLVM features computed from CLI flags (`-Ctarget-cpu`, `-Ctarget-feature`,
711717/// `--target` and similar).
712718pub ( crate ) fn global_llvm_features (
@@ -787,7 +793,7 @@ pub(crate) fn global_llvm_features(
787793
788794 // Compute implied features
789795 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 ) ) {
791797 if let Some ( feature) = feature. strip_prefix ( '+' ) {
792798 all_rust_features. extend (
793799 UnordSet :: from ( sess. target . implied_target_features ( feature) )
@@ -840,18 +846,7 @@ pub(crate) fn global_llvm_features(
840846 sess. dcx ( ) . emit_warn ( unknown_feature) ;
841847 }
842848 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) ;
855850 }
856851 }
857852
0 commit comments