Skip to content

osdlib_retro: flush the instruction cache on macOS - #580

Merged
sonninnos merged 1 commit into
libretro:masterfrom
sevdestruct:macos-icache-flush
Sep 21, 2026
Merged

sonninnos merged 1 commit into
libretro:masterfrom
sevdestruct:macos-icache-flush

Conversation

@sevdestruct

@sevdestruct sevdestruct commented Sep 21, 2026 •

Copy link
Copy Markdown

invalidate_instruction_cache skips the cache flush under !defined(TARGET_OS_IPHONE), but Apple's TargetConditionals.h defines TARGET_OS_IPHONE as 0 on macOS — so the guard is false there and the flush never runs. On Apple Silicon, recompiler output can then execute stale: an arm64 platform=osx build of the hng64 driver died with SIGILL on a valid instruction on first run.

Fix: test the macro's value, not its presence. iOS is unchanged.

Verified: unpatched crashes on the same run; patched, sams64 and xrally run 1800 frames matching the buildbot core.

(Reopening — I closed this by accident while tidying branches. Patch is unchanged.)

invalidate_instruction_cache skipped the flush under !defined(TARGET_OS_IPHONE).
Apple's TargetConditionals.h DEFINES TARGET_OS_IPHONE as 0 on macOS, so the
guard was false there and Apple Silicon ran stale code in recompiler output:
the first hng64 build died with SIGILL on a valid instruction (movz x14,#0x4f10).

Test the macro's value, not its presence. Control: the unpatched build crashes
on the same run; patched, sams64 and xrally run 1800 frames with the same
distinct-frame counts as the buildbot's full core.
@sevdestruct
sevdestruct deleted the macos-icache-flush branch September 21, 2026 04:47
@sevdestruct sevdestruct changed the title osdlib_retro: flush the instruction cache on macOS (TARGET_OS_IPHONE is defined as 0 there) closed Sep 21, 2026
@sevdestruct sevdestruct changed the title closed osdlib_retro: flush the instruction cache on macOS Sep 21, 2026
@sevdestruct
sevdestruct restored the macos-icache-flush branch September 21, 2026 06:10
@sevdestruct sevdestruct reopened this Sep 21, 2026
@sonninnos
sonninnos merged commit f65d5ba into libretro:master Sep 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants