Rollup merge of #121210 - madsmtm:fix-target-abi-i386-apple-ios, r=workingjubilee

Fix `cfg(target_abi = "sim")` on `i386-apple-ios`

Since https://github.com/rust-lang/rust/issues/80970 is stabilizing, I went and had a look, and found that the result was wrong on `i386-apple-ios`.

r? rust-lang/macos
This commit is contained in:
Matthias Krüger 2024-02-17 18:47:42 +01:00 committed by GitHub
commit a78e4610d0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 15 additions and 10 deletions

View file

@ -17,6 +17,7 @@ pub enum Arch {
Arm64e, Arm64e,
Arm64_32, Arm64_32,
I386, I386,
I386_sim,
I686, I686,
X86_64, X86_64,
X86_64h, X86_64h,
@ -34,7 +35,7 @@ impl Arch {
Arm64 | Arm64_macabi | Arm64_sim => "arm64", Arm64 | Arm64_macabi | Arm64_sim => "arm64",
Arm64e => "arm64e", Arm64e => "arm64e",
Arm64_32 => "arm64_32", Arm64_32 => "arm64_32",
I386 => "i386", I386 | I386_sim => "i386",
I686 => "i686", I686 => "i686",
X86_64 | X86_64_sim | X86_64_macabi => "x86_64", X86_64 | X86_64_sim | X86_64_macabi => "x86_64",
X86_64h => "x86_64h", X86_64h => "x86_64h",
@ -45,7 +46,7 @@ impl Arch {
Cow::Borrowed(match self { Cow::Borrowed(match self {
Armv7k | Armv7s => "arm", Armv7k | Armv7s => "arm",
Arm64 | Arm64e | Arm64_32 | Arm64_macabi | Arm64_sim => "aarch64", Arm64 | Arm64e | Arm64_32 | Arm64_macabi | Arm64_sim => "aarch64",
I386 | I686 => "x86", I386 | I386_sim | I686 => "x86",
X86_64 | X86_64_sim | X86_64_macabi | X86_64h => "x86_64", X86_64 | X86_64_sim | X86_64_macabi | X86_64h => "x86_64",
}) })
} }
@ -54,9 +55,7 @@ impl Arch {
match self { match self {
Armv7k | Armv7s | Arm64 | Arm64e | Arm64_32 | I386 | I686 | X86_64 | X86_64h => "", Armv7k | Armv7s | Arm64 | Arm64e | Arm64_32 | I386 | I686 | X86_64 | X86_64h => "",
X86_64_macabi | Arm64_macabi => "macabi", X86_64_macabi | Arm64_macabi => "macabi",
// x86_64-apple-ios is a simulator target, even though it isn't I386_sim | Arm64_sim | X86_64_sim => "sim",
// declared that way in the target like the other ones...
Arm64_sim | X86_64_sim => "sim",
} }
} }
@ -70,7 +69,7 @@ impl Arch {
// Only macOS 10.12+ is supported, which means // Only macOS 10.12+ is supported, which means
// all x86_64/x86 CPUs must be running at least penryn // all x86_64/x86 CPUs must be running at least penryn
// https://github.com/llvm/llvm-project/blob/01f924d0e37a5deae51df0d77e10a15b63aa0c0f/clang/lib/Driver/ToolChains/Arch/X86.cpp#L79-L82 // https://github.com/llvm/llvm-project/blob/01f924d0e37a5deae51df0d77e10a15b63aa0c0f/clang/lib/Driver/ToolChains/Arch/X86.cpp#L79-L82
I386 | I686 => "penryn", I386 | I386_sim | I686 => "penryn",
X86_64 | X86_64_sim => "penryn", X86_64 | X86_64_sim => "penryn",
X86_64_macabi => "penryn", X86_64_macabi => "penryn",
// Note: `core-avx2` is slightly more advanced than `x86_64h`, see // Note: `core-avx2` is slightly more advanced than `x86_64h`, see
@ -85,7 +84,7 @@ impl Arch {
fn stack_probes(self) -> StackProbeType { fn stack_probes(self) -> StackProbeType {
match self { match self {
Armv7k | Armv7s => StackProbeType::None, Armv7k | Armv7s => StackProbeType::None,
Arm64 | Arm64e | Arm64_32 | I386 | I686 | X86_64 | X86_64h | X86_64_sim Arm64 | Arm64e | Arm64_32 | I386 | I386_sim | I686 | X86_64 | X86_64h | X86_64_sim
| X86_64_macabi | Arm64_macabi | Arm64_sim => StackProbeType::Inline, | X86_64_macabi | Arm64_macabi | Arm64_sim => StackProbeType::Inline,
} }
} }
@ -302,8 +301,8 @@ fn link_env_remove(arch: Arch, os: &'static str) -> StaticCow<[StaticCow<str>]>
// Otherwise if cross-compiling for a different OS/SDK, remove any part // Otherwise if cross-compiling for a different OS/SDK, remove any part
// of the linking environment that's wrong and reversed. // of the linking environment that's wrong and reversed.
match arch { match arch {
Armv7k | Armv7s | Arm64 | Arm64e | Arm64_32 | I386 | I686 | X86_64 | X86_64_sim Armv7k | Armv7s | Arm64 | Arm64e | Arm64_32 | I386 | I386_sim | I686 | X86_64
| X86_64h | Arm64_sim => { | X86_64_sim | X86_64h | Arm64_sim => {
cvs!["MACOSX_DEPLOYMENT_TARGET"] cvs!["MACOSX_DEPLOYMENT_TARGET"]
} }
X86_64_macabi | Arm64_macabi => cvs!["IPHONEOS_DEPLOYMENT_TARGET"], X86_64_macabi | Arm64_macabi => cvs!["IPHONEOS_DEPLOYMENT_TARGET"],

View file

@ -2,7 +2,9 @@ use crate::spec::base::apple::{ios_sim_llvm_target, opts, Arch};
use crate::spec::{Target, TargetOptions}; use crate::spec::{Target, TargetOptions};
pub fn target() -> Target { pub fn target() -> Target {
let arch = Arch::I386; // i386-apple-ios is a simulator target, even though it isn't declared
// that way in the target name like the other ones...
let arch = Arch::I386_sim;
Target { Target {
// Clang automatically chooses a more specific target based on // Clang automatically chooses a more specific target based on
// IPHONEOS_DEPLOYMENT_TARGET. // IPHONEOS_DEPLOYMENT_TARGET.

View file

@ -2,6 +2,8 @@ use crate::spec::base::apple::{ios_sim_llvm_target, opts, Arch};
use crate::spec::{SanitizerSet, Target, TargetOptions}; use crate::spec::{SanitizerSet, Target, TargetOptions};
pub fn target() -> Target { pub fn target() -> Target {
// x86_64-apple-ios is a simulator target, even though it isn't declared
// that way in the target name like the other ones...
let arch = Arch::X86_64_sim; let arch = Arch::X86_64_sim;
let mut base = opts("ios", arch); let mut base = opts("ios", arch);
base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::THREAD; base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::THREAD;

View file

@ -2,6 +2,8 @@ use crate::spec::base::apple::{opts, tvos_sim_llvm_target, Arch};
use crate::spec::{Target, TargetOptions}; use crate::spec::{Target, TargetOptions};
pub fn target() -> Target { pub fn target() -> Target {
// x86_64-apple-tvos is a simulator target, even though it isn't declared
// that way in the target name like the other ones...
let arch = Arch::X86_64_sim; let arch = Arch::X86_64_sim;
Target { Target {
llvm_target: tvos_sim_llvm_target(arch).into(), llvm_target: tvos_sim_llvm_target(arch).into(),