Skip to content

feat(bridge): delegate Windows COFF links to lld-link (BR-1) - #20

Merged
zackees merged 2 commits into
mainfrom
br1-windows-coff-bridge
Aug 7, 2026
Merged

zackees merged 2 commits into
mainfrom
br1-windows-coff-bridge

Conversation

@zackees

@zackees zackees commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Implements BR-1 of the bridge strategy (#17). Closes #18.

What

On a Windows/MSVC host, reld/reld-link previously bailed for COFF. This adds a reld_core::bridge module that makes reld link on Windows by delegating COFF links to lld-link (the rust-lld shipped with every Rust toolchain), via raw-argv pass-through.

  • Discovery (RELD_BRIDGE_LINKER override → rust-lld in the active toolchain → gcc-ld/lld-link there / on PATH → clear error). Never falls back to closed-source MSVC link.exe.
  • Interception in main.rs before args.parse() — the Args::Coff variant reuses the ELF parser, which cannot read MSVC /OUT:-style args, so the bridge bypasses parsing and forwards the original argv.
  • -flavor correctness: forwarded_args strips a leading -flavor <name> pair (already consumed by reld's dispatch) so it's never doubled against the -flavor link prepended for rust-lld.
  • Exit-code propagation: the child linker's exit code is propagated verbatim — a failing link can never be reported as success.

ELF and Mach-O paths are unchanged; the lib.rs COFF bail! remains as a defensive backstop.

Testing

  • 9 unit tests in bridge.rs (discovery, env override, -flavor stripping for name/flavor routes × rust-lld/lld-link, not-found message). Hermetic — no global env mutation, no real linker spawned.
  • soldr cargo fmt / clippy --all-targets clean; test -p reld-core green (pre-existing taplo-missing tidy test excluded).
  • E2E: a 16-source-file, two-crate project with 4 deps including rusqlite (bundled → compiles+links the SQLite C amalgamation), built with -Clinker=reld-link, produces a binary that runs and prints linked SQLite 3.46.0 / OK, exit 0.

Review

Independent review found and I fixed a -flavor double-prefix bug on the -flavor link invocation route; re-review verdict: APPROVE.

🤖 Generated with Claude Code

zackees and others added 2 commits August 7, 2026 00:19
On a Windows/MSVC host `reld`/`reld-link` previously bailed for COFF.
Add a bridge module that discovers a COFF-capable linker (RELD_BRIDGE_LINKER
override, then rust-lld / gcc-ld lld-link from the active toolchain, then
lld-link on PATH) and forwards the raw argv to it, bypassing the ELF parser
that cannot read MSVC-style link arguments. Intercept in main.rs before parse.

Raw-argv pass-through strips a leading `-flavor <name>` selector (already
consumed by reld's own dispatch) so it is never doubled against the
`-flavor link` prepended for rust-lld. Child exit code is propagated verbatim,
so a failing link can never be reported as success.

This lights up the Windows target for CI and the benchmark ahead of the native
COFF backend (#7), per the bridge strategy in #17.

Closes #18

Co-Authored-By: Claude Fable 5 <[email protected]>
The `needs_flavor_prefix`/`child_command_line` tests used Windows-style
backslash path literals (`C:\...\rust-lld.exe`). Off Windows, `\` is not a
path separator, so `file_stem()` returned the whole string and the rust-lld
detection asserted false — failing on the Linux and macOS CI runners while
passing locally on Windows. Switch to forward-slash paths (identical
`file_stem()` on every host) and keep the backslash cases under cfg(windows).
Production code is Windows-only and unaffected.

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-1: Windows COFF bridge — reld links via lld-link (rust-lld) pass-through

1 participant