Skip to content

Commit 97df8fb

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 simulator and Mac Catalyst targets: - `aarch64-apple-ios-sim` 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 - `aarch64-apple-ios-macabi` from 13.1 to 14.0 I have chosen to not document the simulator target versions in the platform support docs, as it is fundamentally uninteresting; the normal targets (e.g. `aarch64-apple-ios`, `aarch64-apple-tvos`) still have the same deployment target as before, and that's what developers should actually target.
1 parent 1f44f0a commit 97df8fb

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
@@ -323,12 +323,18 @@ fn deployment_target(os: &str, arch: Arch, abi: TargetAbi) -> (u16, u8, u8) {
323323
};
324324

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

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
@@ -55,11 +55,8 @@ fn main() {
5555
rustc().env(env_var, example_version).run();
5656
minos("foo.o", example_version);
5757

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

6562
// Test that version makes it to the linker when linking dylibs.
@@ -105,8 +102,18 @@ fn main() {
105102
rustc
106103
};
107104

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

@@ -148,10 +155,7 @@ fn main() {
148155
rustc().env(env_var, higher_example_version).run();
149156
minos("foo.o", higher_example_version);
150157

151-
// FIXME(madsmtm): Doesn't work on Mac Catalyst and the simulator.
152-
if !target().contains("macabi") && !target().contains("sim") {
153-
rustc().env_remove(env_var).run();
154-
minos("foo.o", default_version);
155-
}
158+
rustc().env_remove(env_var).run();
159+
minos("foo.o", default_version);
156160
});
157161
}

0 commit comments

Comments
 (0)