Skip to content

Commit afefc69

Browse files
authored
Rollup merge of rust-lang#77484 - terhechte:support-ios-catalyst-macabi-arm64-target-triple, r=nikomatsakis
Add support for Arm64 Catalyst on ARM Macs This is an iteration on rust-lang#63467 which was merged a while ago. In the aforementioned PR, I added support for the `X86_64-apple-ios-macabi` target triple, which is Catalyst, iOS apps running on macOS. Very soon, Apple will launch ARM64 based Macs which will introduce `aarch64_apple_darwin.rs`, macOS apps using the Darwin ABI running on ARM. This PR adds support for Catalyst apps on ARM Macs: iOS apps compiled for the darwin ABI. I don't have access to a Apple Developer Transition Kit (DTK), so I can't really test if the generated binaries work correctly. I'm vaguely hopeful that somebody with access to a DTK could give this a spin.
2 parents 6b1083c + 80ac68e commit afefc69

File tree

5 files changed

+43
-3
lines changed

5 files changed

+43
-3
lines changed

compiler/rustc_codegen_ssa/src/back/link.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -2094,9 +2094,10 @@ fn add_apple_sdk(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) {
20942094
("aarch64", "tvos") => "appletvos",
20952095
("x86_64", "tvos") => "appletvsimulator",
20962096
("arm", "ios") => "iphoneos",
2097+
("aarch64", "ios") if llvm_target.contains("macabi") => "macosx",
20972098
("aarch64", "ios") => "iphoneos",
20982099
("x86", "ios") => "iphonesimulator",
2099-
("x86_64", "ios") if llvm_target.contains("macabi") => "macosx10.15",
2100+
("x86_64", "ios") if llvm_target.contains("macabi") => "macosx",
21002101
("x86_64", "ios") => "iphonesimulator",
21012102
_ => {
21022103
sess.err(&format!("unsupported arch `{}` for os `{}`", arch, os));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
use super::apple_sdk_base::{opts, Arch};
2+
use crate::spec::{LinkerFlavor, Target, TargetOptions};
3+
4+
pub fn target() -> Target {
5+
let base = opts(Arch::Arm64_macabi);
6+
Target {
7+
llvm_target: "arm64-apple-ios14.2-macabi".to_string(),
8+
target_endian: "little".to_string(),
9+
target_pointer_width: "64".to_string(),
10+
target_c_int_width: "32".to_string(),
11+
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".to_string(),
12+
arch: "aarch64".to_string(),
13+
target_os: "ios".to_string(),
14+
target_env: String::new(),
15+
target_vendor: "apple".to_string(),
16+
linker_flavor: LinkerFlavor::Gcc,
17+
options: TargetOptions {
18+
features: "+neon,+fp-armv8,+apple-a12".to_string(),
19+
eliminate_frame_pointer: false,
20+
max_atomic_width: Some(128),
21+
unsupported_abis: super::arm_base::unsupported_abis(),
22+
forces_embed_bitcode: true,
23+
// Taken from a clang build on Xcode 11.4.1.
24+
// These arguments are not actually invoked - they just have
25+
// to look right to pass App Store validation.
26+
bitcode_llvm_cmdline: "-triple\0\
27+
arm64-apple-ios14.2-macabi\0\
28+
-emit-obj\0\
29+
-disable-llvm-passes\0\
30+
-Os\0"
31+
.to_string(),
32+
..base
33+
},
34+
}
35+
}

compiler/rustc_target/src/spec/apple_sdk_base.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ pub enum Arch {
1010
I386,
1111
X86_64,
1212
X86_64_macabi,
13+
Arm64_macabi,
1314
}
1415

1516
fn target_cpu(arch: Arch) -> String {
@@ -20,14 +21,15 @@ fn target_cpu(arch: Arch) -> String {
2021
I386 => "yonah",
2122
X86_64 => "core2",
2223
X86_64_macabi => "core2",
24+
Arm64_macabi => "apple-a12",
2325
}
2426
.to_string()
2527
}
2628

2729
fn link_env_remove(arch: Arch) -> Vec<String> {
2830
match arch {
2931
Armv7 | Armv7s | Arm64 | I386 | X86_64 => vec!["MACOSX_DEPLOYMENT_TARGET".to_string()],
30-
X86_64_macabi => vec!["IPHONEOS_DEPLOYMENT_TARGET".to_string()],
32+
X86_64_macabi | Arm64_macabi => vec!["IPHONEOS_DEPLOYMENT_TARGET".to_string()],
3133
}
3234
}
3335

compiler/rustc_target/src/spec/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,7 @@ supported_targets! {
569569
("armv7-apple-ios", armv7_apple_ios),
570570
("armv7s-apple-ios", armv7s_apple_ios),
571571
("x86_64-apple-ios-macabi", x86_64_apple_ios_macabi),
572+
("aarch64-apple-ios-macabi", aarch64_apple_ios_macabi),
572573
("aarch64-apple-tvos", aarch64_apple_tvos),
573574
("x86_64-apple-tvos", x86_64_apple_tvos),
574575

src/doc/rustc/src/platform-support.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ not available.
146146

147147
target | std | host | notes
148148
-------|-----|------|-------
149+
`aarch64-apple-ios-macabi` | ? | | Apple Catalyst on ARM64
149150
`aarch64-apple-tvos` | * | | ARM64 tvOS
150151
`aarch64-unknown-cloudabi` | ✓ | | ARM64 CloudABI
151152
`aarch64-unknown-freebsd` | ✓ | ✓ | ARM64 FreeBSD
@@ -203,7 +204,7 @@ target | std | host | notes
203204
`thumbv7a-uwp-windows-msvc` | ✓ | |
204205
`thumbv7neon-unknown-linux-musleabihf` | ? | | Thumb2-mode ARMv7a Linux with NEON, MUSL
205206
`thumbv4t-none-eabi` | * | | ARMv4T T32
206-
`x86_64-apple-ios-macabi` | ✓ | | Apple Catalyst
207+
`x86_64-apple-ios-macabi` | ✓ | | Apple Catalyst on x86_64
207208
`x86_64-apple-tvos` | * | | x86 64-bit tvOS
208209
`x86_64-linux-kernel` | * | | Linux kernel modules
209210
`x86_64-pc-solaris` | ? | |

0 commit comments

Comments
 (0)