You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
new_dynarec: native Apple Silicon (darwin-arm64) support
Enable the arm64 new_dynarec on macOS, previously hard-disabled with
NO_ASM=1. Three independent blockers, three fixes:
1. linkage_arm64.S only assembled with ELF toolchains. Add a Mach-O
variant of the symbol macros: leading-underscore C symbols,
.private_extern instead of .hidden (.type/.size dropped, ELF-only),
sym@PAGE/sym@PAGEOFF instead of :lo12: adrp relocations, and '%%'
statement separators because the Darwin arm64 assembler treats ';'
as a comment. Dot-prefixed local labels (ELF-only) become numbered
locals. ELF output is unchanged (verified by cross-assembling for
aarch64-linux before/after).
2. Apple Silicon enforces W^X. The code cache is now allocated with
MAP_JIT at a dynamic address (static memory cannot be made
executable on this platform), and every code path that writes to
the cache is bracketed with pthread_jit_write_protect_np() via
reentrant jit_write_begin/end helpers. The bracket points are the
five C entry points all cache writes funnel through
(new_recompile_block, dynamic_linker{,_ds}, invalidate_block,
invalidate_all_pages) plus the arch_init trampoline setup; the
assembly stubs need no changes because exec mode is the default.
3. cache_flush() reads ctr_el0, which traps (SIGILL) from EL0 on
Apple Silicon. Use the system-provided sys_icache_invalidate()
instead. This was the cause of the "continuous SIGILLs" reported
when compiling the dynarec on M-series machines.
Tested on an M-series Mac (macOS 26.5): two commercial ROMs run on
the dynarec under the stock mupen64plus 2.6.0 frontend/plugins, with
generated code confirmed executing from the MAP_JIT region.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
0 commit comments