@@ -1114,6 +1114,33 @@ impl ToJson for FloatAbi {
1114
1114
}
1115
1115
}
1116
1116
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
+
1117
1144
#[ derive( Clone , Copy , PartialEq , Hash , Debug ) ]
1118
1145
pub enum TlsModel {
1119
1146
GeneralDynamic ,
@@ -2505,6 +2532,12 @@ pub struct TargetOptions {
2505
2532
/// If not provided, LLVM will infer the float ABI from the target triple (`llvm_target`).
2506
2533
pub llvm_floatabi : Option < FloatAbi > ,
2507
2534
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
+
2508
2541
/// Whether or not RelaxElfRelocation flag will be passed to the linker
2509
2542
pub relax_elf_relocations : bool ,
2510
2543
@@ -2664,10 +2697,6 @@ impl TargetOptions {
2664
2697
. collect ( ) ;
2665
2698
}
2666
2699
}
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
- }
2671
2700
}
2672
2701
2673
2702
impl Default for TargetOptions {
@@ -2774,6 +2803,7 @@ impl Default for TargetOptions {
2774
2803
llvm_mcount_intrinsic : None ,
2775
2804
llvm_abiname : "" . into ( ) ,
2776
2805
llvm_floatabi : None ,
2806
+ rustc_abi : None ,
2777
2807
relax_elf_relocations : false ,
2778
2808
llvm_args : cvs ! [ ] ,
2779
2809
use_ctors_section : false ,
@@ -3240,6 +3270,17 @@ impl Target {
3240
3270
_ => { }
3241
3271
}
3242
3272
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
+
3243
3284
// Check that the given target-features string makes some basic sense.
3244
3285
if !self . features . is_empty ( ) {
3245
3286
let mut features_enabled = FxHashSet :: default ( ) ;
0 commit comments