@@ -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 ) ,
@@ -168,14 +175,14 @@ pub(crate) fn base(
168
175
// All Apple x86-32 targets have SSE2.
169
176
opts. rustc_abi = Some ( RustcAbi :: X86Sse2 ) ;
170
177
}
171
- ( opts, unversioned_llvm_target ( os, arch, abi ) , arch. target_arch ( ) )
178
+ ( opts, unversioned_llvm_target ( os, arch, env ) , arch. target_arch ( ) )
172
179
}
173
180
174
181
/// Generate part of the LLVM target triple.
175
182
///
176
183
/// See `rustc_codegen_ssa::back::versioned_llvm_target` for the full triple passed to LLVM and
177
184
/// Clang.
178
- fn unversioned_llvm_target ( os : & str , arch : Arch , abi : TargetAbi ) -> StaticCow < str > {
185
+ fn unversioned_llvm_target ( os : & str , arch : Arch , env : TargetEnv ) -> StaticCow < str > {
179
186
let arch = arch. target_name ( ) ;
180
187
// Convert to the "canonical" OS name used by LLVM:
181
188
// https://github.com/llvm/llvm-project/blob/llvmorg-18.1.8/llvm/lib/TargetParser/Triple.cpp#L236-L282
@@ -187,10 +194,10 @@ fn unversioned_llvm_target(os: &str, arch: Arch, abi: TargetAbi) -> StaticCow<st
187
194
"visionos" => "xros" ,
188
195
_ => unreachable ! ( "tried to get LLVM target OS for non-Apple platform" ) ,
189
196
} ;
190
- let environment = match abi {
191
- TargetAbi :: Normal => "" ,
192
- TargetAbi :: MacCatalyst => "-macabi" ,
193
- TargetAbi :: Simulator => "-simulator" ,
197
+ let environment = match env {
198
+ TargetEnv :: Normal => "" ,
199
+ TargetEnv :: MacCatalyst => "-macabi" ,
200
+ TargetEnv :: Simulator => "-simulator" ,
194
201
} ;
195
202
format ! ( "{arch}-apple-{os}{environment}" ) . into ( )
196
203
}
@@ -309,7 +316,7 @@ impl OSVersion {
309
316
/// This matches what LLVM does, see in part:
310
317
/// <https://github.com/llvm/llvm-project/blob/llvmorg-18.1.8/llvm/lib/TargetParser/Triple.cpp#L1900-L1932>
311
318
pub fn minimum_deployment_target ( target : & Target ) -> Self {
312
- let ( major, minor, patch) = match ( & * target. os , & * target. arch , & * target. abi ) {
319
+ let ( major, minor, patch) = match ( & * target. os , & * target. arch , & * target. env ) {
313
320
( "macos" , "aarch64" , _) => ( 11 , 0 , 0 ) ,
314
321
( "ios" , "aarch64" , "macabi" ) => ( 14 , 0 , 0 ) ,
315
322
( "ios" , "aarch64" , "sim" ) => ( 14 , 0 , 0 ) ,
0 commit comments