@@ -51,14 +51,14 @@ impl Arch {
5151 } )
5252 }
5353
54- fn target_cpu ( self , abi : TargetAbi ) -> & ' static str {
54+ fn target_cpu ( self , env : TargetEnv ) -> & ' static str {
5555 match self {
5656 Armv7k => "cortex-a8" ,
5757 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" ,
6262 } ,
6363 Arm64e => "apple-a12" ,
6464 Arm64_32 => "apple-s4" ,
@@ -83,14 +83,14 @@ impl Arch {
8383}
8484
8585#[ derive( Copy , Clone , PartialEq ) ]
86- pub ( crate ) enum TargetAbi {
86+ pub ( crate ) enum TargetEnv {
8787 Normal ,
8888 Simulator ,
8989 MacCatalyst ,
9090}
9191
92- impl TargetAbi {
93- fn target_abi ( self ) -> & ' static str {
92+ impl TargetEnv {
93+ fn target_env ( self ) -> & ' static str {
9494 match self {
9595 Self :: Normal => "" ,
9696 Self :: MacCatalyst => "macabi" ,
@@ -104,13 +104,20 @@ impl TargetAbi {
104104pub ( crate ) fn base (
105105 os : & ' static str ,
106106 arch : Arch ,
107- abi : TargetAbi ,
107+ env : TargetEnv ,
108108) -> ( TargetOptions , StaticCow < str > , StaticCow < str > ) {
109109 let mut opts = TargetOptions {
110- abi : abi. target_abi ( ) . into ( ) ,
111110 llvm_floatabi : Some ( FloatAbi :: Hard ) ,
112111 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 ( ) ,
114121 link_env_remove : link_env_remove ( os) ,
115122 vendor : "apple" . into ( ) ,
116123 linker_flavor : LinkerFlavor :: Darwin ( Cc :: Yes , Lld :: No ) ,
@@ -168,14 +175,14 @@ pub(crate) fn base(
168175 // All Apple x86-32 targets have SSE2.
169176 opts. rustc_abi = Some ( RustcAbi :: X86Sse2 ) ;
170177 }
171- ( opts, unversioned_llvm_target ( os, arch, abi ) , arch. target_arch ( ) )
178+ ( opts, unversioned_llvm_target ( os, arch, env ) , arch. target_arch ( ) )
172179}
173180
174181/// Generate part of the LLVM target triple.
175182///
176183/// See `rustc_codegen_ssa::back::versioned_llvm_target` for the full triple passed to LLVM and
177184/// 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 > {
179186 let arch = arch. target_name ( ) ;
180187 // Convert to the "canonical" OS name used by LLVM:
181188 // 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
187194 "visionos" => "xros" ,
188195 _ => unreachable ! ( "tried to get LLVM target OS for non-Apple platform" ) ,
189196 } ;
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" ,
194201 } ;
195202 format ! ( "{arch}-apple-{os}{environment}" ) . into ( )
196203}
@@ -309,7 +316,7 @@ impl OSVersion {
309316 /// This matches what LLVM does, see in part:
310317 /// <https://github.com/llvm/llvm-project/blob/llvmorg-18.1.8/llvm/lib/TargetParser/Triple.cpp#L1900-L1932>
311318 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 ) {
313320 ( "macos" , "aarch64" , _) => ( 11 , 0 , 0 ) ,
314321 ( "ios" , "aarch64" , "macabi" ) => ( 14 , 0 , 0 ) ,
315322 ( "ios" , "aarch64" , "sim" ) => ( 14 , 0 , 0 ) ,
0 commit comments