Commit 3b460cd
feat(watchos): arm64_32 device support (Apple Watch Series 4-8 / SE) (#5060)
* feat(watchos): arm64_32 device support (Series 4-8 / SE)
Real pre-S9 Apple Watches use the arm64_32 architecture (64-bit ISA,
32-bit pointers). Perry never produced a working binary for them, and an
old note claimed it was architecturally impossible (NaN-boxing needs
64-bit usize). That's overstated: a 32-bit pointer fits trivially in the
48-bit NaN payload — only a few heap-range guard heuristics and literal
constants assumed a 64-bit address space.
Runtime (32-bit literal fixes; also benefit wasm32):
- array/from_concat: (1usize << 53) saturates via try_from on 32-bit
- box.rs / formatting.rs / value/dynamic_object.rs: 2^47/2^48 pointer-
guard upper bounds compared in u64 so the literal isn't out-of-range
for 32-bit usize (no-op on 32-bit — no addresses reach that high)
The heap-min *value* guards already pick the low (0x1000) floor on
target_os=watchos, so no value changes were needed there.
Compile driver (opt-in via PERRY_WATCHOS_ARM64_32, so the default
watchos=arm64/S9+ path is untouched):
- codegen emits the C entry via PERRY_ENTRY_SYMBOL (e.g. _perry_user_main)
instead of renaming _main with rust-objcopy afterwards — objcopy's
MachOWriter segfaults on arm64_32 Mach-O. The link-time objcopy rename
is skipped on arm64_32 accordingly.
- helpers.rs / app_metadata.rs / link/mod.rs / platform_cmd.rs /
bundle_apple.rs resolve the arm64_32-apple-watchos triple (codegen,
auto-optimize runtime rebuild, native-lib build, swiftc, link) and a
low MinimumOSVersion (PERRY_WATCHOS_MIN, default 11.0).
Validated end to end: built a real game (Bloom Jump) — perry-runtime +
perry-ui-watchos + engine native lib all compile for arm64_32-apple-
watchos; the game links to a Mach-O 'architecture: arm64_32, platform
WATCHOS, minos 11.0' with __perry_user_main and _main both defined and
no undefined refs. (Testable only on real pre-S9 hardware — the
simulator is arm64.)
Co-authored from a parked WIP exploring this target.
* style: rustfmt the arm64_32 entry-symbol changes
---------
Co-authored-by: Ralph Küpper <ralph@skelpo.com>1 parent 3dc1c94 commit 3b460cd
10 files changed
Lines changed: 66 additions & 13 deletions
File tree
- crates
- perry-codegen/src/codegen
- perry-runtime/src
- array
- builtins
- value
- perry/src/commands/compile
- link
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
135 | | - | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
136 | 144 | | |
137 | 145 | | |
138 | 146 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
397 | 397 | | |
398 | 398 | | |
399 | 399 | | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
400 | 406 | | |
401 | 407 | | |
402 | 408 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
413 | 413 | | |
414 | 414 | | |
415 | 415 | | |
416 | | - | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
417 | 419 | | |
418 | 420 | | |
419 | 421 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
90 | | - | |
| 90 | + | |
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
| |||
200 | 200 | | |
201 | 201 | | |
202 | 202 | | |
203 | | - | |
| 203 | + | |
204 | 204 | | |
205 | 205 | | |
206 | 206 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1694 | 1694 | | |
1695 | 1695 | | |
1696 | 1696 | | |
1697 | | - | |
| 1697 | + | |
| 1698 | + | |
| 1699 | + | |
| 1700 | + | |
1698 | 1701 | | |
1699 | 1702 | | |
1700 | 1703 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
90 | | - | |
| 90 | + | |
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
161 | 168 | | |
162 | 169 | | |
163 | 170 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
176 | | - | |
177 | | - | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
178 | 182 | | |
179 | 183 | | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
180 | 187 | | |
181 | 188 | | |
182 | 189 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1762 | 1762 | | |
1763 | 1763 | | |
1764 | 1764 | | |
| 1765 | + | |
| 1766 | + | |
| 1767 | + | |
| 1768 | + | |
| 1769 | + | |
| 1770 | + | |
| 1771 | + | |
| 1772 | + | |
1765 | 1773 | | |
1766 | 1774 | | |
| 1775 | + | |
| 1776 | + | |
| 1777 | + | |
1767 | 1778 | | |
1768 | | - | |
1769 | | - | |
1770 | 1779 | | |
1771 | 1780 | | |
1772 | 1781 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
56 | 62 | | |
57 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
58 | 67 | | |
59 | | - | |
60 | | - | |
| 68 | + | |
61 | 69 | | |
62 | 70 | | |
63 | 71 | | |
| |||
108 | 116 | | |
109 | 117 | | |
110 | 118 | | |
111 | | - | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
112 | 123 | | |
113 | 124 | | |
114 | 125 | | |
| |||
0 commit comments