@@ -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 ) , 
@@ -162,14 +169,14 @@ pub(crate) fn base(
162169        // All Apple x86-32 targets have SSE2. 
163170        opts. rustc_abi  = Some ( RustcAbi :: X86Sse2 ) ; 
164171    } 
165-     ( opts,  unversioned_llvm_target ( os,  arch,  abi ) ,  arch. target_arch ( ) ) 
172+     ( opts,  unversioned_llvm_target ( os,  arch,  env ) ,  arch. target_arch ( ) ) 
166173} 
167174
168175/// Generate part of the LLVM target triple. 
169176/// 
170177/// See `rustc_codegen_ssa::back::versioned_llvm_target` for the full triple passed to LLVM and 
171178/// 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 >  { 
173180    let  arch = arch. target_name ( ) ; 
174181    // Convert to the "canonical" OS name used by LLVM: 
175182    // 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
181188        "visionos"  => "xros" , 
182189        _ => unreachable ! ( "tried to get LLVM target OS for non-Apple platform" ) , 
183190    } ; 
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" , 
188195    } ; 
189196    format ! ( "{arch}-apple-{os}{environment}" ) . into ( ) 
190197} 
@@ -303,7 +310,7 @@ impl OSVersion {
303310/// This matches what LLVM does, see in part: 
304311/// <https://github.com/llvm/llvm-project/blob/llvmorg-18.1.8/llvm/lib/TargetParser/Triple.cpp#L1900-L1932> 
305312pub  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 )  { 
307314            ( "macos" ,  "aarch64" ,  _)  => ( 11 ,  0 ,  0 ) , 
308315            ( "ios" ,  "aarch64" ,  "macabi" )  => ( 14 ,  0 ,  0 ) , 
309316            ( "ios" ,  "aarch64" ,  "sim" )  => ( 14 ,  0 ,  0 ) , 
0 commit comments