Commit c634c9b
Fix a couple of issues that prevent wasmtime for compiling/running on arm64_32 (Apple Watch) (#13259)
* unwinder: type aarch64 register-bearing locals as u64
`crates/unwinder/src/arch/aarch64.rs` has inline-asm operands that take
register-width values. They were typed `usize`, which works on the usual
`aarch64-*` LP64 targets where `usize` is `u64` and the operand class is
unambiguously the 64-bit GPR view. On `arm64_32-apple-watchos` (ILP32
ABI: 64-bit registers, 32-bit pointers) `usize` is `u32`, which makes
the same operands ambiguous between the `w<N>` (32-bit lane) and `x<N>`
(64-bit GPR) views — exactly what rustc's `asm_sub_register` lint flags.
Relying on the ISA-side zero-extend that aarch64 happens to perform on
`mov w<N>, ...` would also be relying on a property the language
doesn't promise: the Rust Reference is explicit that the upper bits of
a register holding a sub-register-width input are *undefined*[0].
Rather than leak `u64` into the public surface (the `Unwind` trait, the
shared `arch/mod.rs` dispatch, and the per-arch backends in `x86.rs`,
`riscv64.rs`, `s390x.rs`), keep the public function signatures `usize`
— that's the existing convention shared with the other backends, and
the `u64`-vs-pointer-width split is unique to aarch64-on-ILP32. Inside
this module, type any register-bearing local that participates in
inline asm as `u64`, and cast at the boundaries:
- `u64::try_from(v).unwrap()` widens `usize` → `u64` (infallible on
every supported Rust target, the `.unwrap()` documents that any
failure would be a target-property issue).
- `as usize` narrows `u64` → `usize` at the return — truncates on
`arm64_32` by design (the saved PC/SP there is a 32-bit host
pointer that fits exactly in the low 32 bits) and is the identity
on aarch64 LP64.
Also switch the saved-LR load from `*(fp as *mut usize).offset(1)` to
`*(fp as *mut u64).offset(1)`. AAPCS64 reserves two 64-bit slots for
the frame record on every aarch64 ABI variant — including `arm64_32` —
so an 8-byte stride is correct regardless of pointer width. With
`*mut usize` on `arm64_32` `.offset(1)` would advance by only 4 bytes
and read the upper half of the saved-FP slot. This is a latent
correctness fix; today the unwinder isn't exercised on `arm64_32`
(which runs Pulley, not Cranelift-compiled native code), but the
corrected form is the right one to land alongside the type change.
No behaviour change on existing aarch64 LP64 targets. Silences two
`asm_sub_register` warnings on a future `arm64_32-apple-watchos` build
of this crate.
[0]: https://doc.rust-lang.org/reference/inline-assembly.html#r-asm.register-operands.smaller-value
* Bump mach2 dep from 0.4.2 to 0.6
mach2 v0.4.2 emits `compile_error!("mach requires macOS or iOS")` on any
target where neither `target_os = "macos"` nor `target_os = "ios"` matches.
That blocks every Apple non-iOS-non-macOS platform — most pressingly
arm64_32-apple-watchos for embedders shipping wasmtime on Apple Watch.
The fix has been upstream in mach2 since 0.6.0 (commit `538ce75`,
2025-08-16, "Add support for tvOS, watchOS and visionOS"), which widens
the cfg gate from `cfg(any(macos, ios))` to `cfg(target_vendor = "apple")`
on both the `compile_error!` and the `libc` build-dep, with no public-API
changes in the modules wasmtime imports
(`exc`, `exception_types`, `kern_return`, `mach_init`, `mach_port`,
`message`, `ndr`, `port`, `thread_act`, `thread_status`).
Verified by building wasmtime as a `staticlib` for `arm64_32-apple-watchos`
under `nightly-2026-01-25 + -Z build-std=std,panic_abort` with
`--features pulley,runtime,std,cranelift,anyhow` — no other changes
needed in `crates/wasmtime/src/runtime/vm/sys/unix/machports.rs`.
The dev-only path (`cranelift-jit -> region -> mach2 0.4.x`) keeps an
older mach2 in the lockfile for cranelift-jit's own host tests; that
path is not part of any production embedder build and stays unchanged.
Closes the watchOS port story without needing a separate mach2 release.
* Add vets for mach2
---------
Co-authored-by: Alex Crichton <[email protected]>1 parent 689eae7 commit c634c9b
5 files changed
Lines changed: 104 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
394 | 394 | | |
395 | 395 | | |
396 | 396 | | |
397 | | - | |
| 397 | + | |
398 | 398 | | |
399 | 399 | | |
400 | 400 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
2 | 47 | | |
3 | 48 | | |
4 | 49 | | |
5 | | - | |
| 50 | + | |
6 | 51 | | |
7 | 52 | | |
8 | 53 | | |
9 | 54 | | |
10 | 55 | | |
11 | 56 | | |
12 | 57 | | |
13 | | - | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
14 | 61 | | |
15 | 62 | | |
16 | 63 | | |
| |||
26 | 73 | | |
27 | 74 | | |
28 | 75 | | |
29 | | - | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
30 | 79 | | |
31 | 80 | | |
32 | 81 | | |
| |||
35 | 84 | | |
36 | 85 | | |
37 | 86 | | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
38 | 90 | | |
39 | 91 | | |
40 | 92 | | |
| |||
44 | 96 | | |
45 | 97 | | |
46 | 98 | | |
47 | | - | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
48 | 104 | | |
49 | 105 | | |
50 | 106 | | |
| |||
55 | 111 | | |
56 | 112 | | |
57 | 113 | | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
58 | 123 | | |
59 | 124 | | |
60 | 125 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7095 | 7095 | | |
7096 | 7096 | | |
7097 | 7097 | | |
| 7098 | + | |
| 7099 | + | |
| 7100 | + | |
| 7101 | + | |
| 7102 | + | |
| 7103 | + | |
| 7104 | + | |
| 7105 | + | |
| 7106 | + | |
| 7107 | + | |
| 7108 | + | |
| 7109 | + | |
7098 | 7110 | | |
7099 | 7111 | | |
7100 | 7112 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1031 | 1031 | | |
1032 | 1032 | | |
1033 | 1033 | | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
1034 | 1046 | | |
1035 | 1047 | | |
1036 | 1048 | | |
| |||
3186 | 3198 | | |
3187 | 3199 | | |
3188 | 3200 | | |
3189 | | - | |
3190 | | - | |
3191 | | - | |
3192 | | - | |
3193 | | - | |
3194 | | - | |
3195 | 3201 | | |
3196 | 3202 | | |
3197 | 3203 | | |
| |||
0 commit comments