Skip to content

Commit 65a5cd4

Browse files
authored
Rollup merge of #129367 - madsmtm:fix-apple-aarch64-deployment-targets, r=jieyouxu
Fix default/minimum deployment target for Aarch64 simulator targets The minimum that `rustc` encoded did not match [the version in Clang](https://github.com./llvm/llvm-project/blob/llvmorg-18.1.8/llvm/lib/TargetParser/Triple.cpp#L1900-L1932), and that meant that that when linking, Clang ended up bumping the version. See #129432 for more motivation behind this change. Specifically, this PR sets the correct deployment target of the following 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 not to document the `-sim` changes in the platform support docs, as it is fundamentally uninteresting; the normal targets (e.g. `aarch64-apple-ios`) still have the same deployment target, and that's what developers should actually target. r? compiler CC `@BlackHoleFox`
2 parents 8e037cc + 97df8fb commit 65a5cd4

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

353353
// On certain targets it makes sense to raise the minimum OS version.
354+
//
355+
// This matches what LLVM does, see:
356+
// <https://github.com./llvm/llvm-project/blob/llvmorg-18.1.8/llvm/lib/TargetParser/Triple.cpp#L1900-L1932>
354357
let min = match (os, arch, abi) {
355-
// Use 11.0 on Aarch64 as that's the earliest version with M1 support.
356358
("macos", Arch::Arm64 | Arch::Arm64e, _) => (11, 0, 0),
357-
("ios", Arch::Arm64e, _) => (14, 0, 0),
359+
("ios", Arch::Arm64 | Arch::Arm64e, TargetAbi::MacCatalyst) => (14, 0, 0),
360+
("ios", Arch::Arm64 | Arch::Arm64e, TargetAbi::Simulator) => (14, 0, 0),
361+
("ios", Arch::Arm64e, TargetAbi::Normal) => (14, 0, 0),
358362
// Mac Catalyst defaults to 13.1 in Clang.
359363
("ios", _, TargetAbi::MacCatalyst) => (13, 1, 0),
364+
("tvos", Arch::Arm64 | Arch::Arm64e, TargetAbi::Simulator) => (14, 0, 0),
365+
("watchos", Arch::Arm64 | Arch::Arm64e, TargetAbi::Simulator) => (7, 0, 0),
360366
_ => os_min,
361367
};
362368

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.
@@ -104,8 +101,18 @@ fn main() {
104101
rustc
105102
};
106103

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

@@ -146,10 +153,7 @@ fn main() {
146153
rustc().env(env_var, higher_example_version).run();
147154
minos("foo.o", higher_example_version);
148155

149-
// FIXME(madsmtm): Doesn't work on Mac Catalyst and the simulator.
150-
if !target().contains("macabi") && !target().contains("sim") {
151-
rustc().env_remove(env_var).run();
152-
minos("foo.o", default_version);
153-
}
156+
rustc().env_remove(env_var).run();
157+
minos("foo.o", default_version);
154158
});
155159
}

0 commit comments

Comments
 (0)