Browse Source

Fix compilation of wasmtime-fiber on arm macOS (#4341)

Turns out that `adr` doesn't work in inline assembly within LLVM on
arm macOS, or at least not how we were using it. This switches instead
to an `adrp` and `add` pair which seems to convince the linker that the
relocations should all fit. The same pattern is used on Linux as well
only it has different syntax (so much for a portable assembler) for
consistency. Performance isn't really an issue here so there's no need
to go out of our way to get the single-instruction operand working.
pull/4344/head
Alex Crichton 2 years ago
committed by GitHub
parent
commit
2efdd5c46b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      crates/fiber/src/unix/aarch64.rs

15
crates/fiber/src/unix/aarch64.rs

@ -20,15 +20,19 @@
cfg_if::cfg_if! {
if #[cfg(target_os = "macos")] {
macro_rules! cfi_window_save { () => (); }
macro_rules! pacia1716 { () => (); }
macro_rules! paciasp { () => (); }
macro_rules! autiasp { () => (); }
macro_rules! cfi_window_save { () => (""); }
macro_rules! pacia1716 { () => (""); }
macro_rules! paciasp { () => (""); }
macro_rules! autiasp { () => (""); }
macro_rules! sym_adrp { ($s:tt) => (concat!("_", $s, "@PAGE")); }
macro_rules! sym_add { ($s:tt) => (concat!("_", $s, "@PAGEOFF")); }
} else {
macro_rules! cfi_window_save { () => (".cfi_window_save\n"); }
macro_rules! pacia1716 { () => ("pacia1716\n"); }
macro_rules! paciasp { () => ("paciasp\n"); }
macro_rules! autiasp { () => ("autiasp\n"); }
macro_rules! sym_adrp { ($s:tt) => (concat!($s, "")); }
macro_rules! sym_add { ($s:tt) => (concat!(":lo12:", $s)); }
}
}
@ -112,7 +116,8 @@ asm_func!(
.cfi_startproc
hint #34 // bti c
sub x16, x0, #16
adr x17, ", asm_sym!("wasmtime_fiber_start"), "
adrp x17, ", sym_adrp!("wasmtime_fiber_start"), "
add x17, x17, ", sym_add!("wasmtime_fiber_start"), "
",
pacia1716!(),
"

Loading…
Cancel
Save