Skip to content

macOS: signed Mach-O for x86_64-macos and aarch64-macos via libSystem - #44

Merged
dev-dami merged 6 commits into
mainfrom
agent/xp-macos
Nov 23, 2026
Merged

dev-dami merged 6 commits into
mainfrom
agent/xp-macos

Conversation

@dev-dami

Copy link
Copy Markdown
Owner

trackc build --target x86_64-macos and --target aarch64-macos now write Mach-O executables, built from any host.

  • macho.trk:
    • the full set of load commands: __PAGEZERO, __TEXT, __DATA_CONST with __got, __DATA, __LINKEDIT, dyld info, symtab, dyld, LC_MAIN, libSystem, LC_BUILD_VERSION with minos 11 and LC_UUID;
    • imports bind into the GOT through dyld bind opcodes;
    • an ad-hoc, linker-signed code signature (SHA-256 over 4 KiB pages), which Apple Silicon requires.
  • rt/os/macos.trk: the OS interface through libSystem. It maps open/mmap flags, the stat layout and clock ids, and reads errno through __error().
  • aarch64: the A64 translator now decodes import calls into adrp/ldr/blr with the AAPCS64 argument shuffle. Card XD (Windows on ARM) reuses this.
  • Language: extern "lib" fn name(...) as "symbol"; names the C symbol, so a runtime name can differ from the libSystem name (for example write and close).
  • Checks: tests/tools/macho_check.py is an independent parser that recomputes every signature hash. It runs in tests/sh/macos.sh.
  • CI: macos-cross cross-builds and uploads the binaries. macos runs them on macos-15-intel and macos-latest (Apple Silicon): the examples are compared against their goldens, and trackc rebuilds hello on the Mac and must produce the same bytes.

Verification:

  • llvm-objdump and llvm-readobj parse all 32 images (hello, the 15 examples and trackc, for each arch) cleanly.
  • macho_check verifies all 32 signatures and catches a one-byte corruption.
  • After merging main and reseeding, a clean bootstrap reaches its fixed point and 115 of 115 tests pass.

Not yet run on a real Mac. The macos CI job is the first run.

🤖 Generated with Claude Code

dev-dami and others added 6 commits November 23, 2026 01:15
…via libSystem; extern as "sym"

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rm64 Mach-O fixups; no variadic open

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ross-build and Mac run jobs, docs; macOS host default; reseed

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	.github/workflows/ci.yml
#	bootstrap/seed/trackc
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dev-dami
dev-dami merged commit 233d410 into main Nov 23, 2026
2 of 3 checks passed
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

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