@@ -34,6 +34,9 @@ pub enum Stability {
3434 /// particular for features are actually ABI configuration flags (not all targets are as nice as
3535 /// RISC-V and have an explicit way to set the ABI separate from target features).
3636 Forbidden { reason : & ' static str } ,
37+ /// This feature can not be set via `-Ctarget-feature` or `#[target_feature]`, it can only be set
38+ /// by target modifier flag. Target modifier flags are tracked to be consistent in linked modules.
39+ TargetModifierOnly { reason : & ' static str , flag : & ' static str } ,
3740}
3841use Stability :: * ;
3942
@@ -49,6 +52,7 @@ impl<CTX> HashStable<CTX> for Stability {
4952 Stability :: Forbidden { reason } => {
5053 reason. hash_stable ( hcx, hasher) ;
5154 }
55+ Stability :: TargetModifierOnly { .. } => { }
5256 }
5357 }
5458}
@@ -74,16 +78,7 @@ impl Stability {
7478 Stability :: Unstable ( nightly_feature) => Some ( nightly_feature) ,
7579 Stability :: Stable { .. } => None ,
7680 Stability :: Forbidden { .. } => panic ! ( "forbidden features should not reach this far" ) ,
77- }
78- }
79-
80- /// Returns whether the feature may be toggled via `#[target_feature]` or `-Ctarget-feature`.
81- /// (It might still be nightly-only even if this returns `true`, so make sure to also check
82- /// `requires_nightly`.)
83- pub fn toggle_allowed ( & self ) -> Result < ( ) , & ' static str > {
84- match self {
85- Stability :: Forbidden { reason } => Err ( reason) ,
86- _ => Ok ( ( ) ) ,
81+ Stability :: TargetModifierOnly { .. } => None ,
8782 }
8883 }
8984}
@@ -453,6 +448,30 @@ static X86_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
453448 ( "prfchw" , Unstable ( sym:: prfchw_target_feature) , & [ ] ) ,
454449 ( "rdrand" , Stable , & [ ] ) ,
455450 ( "rdseed" , Stable , & [ ] ) ,
451+ (
452+ "retpoline-external-thunk" ,
453+ Stability :: TargetModifierOnly {
454+ reason : "use `retpoline-external-thunk` target modifier flag instead" ,
455+ flag : "retpoline-external-thunk" ,
456+ } ,
457+ & [ ] ,
458+ ) ,
459+ (
460+ "retpoline-indirect-branches" ,
461+ Stability :: TargetModifierOnly {
462+ reason : "use `retpoline` target modifier flag instead" ,
463+ flag : "retpoline" ,
464+ } ,
465+ & [ ] ,
466+ ) ,
467+ (
468+ "retpoline-indirect-calls" ,
469+ Stability :: TargetModifierOnly {
470+ reason : "use `retpoline` target modifier flag instead" ,
471+ flag : "retpoline" ,
472+ } ,
473+ & [ ] ,
474+ ) ,
456475 ( "rtm" , Unstable ( sym:: rtm_target_feature) , & [ ] ) ,
457476 ( "sha" , Stable , & [ "sse2" ] ) ,
458477 ( "sha512" , Unstable ( sym:: sha512_sm_x86) , & [ "avx2" ] ) ,
0 commit comments