Skip to content

Commit

Permalink
Add aarch64-apple-ios to platform-check matrix
Browse files Browse the repository at this point in the history
This commit is somewhat of a rebase of bytecodealliance#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 bytecodealliance#7506
  • Loading branch information
alexcrichton committed Dec 20, 2024
1 parent afd8bb3 commit 2aa13cb
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 13 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion crates/asm-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)*)?) => {
Expand Down
2 changes: 1 addition & 1 deletion crates/fiber/src/stackswitch/aarch64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"); }
Expand Down
2 changes: 1 addition & 1 deletion crates/jit-icache-coherence/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion crates/wasmtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion crates/wasmtime/src/runtime/vm/sys/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
16 changes: 8 additions & 8 deletions crates/wasmtime/src/runtime/vm/sys/unix/signals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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"));
}
}

Expand All @@ -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);
}

Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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")] {
Expand All @@ -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");
}
}
}
Expand Down

0 comments on commit 2aa13cb

Please sign in to comment.