Skip to content

feat(bridge): macOS Mach-O bridge via ld64.lld (BR-3) - #31

Merged
zackees merged 1 commit into
mainfrom
br3-macho-bridge
Aug 7, 2026
Merged

zackees merged 1 commit into
mainfrom
br3-macho-bridge

Conversation

@zackees

@zackees zackees commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Implements BR-3 (#17), adapted to the bridge strategy. Closes #29. Follows BR-1 (#20, the Windows COFF bridge this generalizes).

What

Makes reld link Mach-O on macOS by delegating to ld64.lld — generalizing the COFF-only bridge to be format-aware. This completes the "runs everywhere" promise: Linux native + Windows bridge + macOS bridge.

  • BridgeTarget { Coff, MachO } parameterizes the bridge: concrete driver (lld-link / ld64.lld) and rust-lld flavor (link / darwin). discover_linker, find_concrete_linker, not_found_message, and the -flavor prepend all key off the target. RELD_BRIDGE_LINKER override + raw-argv pass-through + exit-code propagation are unchanged.
  • Routing: is_macho() / bridge_target() on Args; main.rs routes Some(target) to run_bridge(argv, target) before parsing. So a macOS host, ld64.reld, or -flavor darwin all reach the Mach-O bridge; ELF is untouched. The COFF path is behaviorally identical (verified).
  • macOS CI e2e on the macos-arm64 leg: builds ci/e2e/sqlite-bridge with reld as the linker via -Clinker-flavor=ld64.lld (so rustc emits ld64-native argv that reld forwards to ld64.lld), runs it, asserts OK + linked SQLite. ld64.lld handles ad-hoc signing itself, so D6 is deferred, not solved.

Testing

  • Local (verified here): fmt/clippy clean; 13 bridge unit tests pass covering both COFF link and Mach-O darwin flavor paths (prefix only for rust-lld, exactly one -flavor pair, concrete drivers get no prefix); YAML valid; the Windows COFF rusqlite e2e still returns OK (COFF non-regression). -Clinker-flavor=ld64.lld confirmed a valid rustc 1.94 flavor against the compiler's own accepted list.
  • CI (the real Mach-O proof): the new macos-arm64 e2e step runs on the runner's ld64.lld (rust-lld / brew llvm@18).

Review

Independent review: APPROVE-WITH-NITS — confirmed the COFF path is behaviorally unchanged, no COFF assumptions leak into the Mach-O path, and the macOS e2e can't false-green (set -euo pipefail, failing command-substitution under -e, two grep gates, fixture returns nonzero on error). Its one actionable nit (leftover hedging in the flavor comment) is resolved here now that the spelling is confirmed valid.

The one thing static analysis can't settle — that -Clinker-flavor=ld64.lld on rustc 1.94 emits exactly the ld64 argv ld64.lld expects — is what the macos-arm64 CI leg exists to confirm.

🤖 Generated with Claude Code

…ld (BR-3)

Extend the COFF-only bridge (BR-1) to be format-aware: a BridgeTarget selects
the concrete driver (lld-link for COFF, ld64.lld for Mach-O) and the rust-lld
flavor (link vs darwin). reld now routes Mach-O links (macOS host, ld64.reld,
or -flavor darwin) through the same discovery + raw-argv pass-through as COFF,
delegating to ld64.lld. Exit-code propagation and the -flavor de-duplication
are unchanged; the COFF path is behaviorally identical.

Add a macos-arm64 CI e2e that builds ci/e2e/sqlite-bridge with reld as the
linker (via -Clinker-flavor=ld64.lld so rustc emits ld64-native argv) and runs
it, asserting OK + linked SQLite — the real Mach-O proof on the runner's
ld64.lld. Native Mach-O codegen (#8) remains separate; this makes macOS work now.

Closes #29

Co-Authored-By: Claude Fable 5 <[email protected]>
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.

BR-3: macOS Mach-O bridge — reld links via ld64.lld (rust-lld)

1 participant