@@ -51,14 +51,14 @@ impl Arch {
51
51
} )
52
52
}
53
53
54
- fn target_cpu ( self , abi : TargetAbi ) -> & ' static str {
54
+ fn target_cpu ( self , env : TargetEnv ) -> & ' static str {
55
55
match self {
56
56
Armv7k => "cortex-a8" ,
57
57
Armv7s => "swift" , // iOS 10 is only supported on iPhone 5 or higher.
58
- Arm64 => match abi {
59
- TargetAbi :: Normal => "apple-a7" ,
60
- TargetAbi :: Simulator => "apple-a12" ,
61
- TargetAbi :: MacCatalyst => "apple-a12" ,
58
+ Arm64 => match env {
59
+ TargetEnv :: Normal => "apple-a7" ,
60
+ TargetEnv :: Simulator => "apple-a12" ,
61
+ TargetEnv :: MacCatalyst => "apple-a12" ,
62
62
} ,
63
63
Arm64e => "apple-a12" ,
64
64
Arm64_32 => "apple-s4" ,
@@ -83,14 +83,14 @@ impl Arch {
83
83
}
84
84
85
85
#[ derive( Copy , Clone , PartialEq ) ]
86
- pub ( crate ) enum TargetAbi {
86
+ pub ( crate ) enum TargetEnv {
87
87
Normal ,
88
88
Simulator ,
89
89
MacCatalyst ,
90
90
}
91
91
92
- impl TargetAbi {
93
- fn target_abi ( self ) -> & ' static str {
92
+ impl TargetEnv {
93
+ fn target_env ( self ) -> & ' static str {
94
94
match self {
95
95
Self :: Normal => "" ,
96
96
Self :: MacCatalyst => "macabi" ,
@@ -104,13 +104,20 @@ impl TargetAbi {
104
104
pub ( crate ) fn base (
105
105
os : & ' static str ,
106
106
arch : Arch ,
107
- abi : TargetAbi ,
107
+ env : TargetEnv ,
108
108
) -> ( TargetOptions , StaticCow < str > , StaticCow < str > ) {
109
109
let mut opts = TargetOptions {
110
- abi : abi. target_abi ( ) . into ( ) ,
111
110
llvm_floatabi : Some ( FloatAbi :: Hard ) ,
112
111
os : os. into ( ) ,
113
- cpu : arch. target_cpu ( abi) . into ( ) ,
112
+ env : env. target_env ( ) . into ( ) ,
113
+ // NOTE: We originally set `cfg(target_abi = "macabi")` / `cfg(target_abi = "sim")`,
114
+ // before it was discovered that those are actually environments:
115
+ // https://github.com/rust-lang/rust/issues/133331
116
+ //
117
+ // But let's continue setting them for backwards compatibility.
118
+ // FIXME(madsmtm): Warn about using these in the future.
119
+ abi : env. target_env ( ) . into ( ) ,
120
+ cpu : arch. target_cpu ( env) . into ( ) ,
114
121
link_env_remove : link_env_remove ( os) ,
115
122
vendor : "apple" . into ( ) ,
116
123
linker_flavor : LinkerFlavor :: Darwin ( Cc :: Yes , Lld :: No ) ,
@@ -162,14 +169,14 @@ pub(crate) fn base(
162
169
// All Apple x86-32 targets have SSE2.
163
170
opts. rustc_abi = Some ( RustcAbi :: X86Sse2 ) ;
164
171
}
165
- ( opts, unversioned_llvm_target ( os, arch, abi ) , arch. target_arch ( ) )
172
+ ( opts, unversioned_llvm_target ( os, arch, env ) , arch. target_arch ( ) )
166
173
}
167
174
168
175
/// Generate part of the LLVM target triple.
169
176
///
170
177
/// See `rustc_codegen_ssa::back::versioned_llvm_target` for the full triple passed to LLVM and
171
178
/// Clang.
172
- fn unversioned_llvm_target ( os : & str , arch : Arch , abi : TargetAbi ) -> StaticCow < str > {
179
+ fn unversioned_llvm_target ( os : & str , arch : Arch , env : TargetEnv ) -> StaticCow < str > {
173
180
let arch = arch. target_name ( ) ;
174
181
// Convert to the "canonical" OS name used by LLVM:
175
182
// https://github.com/llvm/llvm-project/blob/llvmorg-18.1.8/llvm/lib/TargetParser/Triple.cpp#L236-L282
@@ -181,10 +188,10 @@ fn unversioned_llvm_target(os: &str, arch: Arch, abi: TargetAbi) -> StaticCow<st
181
188
"visionos" => "xros" ,
182
189
_ => unreachable ! ( "tried to get LLVM target OS for non-Apple platform" ) ,
183
190
} ;
184
- let environment = match abi {
185
- TargetAbi :: Normal => "" ,
186
- TargetAbi :: MacCatalyst => "-macabi" ,
187
- TargetAbi :: Simulator => "-simulator" ,
191
+ let environment = match env {
192
+ TargetEnv :: Normal => "" ,
193
+ TargetEnv :: MacCatalyst => "-macabi" ,
194
+ TargetEnv :: Simulator => "-simulator" ,
188
195
} ;
189
196
format ! ( "{arch}-apple-{os}{environment}" ) . into ( )
190
197
}
@@ -303,7 +310,7 @@ impl OSVersion {
303
310
/// This matches what LLVM does, see in part:
304
311
/// <https://github.com/llvm/llvm-project/blob/llvmorg-18.1.8/llvm/lib/TargetParser/Triple.cpp#L1900-L1932>
305
312
pub fn minimum_deployment_target ( target : & Target ) -> Self {
306
- let ( major, minor, patch) = match ( & * target. os , & * target. arch , & * target. abi ) {
313
+ let ( major, minor, patch) = match ( & * target. os , & * target. arch , & * target. env ) {
307
314
( "macos" , "aarch64" , _) => ( 11 , 0 , 0 ) ,
308
315
( "ios" , "aarch64" , "macabi" ) => ( 14 , 0 , 0 ) ,
309
316
( "ios" , "aarch64" , "sim" ) => ( 14 , 0 , 0 ) ,
0 commit comments