Skip to content

macOS / POSIX build support (supersedes #10) - #13

Merged
mstan merged 3 commits into
masterfrom
macos-support
May 29, 2026
Merged

macOS / POSIX build support (supersedes #10)#13
mstan merged 3 commits into
masterfrom
macos-support

Conversation

@mstan

@mstan mstan commented May 29, 2026

Copy link
Copy Markdown
Owner

Native macOS (Apple Silicon + Intel) build support for the recompiler and game runners. Both Super Mario Bros. and The Legend of Zelda build and run natively on arm64 macOS; Zelda plays cleanly end-to-end.

Credit

This is a rebase of @nbudin's work in #10 onto current master. That PR branched ~39 commits back and could not be cleanly rebased in place (it lives on a fork), so its changes were re-applied here with authorship preserved (Co-authored-by on the port commit). Thanks, @nbudin! Once this merges, #10 can be closed as superseded.

What's here

From #10 (rebased):

  • POSIX ucontext coroutine backend, replacing the non-Windows #error stub (matches the current coroutine.h API)
  • Cross-platform directory creation (make_dir macro over _mkdir/mkdir)
  • mapper_init declaration fixed to match mapper.h/mapper.c
  • clang narrowing flags for the optional nestopia oracle build

Additional fixes surfaced by building on Apple Clang (MSVC silently tolerated these):

  • code_generator.c now emits forward declarations into the generated _dispatch.c — previously it relied on implicit function declarations, a hard error under clang/gcc C99+. Fixed in the generator, not the artifact (RULE 1).
  • Declared four runtime_* functions in nes_runtime.h that were defined in runtime.c but called without a prior declaration.
  • Removed a stale duplicate declaration of debug_server_get_frame_record.

Docs:

  • README: cross-platform build instructions (macOS/Linux), a Platform Support table, an experimental note, and acknowledgement of @nbudin.

Notes

  • launcher.c / override_chr.c already had POSIX branches on master, so they're untouched.
  • macOS support is marked experimental in the README. SMB shows minor timing/demo quirks (pre-existing, also noted in its own README); Zelda is clean.
  • Game repos need no per-project build changes — they pick this up by bumping their nesrecomp.pin and regenerating.

🤖 Generated with Claude Code

mstan and others added 3 commits May 29, 2026 10:34
Re-applies the macOS portability work from PR #10 onto current master
(the PR branched ~39 commits back and could not be cleanly rebased):

- recompiler/main_nes.c: abstract _mkdir/direct.h behind a make_dir() macro
  with a POSIX sys/stat.h mkdir() fallback
- runner/coroutine.c: POSIX ucontext_t coroutine backend, replacing the
  non-Windows #error stub (matches the current coroutine.h API surface)
- runner/nes_runtime.h: fix stale 2-arg mapper_init declaration to match
  the 4-arg definition in mapper.h / mapper.c
- runner/nestopia_cmake.cmake: clang narrowing flags for oracle builds

launcher.c and override_chr.c already gained POSIX branches on master, so
they are unchanged here.

Co-authored-by: Nat Budin <nbudin@actbluetech.com>
Building Super Mario Bros. on macOS (AppleClang) surfaced three latent
issues that MSVC silently tolerated:

- code_generator.c: emit forward declarations into the generated _dispatch.c
  (call_by_address) translation unit. Previously only _full.c got them, so
  dispatch.c relied on implicit function declarations — a hard error under
  clang/gcc C99+. RULE 1 fix: corrected in the generator, not the artifact.
- nes_runtime.h: declare runtime_get_ppu_t / runtime_scroll_from_t_valid /
  runtime_get_latch_state / runtime_set_latch_state (defined in runtime.c,
  called from ppu_renderer.c without a prior declaration).
- debug_server.h: remove a stale duplicate declaration of
  debug_server_get_frame_record (uint32_t) that conflicted with the
  uint64_t definition.

With these, the recompiler and the SMB runner build clean and the game
boots natively on arm64 macOS.
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.

1 participant