GeezerVison is showing github.com — Polylinker: flag-aware router over bundled linkers (LTO/optimized via routing + fallbacks) — design + docs · Issue #30 · forge-ci/reld
Polylinker: flag-aware router over bundled linkers (LTO/optimized via routing + fallbacks) — design + docs #30DescriptionExtends #17 (decision B8, flag-based engine routing) and #19 (the "router over engines" that lives in the linker daemon). This issue formalizes the polylinker framing and its fallback semantics, and asks for the docs to be updated to match.
Insight
reld is a fat linker: it bundles multiple real linkers per platform (the native engine + the lld bridge today; radlink and others later). Once that's true, reld can support any linker configuration — including optimized/release links and LTO — not by implementing each feature natively, but by routing the request to whichever bundled linker already supports it. reld becomes a polylinker: a flag-aware router over a fleet of bundled linkers, defaulting to the fastest engine for the platform and escalating to a more capable one only when the requested configuration demands it.
This directly reframes today's LTO story (see "Relationship to locked decisions" below).
Proposal — a flag-aware routing layer
- Capability model. Each bundled linker declares which configurations it supports (LTO / ThinLTO, plugin interface, GC-sections, ICF, PDB/DWARF, identity/reproducible output, incremental, per-format: ELF/COFF/Mach-O, etc.). This is a static table plus a probe where cheap.
- Router. On each link, inspect the incoming linker request — argv flags (
-flto, --plugin, /LTCG, /GL, -O levels, --icf, --gc-sections, identity/strip flags, --engine= explicit override, env) — classify the required configuration, and select the bundled linker whose capabilities cover it. Default: the fastest engine for the platform (the dev-loop path). Escalate: LTO/optimized/release-fidelity → the capable engine (e.g. lld with its LTO/plugin support), even on a platform where the native fast engine exists.
- Fallbacks. If the fastest linker can't satisfy a requested configuration, fall back to a capable bundled linker rather than failing — and if no bundled linker supports the configuration, error clearly and specifically (never silently mislink, never silently drop a flag that changes correctness). Fallbacks are ordered by (capability match, then speed).
- Explicit override.
--engine=<name> / RELD_ENGINE forces a specific bundled linker, bypassing routing (for benchmarking and escape hatches).
- Observability / honesty. Every routing decision is logged at note level (
reld: engine=<name> (<reason: default|flag:-flto|fallback:...|override>)), and — per the benchmark honesty policy — the benchmark records which engine produced each number (this is the mode/engine field from BR-4b generalized). A user must always be able to tell which real linker ran and why.
The router is the same "router over engines" that #19 places inside the daemon; this issue defines its policy (capabilities + routing + fallbacks), independent of where it physically runs (in-process bridge today, daemon later).
Relationship to locked decisions — read before objecting
docs/plan/01-DECISIONS.md D13 and README/DESIGN currently say LTO is deferred / its flags are "rejected or ignored" until implemented natively. The polylinker reframes this at the product level:
- LTO is no longer deferred for the user — an
-flto link is delegated to a bundled linker that does LTO (strictly better than rejecting it), even though native LTO codegen in reld's own engine remains future work.
- Per DECISIONS.md's own rule ("if evidence emerges that a locked decision is wrong, raise it as an issue — do not quietly implement the alternative"), this issue is that flag: D13's "reject LTO flags" stance should become "route LTO flags to a capable engine." The fast-inner-loop priority is unchanged — LTO just stops being a dead end.
Docs to update (part of this issue's scope)
Reframe the project as a polylinker everywhere it's described:
- README.md — the "four claims" / non-goals / stretch-goals sections: reld runs everywhere and supports every linker configuration by routing, with fast defaults and fallbacks. Replace the "LTO flags are rejected" language with "LTO is routed to a capable engine."
- DESIGN.md — add a "Polylinker: flag-aware routing over bundled engines" section (capability model, routing policy, fallback ordering, honesty/logging); update the LTO section (§ stretch goal) to the routing framing.
docs/plan/01-DECISIONS.md — amend/супersede D13 with the routing decision; cross-reference B8 (Bridge linkers: run + benchmark reld on Windows and macOS now by delegating to lld (rust-lld) per platform #17).
- Agent docs — reld has no
agents/docs/ yet; create a short agents/docs/ (or AGENTS.md) note describing the polylinker routing model so future agents implement new backends behind the capability table, not as forks.
Non-goals / cautions
Done when
DESIGN.md/README.md/DECISIONS.md/agent docs describe reld as a polylinker with the capability + routing + fallback model above; D13 is reconciled; the routing policy is specified precisely enough that B8 (#17) and the daemon router (#19) implement against it. (Implementation of the router itself is tracked by B8/#19 — this issue delivers the design + docs.) MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|