@@ -30,6 +30,8 @@ use crate::targets as targ;
3030/// All predicates that pertains to a target, except for `target_feature`
3131#[ derive( Clone , PartialEq , Eq , Debug ) ]
3232pub enum TargetPredicate {
33+ /// [target_abi](https://github.com/rust-lang/rust/issues/80970)
34+ Abi ( targ:: Abi ) ,
3335 /// [target_arch](https://doc.rust-lang.org/reference/conditional-compilation.html#target_arch)
3436 Arch ( targ:: Arch ) ,
3537 /// [target_endian](https://doc.rust-lang.org/reference/conditional-compilation.html#target_endian)
@@ -59,10 +61,15 @@ pub trait TargetMatcher {
5961impl TargetMatcher for targ:: TargetInfo {
6062 fn matches ( & self , tp : & TargetPredicate ) -> bool {
6163 use TargetPredicate :: {
62- Arch , Endian , Env , Family , HasAtomic , Os , Panic , PointerWidth , Vendor ,
64+ Abi , Arch , Endian , Env , Family , HasAtomic , Os , Panic , PointerWidth , Vendor ,
6365 } ;
6466
6567 match tp {
68+ // The ABI is allowed to be an empty string
69+ Abi ( abi) => match & self . abi {
70+ Some ( a) => abi == a,
71+ None => abi. 0 . is_empty ( ) ,
72+ } ,
6673 Arch ( a) => a == & self . arch ,
6774 Endian ( end) => * end == self . endian ,
6875 // The environment is allowed to be an empty string
@@ -90,10 +97,14 @@ impl TargetMatcher for target_lexicon::Triple {
9097 fn matches ( & self , tp : & TargetPredicate ) -> bool {
9198 use target_lexicon:: * ;
9299 use TargetPredicate :: {
93- Arch , Endian , Env , Family , HasAtomic , Os , Panic , PointerWidth , Vendor ,
100+ Abi , Arch , Endian , Env , Family , HasAtomic , Os , Panic , PointerWidth , Vendor ,
94101 } ;
95102
96103 match tp {
104+ Abi ( _) => {
105+ // `target_abi` is unstable. Assume false for this.
106+ false
107+ }
97108 Arch ( arch) => {
98109 if arch == & targ:: Arch :: x86 {
99110 matches ! ( self . architecture, Architecture :: X86_32 ( _) )
@@ -356,6 +367,7 @@ impl TargetPredicate {
356367
357368#[ derive( Clone , Debug ) ]
358369pub ( crate ) enum Which {
370+ Abi ,
359371 Arch ,
360372 Endian ( targ:: Endian ) ,
361373 Env ,
@@ -419,6 +431,9 @@ impl InnerPredicate {
419431
420432 match self {
421433 IP :: Target ( it) => match & it. which {
434+ Which :: Abi => Target ( TargetPredicate :: Abi ( targ:: Abi :: new (
435+ s[ it. span . clone ( ) . unwrap ( ) ] . to_owned ( ) ,
436+ ) ) ) ,
422437 Which :: Arch => Target ( TargetPredicate :: Arch ( targ:: Arch :: new (
423438 s[ it. span . clone ( ) . unwrap ( ) ] . to_owned ( ) ,
424439 ) ) ) ,
0 commit comments