Skip to content

Commit 7c06800

Browse files
committed
Add support for Arm64 Catalyst on ARM Macs
1 parent 1fe9b7f commit 7c06800

File tree

4 files changed

+42
-1
lines changed

4 files changed

+42
-1
lines changed

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2101,6 +2101,7 @@ fn add_apple_sdk(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) {
21012101
("aarch64", "tvos") => "appletvos",
21022102
("x86_64", "tvos") => "appletvsimulator",
21032103
("arm", "ios") => "iphoneos",
2104+
("aarch64", "ios") if llvm_target.contains("macabi") => "macos11",
21042105
("aarch64", "ios") => "iphoneos",
21052106
("x86", "ios") => "iphonesimulator",
21062107
("x86_64", "ios") if llvm_target.contains("macabi") => "macosx10.15",
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
use super::apple_sdk_base::{opts, Arch};
2+
use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
3+
4+
pub fn target() -> TargetResult {
5+
let base = opts(Arch::Arm64_macabi);
6+
Ok(Target {
7+
llvm_target: "arm64-apple-ios-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-a7".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-ios-macabi\0\
28+
-emit-obj\0\
29+
-disable-llvm-passes\0\
30+
-target-abi\0\
31+
darwinpcs\0\
32+
-Os\0"
33+
.to_string(),
34+
..base
35+
},
36+
})
37+
}

compiler/rustc_target/src/spec/apple_sdk_base.rs

Lines changed: 3 additions & 1 deletion
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-a7",
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

Lines changed: 1 addition & 0 deletions
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

0 commit comments

Comments
 (0)