Skip to content

Commit dae22a5

Browse files
committed
Fix cfg(target_abi = "sim") on i386-apple-ios
i386-apple-ios is also a simulator target
1 parent b11fbfb commit dae22a5

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

compiler/rustc_target/src/spec/base/apple/mod.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub enum Arch {
1717
Arm64e,
1818
Arm64_32,
1919
I386,
20+
I386_sim,
2021
I686,
2122
X86_64,
2223
X86_64h,
@@ -34,7 +35,7 @@ impl Arch {
3435
Arm64 | Arm64_macabi | Arm64_sim => "arm64",
3536
Arm64e => "arm64e",
3637
Arm64_32 => "arm64_32",
37-
I386 => "i386",
38+
I386 | I386_sim => "i386",
3839
I686 => "i686",
3940
X86_64 | X86_64_sim | X86_64_macabi => "x86_64",
4041
X86_64h => "x86_64h",
@@ -45,7 +46,7 @@ impl Arch {
4546
Cow::Borrowed(match self {
4647
Armv7k | Armv7s => "arm",
4748
Arm64 | Arm64e | Arm64_32 | Arm64_macabi | Arm64_sim => "aarch64",
48-
I386 | I686 => "x86",
49+
I386 | I386_sim | I686 => "x86",
4950
X86_64 | X86_64_sim | X86_64_macabi | X86_64h => "x86_64",
5051
})
5152
}
@@ -56,7 +57,7 @@ impl Arch {
5657
X86_64_macabi | Arm64_macabi => "macabi",
5758
// x86_64-apple-ios is a simulator target, even though it isn't
5859
// declared that way in the target like the other ones...
59-
Arm64_sim | X86_64_sim => "sim",
60+
I386_sim | Arm64_sim | X86_64_sim => "sim",
6061
}
6162
}
6263

@@ -70,7 +71,7 @@ impl Arch {
7071
// Only macOS 10.12+ is supported, which means
7172
// all x86_64/x86 CPUs must be running at least penryn
7273
// https://github.com/llvm/llvm-project/blob/01f924d0e37a5deae51df0d77e10a15b63aa0c0f/clang/lib/Driver/ToolChains/Arch/X86.cpp#L79-L82
73-
I386 | I686 => "penryn",
74+
I386 | I386_sim | I686 => "penryn",
7475
X86_64 | X86_64_sim => "penryn",
7576
X86_64_macabi => "penryn",
7677
// Note: `core-avx2` is slightly more advanced than `x86_64h`, see
@@ -85,7 +86,7 @@ impl Arch {
8586
fn stack_probes(self) -> StackProbeType {
8687
match self {
8788
Armv7k | Armv7s => StackProbeType::None,
88-
Arm64 | Arm64e | Arm64_32 | I386 | I686 | X86_64 | X86_64h | X86_64_sim
89+
Arm64 | Arm64e | Arm64_32 | I386 | I386_sim | I686 | X86_64 | X86_64h | X86_64_sim
8990
| X86_64_macabi | Arm64_macabi | Arm64_sim => StackProbeType::Inline,
9091
}
9192
}
@@ -302,8 +303,8 @@ fn link_env_remove(arch: Arch, os: &'static str) -> StaticCow<[StaticCow<str>]>
302303
// Otherwise if cross-compiling for a different OS/SDK, remove any part
303304
// of the linking environment that's wrong and reversed.
304305
match arch {
305-
Armv7k | Armv7s | Arm64 | Arm64e | Arm64_32 | I386 | I686 | X86_64 | X86_64_sim
306-
| X86_64h | Arm64_sim => {
306+
Armv7k | Armv7s | Arm64 | Arm64e | Arm64_32 | I386 | I386_sim | I686 | X86_64
307+
| X86_64_sim | X86_64h | Arm64_sim => {
307308
cvs!["MACOSX_DEPLOYMENT_TARGET"]
308309
}
309310
X86_64_macabi | Arm64_macabi => cvs!["IPHONEOS_DEPLOYMENT_TARGET"],

compiler/rustc_target/src/spec/targets/i386_apple_ios.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::spec::base::apple::{ios_sim_llvm_target, opts, Arch};
22
use crate::spec::{Target, TargetOptions};
33

44
pub fn target() -> Target {
5-
let arch = Arch::I386;
5+
let arch = Arch::I386_sim;
66
Target {
77
// Clang automatically chooses a more specific target based on
88
// IPHONEOS_DEPLOYMENT_TARGET.

0 commit comments

Comments
 (0)