Skip to content

BR-1: Windows COFF bridge — reld links via lld-link (rust-lld) pass-through #18

Closed

Description

@zackees

Sub-task of #17 (phase BR-1). First executable slice of the bridge strategy.

Goal

Make reld link a real program on Windows / x86_64-pc-windows-msvc by delegating to lld-link (via the rust-lld that ships in every Rust toolchain). ELF/Linux path stays byte-for-byte unchanged.

Why raw-argv pass-through (not parsed args)

On a Windows-MSVC host, PlatformKind::host() → Coff, but Args::new reuses the ELF/GNU parser for Args::Coff (crates/reld-core/src/args.rs:142-145). rustc drives the msvc linker with link.exe syntax (/OUT:, /DEFAULTLIB:, /LIBPATH:…), which the ELF parser cannot parse. Therefore the bridge must forward the original argv verbatim to rust-lld -flavor link, bypassing reld's parser entirely. lld-link speaks MSVC syntax natively, so pass-through is correct (issue #17, decision B3).

Scope

  • New reld_core::bridge module:
    • Discovery (issue Bridge linkers: run + benchmark reld on Windows and macOS now by delegating to lld (rust-lld) per platform #17, B2 order): RELD_BRIDGE_LINKER env override → rust-lld next to the active toolchain (rustc --print sysroot → lib/rustlib/<host>/bin/rust-lld) → gcc-ld/lld-link in that same tree / on PATH → hard error naming what to install. Never silently fall back to MSVC link.exe.
    • Exec: spawn the discovered linker with -flavor link + the pass-through argv tail; inherit stdio; propagate the child's exit code verbatim; emit one note-level line reld: engine=lld-link (bridge) <path> to stderr (B5).
  • Wiring: intercept in the run path when the platform is Coff, operating on raw std::env::args(), before the ELF parse runs. Args::Elf/Args::MachO paths untouched.
  • Unit tests for discovery: env override wins; sysroot resolution; PATH fallback; missing-everything produces a clear error naming RELD_BRIDGE_LINKER and rust-lld.

Out of scope (later BR phases)

macOS/ld64.lld bridge (BR-3), 3-platform benchmark + schema bump (BR-4), embedded payload/versioned cache (BR-5), flag-based LTO routing (BR-6), radlink alternative.

Done when

  • cargo build of a 16-source-file, two-crate project (lib + bin) with 4 dependencies including rusqlite (bundled → compiles+links the SQLite C amalgamation) using -C linker=<reld-link> on x86_64-pc-windows-msvc produces an .exe that runs and exits 0 (opens an in-memory SQLite DB, round-trips a row).
  • Existing Linux acceptance/CI stays green (ELF path unchanged).
  • Bridge-discovery unit tests pass.
  • PR merged, this issue closed, branch rebased on origin/main.

Activity

  1. added
    enhancement
    on Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions