Skip to content

Commit c3457cf

Browse files
committed
[watchos] add target specs for watchos armv7k and arm64_32
[watchos] Add spec for x86_64-apple-watchos-sim
1 parent cd2da4d commit c3457cf

File tree

11 files changed

+109
-8
lines changed

11 files changed

+109
-8
lines changed

compiler/rustc_codegen_llvm/src/back/write.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1035,7 +1035,8 @@ unsafe fn embed_bitcode(
10351035
// reason (see issue #90326 for historical background).
10361036
let is_apple = cgcx.opts.target_triple.triple().contains("-ios")
10371037
|| cgcx.opts.target_triple.triple().contains("-darwin")
1038-
|| cgcx.opts.target_triple.triple().contains("-tvos");
1038+
|| cgcx.opts.target_triple.triple().contains("-tvos")
1039+
|| cgcx.opts.target_triple.triple().contains("-watchos");
10391040
if is_apple
10401041
|| cgcx.opts.target_triple.triple().starts_with("wasm")
10411042
|| cgcx.opts.target_triple.triple().starts_with("asmjs")

compiler/rustc_target/src/spec/apple_base.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,12 @@ pub fn ios_sim_llvm_target(arch: &str) -> String {
114114
let (major, minor) = ios_deployment_target();
115115
format!("{}-apple-ios{}.{}.0-simulator", arch, major, minor)
116116
}
117+
118+
fn watchos_deployment_target() -> (u32, u32) {
119+
deployment_target("WATCHOS_DEPLOYMENT_TARGET").unwrap_or((5, 0))
120+
}
121+
122+
pub fn watchos_sim_llvm_target(arch: &str) -> String {
123+
let (major, minor) = watchos_deployment_target();
124+
format!("{}-apple-watchos{}.{}.0-simulator", arch, major, minor)
125+
}

compiler/rustc_target/src/spec/apple_sdk_base.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ use Arch::*;
55
#[derive(Copy, Clone)]
66
pub enum Arch {
77
Armv7,
8+
Armv7k,
89
Armv7s,
910
Arm64,
11+
Arm64_32,
1012
I386,
1113
X86_64,
1214
X86_64_macabi,
@@ -26,8 +28,10 @@ fn target_abi(arch: Arch) -> String {
2628
fn target_cpu(arch: Arch) -> String {
2729
match arch {
2830
Armv7 => "cortex-a8", // iOS7 is supported on iPhone 4 and higher
31+
Armv7k => "cortex-a8",
2932
Armv7s => "cortex-a9",
3033
Arm64 => "apple-a7",
34+
Arm64_32 => "apple-s4",
3135
I386 => "yonah",
3236
X86_64 => "core2",
3337
X86_64_macabi => "core2",
@@ -39,7 +43,7 @@ fn target_cpu(arch: Arch) -> String {
3943

4044
fn link_env_remove(arch: Arch) -> Vec<String> {
4145
match arch {
42-
Armv7 | Armv7s | Arm64 | I386 | X86_64 | Arm64_sim => {
46+
Armv7 | Armv7k | Armv7s | Arm64 | Arm64_32 | I386 | X86_64 | Arm64_sim => {
4347
vec!["MACOSX_DEPLOYMENT_TARGET".to_string()]
4448
}
4549
X86_64_macabi | Arm64_macabi => vec!["IPHONEOS_DEPLOYMENT_TARGET".to_string()],
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
use super::apple_sdk_base::{opts, Arch};
2+
use crate::spec::{Target, TargetOptions};
3+
4+
pub fn target() -> Target {
5+
let base = opts("watchos", Arch::Arm64_32);
6+
Target {
7+
llvm_target: "arm64_32-apple-watchos".to_string(),
8+
pointer_width: 32,
9+
data_layout: "e-m:o-p:32:32-i64:64-i128:128-n32:64-S128".to_string(),
10+
arch: "aarch64".to_string(),
11+
options: TargetOptions {
12+
features: "+neon,+fp-armv8,+apple-a7".to_string(),
13+
max_atomic_width: Some(64),
14+
unsupported_abis: super::arm_base::unsupported_abis(),
15+
forces_embed_bitcode: true,
16+
// These arguments are not actually invoked - they just have
17+
// to look right to pass App Store validation.
18+
bitcode_llvm_cmdline: "-triple\0\
19+
arm64_32-apple-watchos5.0.0\0\
20+
-emit-obj\0\
21+
-disable-llvm-passes\0\
22+
-target-abi\0\
23+
darwinpcs\0\
24+
-Os\0"
25+
.to_string(),
26+
..base
27+
},
28+
}
29+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
use super::apple_sdk_base::{opts, Arch};
2+
use crate::spec::{Target, TargetOptions};
3+
4+
pub fn target() -> Target {
5+
let base = opts("watchos", Arch::Armv7k);
6+
Target {
7+
llvm_target: "armv7k-apple-watchos".to_string(),
8+
pointer_width: 32,
9+
data_layout: "e-m:o-p:32:32-Fi8-i64:64-a:0:32-n32-S128".to_string(),
10+
arch: "arm".to_string(),
11+
options: TargetOptions {
12+
features: "+v7".to_string(),
13+
max_atomic_width: Some(64),
14+
unsupported_abis: super::arm_base::unsupported_abis(),
15+
..base
16+
},
17+
}
18+
}

compiler/rustc_target/src/spec/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,10 @@ supported_targets! {
923923
("aarch64-apple-tvos", aarch64_apple_tvos),
924924
("x86_64-apple-tvos", x86_64_apple_tvos),
925925

926+
("armv7k-apple-watchos", armv7k_apple_watchos),
927+
("arm64_32-apple-watchos", arm64_32_apple_watchos),
928+
("x86_64-apple-watchos-sim", x86_64_apple_watchos_sim),
929+
926930
("armebv7r-none-eabi", armebv7r_none_eabi),
927931
("armebv7r-none-eabihf", armebv7r_none_eabihf),
928932
("armv7r-none-eabi", armv7r_none_eabi),
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
use super::apple_sdk_base::{opts, Arch};
2+
use crate::spec::{StackProbeType, Target, TargetOptions};
3+
4+
pub fn target() -> Target {
5+
let base = opts("watchos", Arch::X86_64);
6+
7+
let arch = "x86_64";
8+
let llvm_target = super::apple_base::watchos_sim_llvm_target(arch);
9+
10+
Target {
11+
llvm_target: llvm_target,
12+
pointer_width: 64,
13+
data_layout: "e-m:o-i64:64-f80:128-n8:16:32:64-S128".to_string(),
14+
arch: "x86_64".to_string(),
15+
options: TargetOptions {
16+
max_atomic_width: Some(64),
17+
// don't use probe-stack=inline-asm until rust#83139 and rust#84667 are resolved
18+
stack_probes: StackProbeType::Call,
19+
forces_embed_bitcode: true,
20+
// Taken from a clang build on Xcode 11.4.1.
21+
// These arguments are not actually invoked - they just have
22+
// to look right to pass App Store validation.
23+
bitcode_llvm_cmdline: "-triple\0\
24+
x86_64-apple-watchos5.0-simulator\0\
25+
-emit-obj\0\
26+
-disable-llvm-passes\0\
27+
-target-abi\0\
28+
darwinpcs\0\
29+
-Os\0"
30+
.to_string(),
31+
..base
32+
},
33+
}
34+
}

library/panic_unwind/src/dwarf/eh.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ pub enum EHAction {
4949
Terminate,
5050
}
5151

52-
pub const USING_SJLJ_EXCEPTIONS: bool = cfg!(all(target_os = "ios", target_arch = "arm"));
52+
pub const USING_SJLJ_EXCEPTIONS: bool =
53+
cfg!(all(any(target_os = "ios", target_os = "watchos"), target_arch = "arm"));
5354

5455
pub unsafe fn find_eh_action(lsda: *const u8, context: &EHContext<'_>) -> Result<EHAction, ()> {
5556
if lsda.is_null() {

library/panic_unwind/src/gcc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ const UNWIND_DATA_REG: (i32, i32) = (10, 11); // x10, x11
131131
// https://github.com/gcc-mirror/gcc/blob/trunk/libgcc/unwind-c.c
132132

133133
cfg_if::cfg_if! {
134-
if #[cfg(all(target_arch = "arm", not(target_os = "ios"), not(target_os = "netbsd")))] {
134+
if #[cfg(all(target_arch = "arm", not(target_os = "ios"), not(target_os = "watchos"), not(target_os = "netbsd")))] {
135135
// ARM EHABI personality routine.
136136
// https://infocenter.arm.com/help/topic/com.arm.doc.ihi0038b/IHI0038B_ehabi.pdf
137137
//

library/std/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ fn main() {
1515
|| target.contains("illumos")
1616
|| target.contains("apple-darwin")
1717
|| target.contains("apple-ios")
18+
|| target.contains("apple-watchos")
1819
|| target.contains("uwp")
1920
|| target.contains("windows")
2021
|| target.contains("fuchsia")

library/unwind/src/libunwind.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ pub const unwinder_private_data_size: usize = 5;
3030
#[cfg(target_arch = "x86_64")]
3131
pub const unwinder_private_data_size: usize = 6;
3232

33-
#[cfg(all(target_arch = "arm", not(target_os = "ios")))]
33+
#[cfg(all(target_arch = "arm", not(any(target_os = "ios", target_os = "watchos"))))]
3434
pub const unwinder_private_data_size: usize = 20;
3535

36-
#[cfg(all(target_arch = "arm", target_os = "ios"))]
36+
#[cfg(all(target_arch = "arm", any(target_os = "ios", target_os = "watchos")))]
3737
pub const unwinder_private_data_size: usize = 5;
3838

3939
#[cfg(all(target_arch = "aarch64", target_pointer_width = "64"))]
@@ -105,7 +105,7 @@ extern "C" {
105105
}
106106

107107
cfg_if::cfg_if! {
108-
if #[cfg(any(target_os = "ios", target_os = "netbsd", not(target_arch = "arm")))] {
108+
if #[cfg(any(target_os = "ios", target_os = "watchos", target_os = "netbsd", not(target_arch = "arm")))] {
109109
// Not ARM EHABI
110110
#[repr(C)]
111111
#[derive(Copy, Clone, PartialEq)]
@@ -240,7 +240,7 @@ if #[cfg(any(target_os = "ios", target_os = "netbsd", not(target_arch = "arm")))
240240
} // cfg_if!
241241

242242
cfg_if::cfg_if! {
243-
if #[cfg(not(all(target_os = "ios", target_arch = "arm")))] {
243+
if #[cfg(not(all(any(target_os = "ios", target_os = "watchos"), target_arch = "arm")))] {
244244
// Not 32-bit iOS
245245
#[cfg_attr(
246246
all(feature = "llvm-libunwind", any(target_os = "fuchsia", target_os = "linux")),

0 commit comments

Comments
 (0)