Skip to content

feat(bridge): explicit engine override + registry — polylinker router foundation (B8a) - #35

Merged
zackees merged 1 commit into
mainfrom
b8a-engine-override
Aug 7, 2026
Merged

zackees merged 1 commit into
mainfrom
b8a-engine-override

Conversation

@zackees

@zackees zackees commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Implements B8a (#34) — the first code slice of the polylinker router (B8 in #17; design in #30 / agents/docs/polylinker.md). Follows the polylinker docs (#33).

What

Turns the bridge's fixed platform→engine mapping into explicit, overridable engine selection:

  • Engine registry (capability seed): an Engine = name + object format + linker basename + rust-lld flavor. Two entries: lld-link/COFF, ld64.lld/Mach-O.
  • select_engine(target, override): no override → the target's default engine (byte-for-byte the previous behavior); an override names an engine, with a hard error on an unknown name (listing valid engines) or a format mismatch (e.g. ld64.lld for a COFF link) — never a silent fallback.
  • Override source, in precedence: a reld-specific --engine=<name> argv token (consumed/stripped from the forwarded argv like -flavor, at any position), then the RELD_ENGINE env var.
  • Observable routing: the note now carries the reason — reld: engine=<name> (bridge, reason=default|override(--engine)|override(RELD_ENGINE)) -> <path>.

Default (no-override) behavior, discovery order, -flavor handling, exit-code propagation, and RELD_BRIDGE_LINKER are all unchanged; ELF/native untouched. Flag/LTO-based routing (Linux native→lld) is a later slice.

Testing

  • Scoped to crates/reld-core/src/bridge.rs. 25/25 bridge tests pass (12 new: select_engine default/valid-override/unknown/format-mismatch both directions; --engine= stripping at start/middle/end + combined with -flavor; engine_override_from_argv present/absent). fmt/clippy --all-targets clean.
  • Windows rusqlite e2e, all three paths verified: default → OK; RELD_ENGINE=lld-link (explicit) → OK; RELD_ENGINE=bogus → build fails with reld: error: Unknown engine 'bogus'. Valid engines: lld-link, ld64.lld. (hard error, not silently ignored).

Review

Independent review: APPROVE-WITH-NITS — confirmed the default path is byte-for-byte identical, an invalid/mismatched override cannot be silently ignored, and --engine= can never leak to the child linker at any argv position. Both LOW nits (symmetric mismatch test; engine_override_from_argv skipping argv[0] to mirror forwarded_args) are applied in this PR.

🤖 Generated with Claude Code

… foundation (B8a)

First implementation slice of the polylinker router (B8/#30). Turn the bridge's
fixed platform->engine mapping into explicit, overridable engine selection:

- An `Engine` registry (name + object format + linker basename + rust-lld
  flavor) — the capability seed: lld-link/COFF, ld64.lld/Mach-O.
- `select_engine(target, override)`: no override -> the target's default engine
  (byte-for-byte the previous behavior); an override names an engine, with a
  hard error on an unknown name (listing valid engines) or a format mismatch
  (e.g. ld64.lld requested for a COFF link) — never a silent fallback.
- Override source, in precedence: a reld-specific `--engine=<name>` argv token
  (consumed/stripped from the forwarded argv like `-flavor`, at any position),
  then the `RELD_ENGINE` env var.
- The routing note now carries the reason: `reld: engine=<name> (bridge,
  reason=default|override(--engine)|override(RELD_ENGINE)) -> <path>`.

Default (no-override) behavior, discovery order, `-flavor` handling, exit-code
propagation, and `RELD_BRIDGE_LINKER` are all unchanged; ELF/native untouched.
Flag/LTO-based routing (the Linux native->lld case) is a later slice.

Closes #34

Co-Authored-By: Claude Fable 5 <[email protected]>
@zackees
zackees merged commit c81fd9a into main Aug 7, 2026
6 checks passed
@zackees
zackees deleted the b8a-engine-override branch August 7, 2026 11:07
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