From 2aa13cba7371c5e7d0bd80b7ba316e26d7974ef2 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 20 Dec 2024 14:08:26 -0800 Subject: [PATCH] Add aarch64-apple-ios to platform-check matrix This commit is somewhat of a rebase of #7506 to port most of it to `main`. I've left out any test-related changes since we're not testing anything just yet. I've also found that rustc now has `target_vendor = "apple"` to cover both macOS and iOS targets (and presumably other targets like tvOS as well if they get added) Closes #7506 --- .github/workflows/main.yml | 3 +++ crates/asm-macros/src/lib.rs | 2 +- crates/fiber/src/stackswitch/aarch64.rs | 2 +- crates/jit-icache-coherence/Cargo.toml | 2 +- crates/wasmtime/Cargo.toml | 2 +- crates/wasmtime/src/runtime/vm/sys/unix/mod.rs | 2 +- .../wasmtime/src/runtime/vm/sys/unix/signals.rs | 16 ++++++++-------- 7 files changed, 16 insertions(+), 13 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2397a9f322ae..783bb05e933e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -553,6 +553,9 @@ jobs: - target: wasm32-wasip1 os: ubuntu-latest test: cargo build --no-default-features --features compile,cranelift,all-arch + - target: aarch64-apple-ios + os: macos-latest + test: cargo build steps: - uses: actions/checkout@v4 with: diff --git a/crates/asm-macros/src/lib.rs b/crates/asm-macros/src/lib.rs index 92b04380b489..bb70bb199345 100644 --- a/crates/asm-macros/src/lib.rs +++ b/crates/asm-macros/src/lib.rs @@ -9,7 +9,7 @@ #![no_std] cfg_if::cfg_if! { - if #[cfg(target_os = "macos")] { + if #[cfg(target_vendor = "apple")] { #[macro_export] macro_rules! asm_func { ($name:expr, $body:expr $(, $($args:tt)*)?) => { diff --git a/crates/fiber/src/stackswitch/aarch64.rs b/crates/fiber/src/stackswitch/aarch64.rs index 92a09c24b0b1..c0b9272f8ee0 100644 --- a/crates/fiber/src/stackswitch/aarch64.rs +++ b/crates/fiber/src/stackswitch/aarch64.rs @@ -22,7 +22,7 @@ use super::wasmtime_fiber_start; use wasmtime_asm_macros::asm_func; cfg_if::cfg_if! { - if #[cfg(target_os = "macos")] { + if #[cfg(target_vendor = "apple")] { macro_rules! paci1716 { () => ("pacib1716\n"); } macro_rules! pacisp { () => ("pacibsp\n"); } macro_rules! autisp { () => ("autibsp\n"); } diff --git a/crates/jit-icache-coherence/Cargo.toml b/crates/jit-icache-coherence/Cargo.toml index 5612c2af516d..365e65535e49 100644 --- a/crates/jit-icache-coherence/Cargo.toml +++ b/crates/jit-icache-coherence/Cargo.toml @@ -24,7 +24,7 @@ features = [ "Win32_System_Diagnostics_Debug", ] -[target.'cfg(any(target_os = "linux", target_os = "macos", target_os = "freebsd", target_os = "android"))'.dependencies] +[target.'cfg(any(target_os = "linux", target_vendor = "apple", target_os = "freebsd", target_os = "android"))'.dependencies] libc = { workspace = true } [features] diff --git a/crates/wasmtime/Cargo.toml b/crates/wasmtime/Cargo.toml index ef2db1f2ca69..d67a10f8aaf7 100644 --- a/crates/wasmtime/Cargo.toml +++ b/crates/wasmtime/Cargo.toml @@ -89,7 +89,7 @@ ittapi = { workspace = true, optional = true } [target.'cfg(target_os = "linux")'.dependencies] memfd = { workspace = true, optional = true } -[target.'cfg(target_os = "macos")'.dependencies] +[target.'cfg(target_vendor = "apple")'.dependencies] mach2 = { workspace = true, optional = true } [target.'cfg(unix)'.dependencies] diff --git a/crates/wasmtime/src/runtime/vm/sys/unix/mod.rs b/crates/wasmtime/src/runtime/vm/sys/unix/mod.rs index 3c8fbcccae5d..8c6d90240aa8 100644 --- a/crates/wasmtime/src/runtime/vm/sys/unix/mod.rs +++ b/crates/wasmtime/src/runtime/vm/sys/unix/mod.rs @@ -12,7 +12,7 @@ pub mod unwind; #[cfg(feature = "signals-based-traps")] pub mod vm; -#[cfg(all(feature = "signals-based-traps", target_os = "macos"))] +#[cfg(all(feature = "signals-based-traps", target_vendor = "apple"))] pub mod machports; #[cfg(feature = "signals-based-traps")] pub mod signals; diff --git a/crates/wasmtime/src/runtime/vm/sys/unix/signals.rs b/crates/wasmtime/src/runtime/vm/sys/unix/signals.rs index a4a50003aaa5..06d91dc12e8b 100644 --- a/crates/wasmtime/src/runtime/vm/sys/unix/signals.rs +++ b/crates/wasmtime/src/runtime/vm/sys/unix/signals.rs @@ -31,7 +31,7 @@ impl TrapHandler { pub unsafe fn new(macos_use_mach_ports: bool) -> TrapHandler { // Either mach ports shouldn't be in use or we shouldn't be on macOS, // otherwise the `machports.rs` module should be used instead. - assert!(!macos_use_mach_ports || !cfg!(target_os = "macos")); + assert!(!macos_use_mach_ports || !cfg!(target_vendor = "apple")); foreach_handler(|slot, signal| { let mut handler: libc::sigaction = mem::zeroed(); @@ -63,7 +63,7 @@ impl TrapHandler { } pub fn validate_config(&self, macos_use_mach_ports: bool) { - assert!(!macos_use_mach_ports || !cfg!(target_os = "macos")); + assert!(!macos_use_mach_ports || !cfg!(target_vendor = "apple")); } } @@ -81,7 +81,7 @@ unsafe fn foreach_handler(mut f: impl FnMut(*mut libc::sigaction, i32)) { // Sometimes we need to handle SIGBUS too: // - On Darwin, guard page accesses are raised as SIGBUS. - if cfg!(target_os = "macos") || cfg!(target_os = "freebsd") { + if cfg!(target_vendor = "apple") || cfg!(target_os = "freebsd") { f(addr_of_mut!(PREV_SIGBUS), libc::SIGBUS); } @@ -209,7 +209,7 @@ unsafe extern "C" fn trap_handler( // done running" which will clear the sigaltstack flag and allow // reusing it for the next signal. Then upon resuming in our custom // code we blow away the stack anyway with a longjmp. - if cfg!(target_os = "macos") { + if cfg!(target_vendor = "apple") { unsafe extern "C" fn wasmtime_longjmp_shim(jmp_buf: *const u8) { wasmtime_longjmp(jmp_buf) } @@ -303,13 +303,13 @@ unsafe fn get_trap_registers(cx: *mut libc::c_void, _signum: libc::c_int) -> Tra pc: (cx.uc_mcontext.psw.addr - trap_offset) as usize, fp: *(cx.uc_mcontext.gregs[15] as *const usize), } - } else if #[cfg(all(target_os = "macos", target_arch = "x86_64"))] { + } else if #[cfg(all(target_vendor = "apple", target_arch = "x86_64"))] { let cx = &*(cx as *const libc::ucontext_t); TrapRegisters { pc: (*cx.uc_mcontext).__ss.__rip as usize, fp: (*cx.uc_mcontext).__ss.__rbp as usize, } - } else if #[cfg(all(target_os = "macos", target_arch = "aarch64"))] { + } else if #[cfg(all(target_vendor = "apple", target_arch = "aarch64"))] { let cx = &*(cx as *const libc::ucontext_t); TrapRegisters { pc: (*cx.uc_mcontext).__ss.__pc as usize, @@ -358,7 +358,7 @@ unsafe fn get_trap_registers(cx: *mut libc::c_void, _signum: libc::c_int) -> Tra // See more comments above where this is called for what it's doing. unsafe fn set_pc(cx: *mut libc::c_void, pc: usize, arg1: usize) { cfg_if::cfg_if! { - if #[cfg(not(target_os = "macos"))] { + if #[cfg(not(target_vendor = "apple"))] { let _ = (cx, pc, arg1); unreachable!(); // not used on these platforms } else if #[cfg(target_arch = "x86_64")] { @@ -382,7 +382,7 @@ unsafe fn set_pc(cx: *mut libc::c_void, pc: usize, arg1: usize) { (*cx.uc_mcontext).__ss.__pc = pc as u64; (*cx.uc_mcontext).__ss.__x[0] = arg1 as u64; } else { - compile_error!("unsupported macos target architecture"); + compile_error!("unsupported apple target architecture"); } } }