Repository navigation
Description
Part of #17 (phase BR-3, adapted to the bridge strategy). Follows BR-1 (#20, Windows COFF bridge).
Goal
Make reld link a real program on macOS / aarch64-apple-darwin by delegating Mach-O links to ld64.lld (the Mach-O driver in rust-lld), exactly as BR-1 did for Windows/COFF. This completes the "runs everywhere" promise (Linux native + Windows bridge + macOS bridge). Native Mach-O codegen (the wild skeleton, #8) remains a separate, later effort; the bridge makes macOS work now.
Design — generalize the existing bridge to be format-aware
Today crates/reld-core/src/bridge.rs is COFF-only: it discovers lld-link and prepends -flavor link for rust-lld. Generalize it to a target format:
- Introduce a
BridgeTarget { Coff, MachO }(or reusePlatformKind) passed intorun_bridge/discover_linker. - COFF: discover
lld-link(rust-lld-flavor link, thengcc-ld/lld-link, then PATH) — unchanged behavior. - Mach-O: discover
ld64.lld(rust-lld-flavor darwin, thengcc-ld/ld64.lld, thenld64.lldon PATH).RELD_BRIDGE_LINKERoverride still honored; if it resolves torust-lld, prepend the target's flavor (linkvsdarwin). - Route Mach-O to the bridge: add
pub fn is_macho(&self)onArgs, and incrates/reld/src/main.rsrouteif args.is_coff() || args.is_macho() { return reld_core::run_bridge(std::env::args_os(), <target>); }BEFOREargs.parse(). Keep ELF untouched. Leave theArgs::MachO(_) => ...skeleton dispatch inlib.rsas a defensive fallback. - Keep exit-code propagation and the
-flavorde-duplication from BR-1 intact for both formats.
macOS CI e2e (mirror BR-2)
Add a macos-arm64 step to phase1-native in .github/workflows/ci.yml that builds ci/e2e/sqlite-bridge with reld as the linker and runs it (OK, exit 0). Key subtlety: on macOS rustc invokes the linker via the cc driver by default, which passes clang-driver args, NOT ld64 args. To hand reld the ld64-native argv it forwards to ld64.lld, the build must select a direct ld64 linker flavor (research the exact rustc 1.94 spelling — likely -C linker-flavor=ld64 via CARGO_TARGET_AARCH64_APPLE_DARWIN_RUSTFLAGS, plus CARGO_TARGET_AARCH64_APPLE_DARWIN_LINKER=<reld>). ld64.lld performs ad-hoc signing itself, so D6 is deferred, not solved.
Verification
- Windows (local, regression): the COFF bridge must be unchanged —
ci/e2e/sqlite-bridgestill links via reld and runs. - Unit tests: discovery + flavor selection for both Coff and MachO (hermetic, temp files; no real linker spawned).
- macOS (CI): the new macos-arm64 e2e step is the real proof — it runs on the runner's
ld64.lld(brew llvm@18, already installed in CI).
Done when
reld links + runs ci/e2e/sqlite-bridge on the macos-arm64 CI runner; the Windows COFF bridge and ELF paths are unchanged (their e2e/CI stay green); unit tests cover both formats; PR merged, issue closed, branch rebased on origin/main.
Activity