@@ -1114,6 +1114,33 @@ impl ToJson for FloatAbi {
11141114 }
11151115}
11161116
1117+ /// The Rustc-specific variant of the ABI used for this target.
1118+ #[ derive( Clone , Copy , PartialEq , Hash , Debug ) ]
1119+ pub enum RustcAbi {
1120+ /// On x86-32/64 only: do not use any FPU or SIMD registers for the ABI.
1121+ X86Softfloat ,
1122+ }
1123+
1124+ impl FromStr for RustcAbi {
1125+ type Err = ( ) ;
1126+
1127+ fn from_str ( s : & str ) -> Result < RustcAbi , ( ) > {
1128+ Ok ( match s {
1129+ "x86-softfloat" => RustcAbi :: X86Softfloat ,
1130+ _ => return Err ( ( ) ) ,
1131+ } )
1132+ }
1133+ }
1134+
1135+ impl ToJson for RustcAbi {
1136+ fn to_json ( & self ) -> Json {
1137+ match * self {
1138+ RustcAbi :: X86Softfloat => "x86-softfloat" ,
1139+ }
1140+ . to_json ( )
1141+ }
1142+ }
1143+
11171144#[ derive( Clone , Copy , PartialEq , Hash , Debug ) ]
11181145pub enum TlsModel {
11191146 GeneralDynamic ,
@@ -2505,6 +2532,12 @@ pub struct TargetOptions {
25052532 /// If not provided, LLVM will infer the float ABI from the target triple (`llvm_target`).
25062533 pub llvm_floatabi : Option < FloatAbi > ,
25072534
2535+ /// Picks a specific ABI for this target. This is *not* just for "Rust" ABI functions,
2536+ /// it can also affect "C" ABI functions; the point is that this flag is interpreted by
2537+ /// rustc and not forwarded to LLVM.
2538+ /// So far, this is only used on x86.
2539+ pub rustc_abi : Option < RustcAbi > ,
2540+
25082541 /// Whether or not RelaxElfRelocation flag will be passed to the linker
25092542 pub relax_elf_relocations : bool ,
25102543
@@ -2664,10 +2697,6 @@ impl TargetOptions {
26642697 . collect ( ) ;
26652698 }
26662699 }
2667-
2668- pub ( crate ) fn has_feature ( & self , search_feature : & str ) -> bool {
2669- self . features . split ( ',' ) . any ( |f| f. strip_prefix ( '+' ) . is_some_and ( |f| f == search_feature) )
2670- }
26712700}
26722701
26732702impl Default for TargetOptions {
@@ -2774,6 +2803,7 @@ impl Default for TargetOptions {
27742803 llvm_mcount_intrinsic : None ,
27752804 llvm_abiname : "" . into ( ) ,
27762805 llvm_floatabi : None ,
2806+ rustc_abi : None ,
27772807 relax_elf_relocations : false ,
27782808 llvm_args : cvs ! [ ] ,
27792809 use_ctors_section : false ,
@@ -3240,6 +3270,17 @@ impl Target {
32403270 _ => { }
32413271 }
32423272
3273+ // Check consistency of Rust ABI declaration.
3274+ if let Some ( rust_abi) = self . rustc_abi {
3275+ match rust_abi {
3276+ RustcAbi :: X86Softfloat => check_matches ! (
3277+ & * self . arch,
3278+ "x86" | "x86_64" ,
3279+ "`x86-softfloat` ABI is only valid for x86 targets"
3280+ ) ,
3281+ }
3282+ }
3283+
32433284 // Check that the given target-features string makes some basic sense.
32443285 if !self . features . is_empty ( ) {
32453286 let mut features_enabled = FxHashSet :: default ( ) ;
0 commit comments