Skip to content

Commit ae00200

Browse files
committed
Fix default/minimum deployment target for Aarch64 simulator targets
The minimum that `rustc` encoded did not match the version in Clang, and that meant that that when linking, we ended up bumping the version. Specifically, this sets the correct deployment target of the following targets: - `aarch64-apple-ios-sim` from 10.0 to 14.0 - `aarch64-apple-ios-macabi` from 10.0 to 14.0 - `aarch64-apple-tvos-sim` from 10.0 to 14.0 - `aarch64-apple-watchos-sim` from 5.0 to 7.0 I have chosen not to document this in the platform support docs, as it is fundamentally uninteresting; the normal targets (`aarch64-apple-ios`) still have the same deployment target, and that's what developers should actually target.
1 parent 23bd0d5 commit ae00200

File tree

4 files changed

+26
-16
lines changed

4 files changed

+26
-16
lines changed

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

+8-2
Original file line numberDiff line numberDiff line change
@@ -327,12 +327,18 @@ fn deployment_target(os: &str, arch: Arch, abi: TargetAbi) -> (u16, u8, u8) {
327327
};
328328

329329
// On certain targets it makes sense to raise the minimum OS version.
330+
//
331+
// This matches what LLVM does, see:
332+
// <https://github.com/llvm/llvm-project/blob/llvmorg-18.1.8/llvm/lib/TargetParser/Triple.cpp#L1900-L1932>
330333
let min = match (os, arch, abi) {
331-
// Use 11.0 on Aarch64 as that's the earliest version with M1 support.
332334
("macos", Arch::Arm64 | Arch::Arm64e, _) => (11, 0, 0),
333-
("ios", Arch::Arm64e, _) => (14, 0, 0),
335+
("ios", Arch::Arm64 | Arch::Arm64e, TargetAbi::MacCatalyst) => (14, 0, 0),
336+
("ios", Arch::Arm64 | Arch::Arm64e, TargetAbi::Simulator) => (14, 0, 0),
337+
("ios", Arch::Arm64e, TargetAbi::Normal) => (14, 0, 0),
334338
// Mac Catalyst defaults to 13.1 in Clang.
335339
("ios", _, TargetAbi::MacCatalyst) => (13, 1, 0),
340+
("tvos", Arch::Arm64 | Arch::Arm64e, TargetAbi::Simulator) => (14, 0, 0),
341+
("watchos", Arch::Arm64 | Arch::Arm64e, TargetAbi::Simulator) => (7, 0, 0),
336342
_ => os_min,
337343
};
338344

src/doc/rustc/src/platform-support/apple-ios-macabi.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ environment variable.
2424

2525
### OS version
2626

27-
The minimum supported version is iOS 13.1.
27+
The minimum supported version is iOS 13.1 on x86 and 14.0 on Aarch64.
2828

2929
This can be raised per-binary by changing the deployment target. `rustc`
3030
respects the common environment variables used by Xcode to do so, in this

src/doc/rustc/src/platform-support/arm64e-apple-ios.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
**Tier: 3**
44

5-
ARM64e iOS (12.0+)
5+
ARM64e iOS (14.0+)
66

77
## Target maintainers
88

tests/run-make/apple-deployment-target/rmake.rs

+16-12
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,8 @@ fn main() {
5252
rustc.env(env_var, example_version).run();
5353
minos("foo.o", example_version);
5454

55-
// FIXME(madsmtm): Doesn't work on Mac Catalyst and the simulator.
56-
if !target().contains("macabi") && !target().contains("sim") {
57-
rustc.env_remove(env_var).run();
58-
minos("foo.o", default_version);
59-
}
55+
rustc.env_remove(env_var).run();
56+
minos("foo.o", default_version);
6057
});
6158

6259
// Test that version makes it to the linker when linking dylibs.
@@ -97,8 +94,18 @@ fn main() {
9794
rustc.input("foo.rs");
9895
rustc.output("foo");
9996

100-
// FIXME(madsmtm): Doesn't work on watchOS for some reason?
101-
if !target().contains("watchos") {
97+
// FIXME(madsmtm): Xcode's version of Clang seems to require a minimum
98+
// version of 9.0 on aarch64-apple-watchos for some reason? Which is
99+
// odd, because the first Aarch64 watch was Apple Watch Series 4,
100+
// which runs on as low as watchOS 5.0.
101+
//
102+
// You can see Clang's behaviour by running:
103+
// ```
104+
// echo "int main() { return 0; }" > main.c
105+
// xcrun --sdk watchos clang --target=aarch64-apple-watchos main.c
106+
// vtool -show a.out
107+
// ```
108+
if target() != "aarch64-apple-watchos" {
102109
rustc.env(env_var, example_version).run();
103110
minos("foo", example_version);
104111

@@ -133,10 +140,7 @@ fn main() {
133140
rustc.env(env_var, higher_example_version).run();
134141
minos("foo.o", higher_example_version);
135142

136-
// FIXME(madsmtm): Doesn't work on Mac Catalyst and the simulator.
137-
if !target().contains("macabi") && !target().contains("sim") {
138-
rustc.env_remove(env_var).run();
139-
minos("foo.o", default_version);
140-
}
143+
rustc.env_remove(env_var).run();
144+
minos("foo.o", default_version);
141145
});
142146
}

0 commit comments

Comments
 (0)