Repository navigation
Description
Slice burn-down
- P0: Fork wild — vendor, license, rename, open the COFF dispatch point #4
- P1: Acceptance-test infrastructure (before any new format code) #5
- P2: Prove Linux — self-host, corpus pass rate, populate the benchmark column #6
- Polylinker: flag-aware router over bundled linkers (LTO/optimized via routing + fallbacks) — design + docs #30 (polylinker: flag-aware router + LTO-via-routing — design/docs)
- Bridge linkers: run + benchmark reld on Windows and macOS now by delegating to lld (rust-lld) per platform #17 (bridge engines — unblocks Win/mac CI + 3-platform benchmark ahead of P3: PE/COFF backend, MinGW (windows-gnu) ABI #7/P4: Mach-O backend, aarch64-apple-darwin #8)
- P3: PE/COFF backend, MinGW (windows-gnu) ABI #7
- P4: Mach-O backend, aarch64-apple-darwin #8
- P5: MSVC ABI + resolve the PDB decision (D5) #9
- DECISION: two contradictions in DESIGN.md that block incremental #10
- I0-I7: Incremental linking (do not start before P4 is green) #11
Meta issue. Tracks everything between here and "reld links a real program on Windows, Linux, and macOS." Incremental linking is explicitly out of scope for this issue — it is the product, but it is the second problem. Sub-issues to be split out of the checklists below as work starts.
0. Where we actually are
crates/reldis 28 lines.--targetsprints three strings; everything else exits 2.crates/reld-testkit(~500 lines) is the real asset: seeded C workload generator + bench + stress drivers, all three consumers (bench / stress / differential) designed in from the start.- CI, sanitizers, stress, and the benchmark-publishing pipeline are green and wired.
- The
reldcolumn in the published benchmark readsn/aand will keep readingn/auntil §2 lands.
So: the scaffolding is ahead of the linker, which is the correct order, and the next commit is the first one that has to write an actual output file.
1. Decisions to lock before writing linker code
These change the schedule by person-years, not days. Each needs an explicit answer recorded in DESIGN.md.
- D1 — Fork
wild's ELF backend, or reimplement?wildis MIT/Apache-2.0 and its core is already format-neutral by design. Forking hands us Linux/ELF at production quality on day one and lets all net-new effort go to PE/COFF and Mach-O — the two formats nobody has solved openly. Reimplementing buys independence and understanding we will need anyway when incremental lands. This is the single highest-leverage decision in the project. Recommendation: fork, and stay rebaseable against upstream for as long as that is cheap. - D2 — Driver surface. Three incompatible CLIs: GNU
ld/lld(Linux), MSVClink.exe(Windows),ld64(macOS). Toolchains reach us via-fuse-ld=/-Clinker-flavor, so we need argv[0] dispatch the way lld does (ld.reld,reld-link,ld64.reld). Decide the multi-call layout now; retrofitting it is miserable. - D3 — Target matrix for v0. Proposal:
x86_64-unknown-linux-gnu,x86_64-pc-windows-msvc,aarch64-apple-darwin. Note macOS forces us to arm64 first, not x86_64 — Apple Silicon is the machine that matters and it changes which relocation code gets written first. - D4 — Input parsing.
objectcrate for correctness-first bring-up vs. hand-rolled zero-copy mmap readers (whatwilddoes, for speed). Possible answer:objectbehind our own trait for v0, swap later — but only if the trait is drawn so the swap is real. - D5 — PDB, and whether the Windows story is credible without it. A dev-loop linker whose output cannot be debugged is not a dev-loop linker. Writing PDB is a large subproject on its own (
pdb/pdb2crates are read-oriented). Options: (a) write PDB, (b) emit DWARF into PE and support only LLDB, (c) ship v0 with no debug info and a loud warning. This is the most likely thing to quietly sink the Windows target and needs an answer before M2 starts, not during. - D6 — Ad-hoc code signing on Apple Silicon is mandatory, not optional polish — unsigned arm64 Mach-O binaries do not execute. Confirm whether we generate the
LC_CODE_SIGNATUREblob ourselves or shell out tocodesignfor v0.
2. Milestones — "it works everywhere"
Sequenced deliberately: ELF first (best-documented, best reference implementations, and D1 may hand it to us), then PE, then Mach-O.
M1 — Linux / ELF / x86_64
- Link a static non-PIE
hello.ofromcc -cinto a binary that runs and exits 0 - Archive (
.a) member semantics: lazy pull,--start-group/--end-group,--whole-archive - PIE +
-pie/-no-pie, GOT/PLT construction,R_X86_64_*relocation coverage - Dynamic linking against system libc:
DT_NEEDED, symbol versioning,.dynsym/.dynstr/.hash/.gnu.hash - TLS (initial-exec + global-dynamic at minimum; TLSDESC noted as a gap if punted)
-
.eh_frame/.eh_frame_hdr— C++ exceptions and Rust panics both die without this - Common flags accepted or explicitly rejected with a real message:
-L -l -o -rpath -soname --gc-sections -z ... --as-needed - Linker scripts: at minimum detect, and fail loudly rather than silently mislink
- Gate:
cargo buildof a nontrivial crate with-Clink-arg=-fuse-ld=reld, and the binary runs
M2 — Windows / PE-COFF / x86_64
- Link
cl.exe/clang-clobjects into a running.exe - Import libraries +
__imp_thunks, IAT construction, delay-load left as an explicit gap - COMDAT selection semantics (
IMAGE_COMDAT_SELECT_*) — the classic silent-wrong-answer generator - Base relocations + ASLR,
.pdata/.xdataunwind tables (SEH is not optional on x64) - Subsystem/entry-point selection,
/SUBSYSTEM,/ENTRY, DLL output + export tables +.def - TLS via
_tls_used/.tlsdirectory -
link.exe-compatible flag surface for the subset MSVC and rustc actually emit - Resolve D5 and implement whatever it says
- Gate: a Rust binary linked by reld runs, and a breakpoint hits in the chosen debugger (or the no-debug-info limitation is documented in the README, not just the issue tracker)
M3 — macOS / Mach-O / arm64
- Load commands,
__TEXT/__DATA_CONST/__LINKEDITsegment layout - arm64 relocations, stubs,
__got, branch islands for large images - Chained fixups (
LC_DYLD_CHAINED_FIXUPS) — the modern format; classic rebase/bind opcodes are legacy and may be skippable -
LC_BUILD_VERSION/-platform_version, SDK + deployment target plumbing -
.tbdstub dylibs — linking against the shared cache means never touching a reallibSystem.dylib - Ad-hoc code signature (D6)
- Objective-C section semantics only if a target workload needs it; otherwise record as a scoped gap
- Gate: a Rust binary linked by reld runs on a clean Apple Silicon machine with Gatekeeper in its default state
M4 — Cross-cutting core (concurrent with M1–M3, not after)
- Symbol resolution engine: weak/strong, common symbols, duplicate diagnosis, archive-order sensitivity
- Section GC (
--gc-sections) and string/constant merging — format-neutral per DESIGN §4.1 - Error taxonomy. Undefined-symbol messages that name the referencing object and demangle the symbol are cheap to build, and are the single most visible daily quality difference between linkers. Do this early; it also makes every other milestone easier to debug.
- Never-hang / never-OOM / never-silently-miscompile on malformed input
3. Testing — what has to exist for any of the above to be believable
The generator already exists and already anticipates this. What's missing is the oracle.
- T1 — Differential execution testing (primary oracle). Same objects → reld and → reference linker; run both binaries, compare exit code and stdout. Deliberately not a byte comparison — reproducible output is an explicit non-goal, so a byte-diff oracle would be wrong as well as noisy. This turns the existing seeded stress harness from a crash-finder into a correctness-finder, which is a much bigger upgrade than its cost.
- T2 — Self-host / bootstrap. Link
reldwithreld. Strongest single correctness signal available, and it costs one CI job. Add as a gate the moment M1 passes. - T3 — Real-world corpus. A pinned list of C/C++/Rust projects linked by reld in CI, published as a pass-rate percentage on the benchmark branch. Same honesty policy as §6 of DESIGN: a regressing number is still published. A link-success table is more persuasive at this stage than any speed chart, and we can publish it long before the speed column has content.
- T4 — Per-format conformance suites. Targeted objects that isolate one feature each (weak symbol, COMDAT, TLS model, unwind table), so a failure names the feature rather than the program.
- T5 — Malformed-input fuzzing. Truncated/corrupt objects and archives. Requirement is a clean error, not a panic and not a wrong binary.
- T6 — Runner matrix. Confirm the three GitHub-hosted runners cover us, including arm64 macOS; flag anything needing self-hosted hardware early.
- T7 — Sanitizer/stress coverage extended to the real linker as it lands, rather than staying pointed at the placeholder.
- T8 —
--verifymode. Re-link from scratch and compare symbol addresses against the fast path. Currently redundant; becomes the safety net that makes incremental's "fall back when uncertain" rule (DESIGN §4.2) enforceable rather than aspirational. Cheap to add now, expensive to retrofit.
4. Known feature gaps to record, not necessarily to fix
Worth writing down so they are scoped decisions rather than later surprises: LTO (non-goal, but rustc passes -flto and we must reject it comprehensibly), linker scripts, --build-id, incremental (deferred by design), delay-load imports, Objective-C/Swift metadata, symbol versioning depth on ELF, /DEBUG:FASTLINK, universal/fat Mach-O binaries, static PIE, and 32-bit anything.
5. Suggested first slice
- Answer D1 — everything downstream depends on it.
- Answer D2 and land multi-call argv[0] dispatch (small, unblocks all toolchain integration testing).
- Land T1 against a reference linker while reld still links nothing. The harness proves itself against a known-good linker before it has to judge ours — and it starts producing signal on the first day M1 emits bytes.
- Then M1.
Ordering note: 3 before 4 is the part that is easy to skip and expensive to skip.
Activity
zackees commentedon Aug 1, 2026
Deep dive complete — plan filed, phases broken out
Full execution-ready plan in #3 (
docs/plan/, 10 documents), grounded in file-level analysis ofwild,moldandradlinkplus a survey of incremental-linking prior art.Phase issues
What changed from the original meta issue
D1 answered: fork wild. But the framing shifts — wild's Mach-O backend is a skeleton with 40
todo!()s, arm64-only, feature-gated off. We inherit production ELF, the GNU arg parser, and a differential test methodology. We do not inherit a working Mach-O, and Windows is greenfield.D3 answered: windows-gnu first. DWARF needs only section concatenation plus
SECREL/SECTIONrelocations; MSVC needs PDB, which is ~20k lines in radlink — larger than its entire linking core.New, and the first real surgery in P3: wild's core speaks an ELF relocation vocabulary threaded through
platform.rsandlayout.rs. It must be generalized, not forked — forking the abstraction is the mistake that cost LLD 36,441 lines in 2021.Testing is better specified than I originally proposed. wild's oracle uses each input object's relocation list as ground truth, locates the output bytes via a
.layoutsidecar, infers which relaxation was applied, reverses the arithmetic, and compares recovered symbol-level targets. Plus two things I'd underweighted: mutation-injection to prove the oracle works at all, and mold's skip-list ratchet that fails CI when a skipped external test starts passing.The two findings that most change the incremental plan
1. The daemon is a precondition, not an optimization. HP-UX measured a 118 MB binary: 2 objects changed → 11.3s, 30 objects changed → 16.7s. Changing 15× more cost 48% more, because reloading state dominates. gold's null relink on Chrome was ~30s. DESIGN.md's millisecond target is unachievable with on-disk state — and this is the one place reld genuinely diverges from wild, which plans no daemon.
2. wild was named for incremental linking, published a design in Nov 2024, and still hasn't implemented it as of 0.9.0 — because the base linker consumed the time and once it was fast the incentive decayed. That is the failure mode most likely to happen to us, and it argues for shipping I2 (daemon + warm full link, zero patching) as a standalone win rather than treating incremental as one big milestone.
Also:
.eh_frame_hdr/.pdata/__unwind_infoare global address-sorted tables that cannot be padded or indirected around. That is what killed gold's C++ support, and it is identical on all three of our formats.zackees commentedon Aug 1, 2026
Correction: LTO is a deferred stretch goal, not a non-goal.
My earlier comment on this issue listed LTO as a non-goal — that was wrong, and it was wrong in DESIGN.md and README.md too. Corrected in d3706df and recorded as D13.
LTO is sequenced after the fast linker on all three platforms: the inner loop is the priority, and LTO interacts with symbol resolution, archive extraction, layout and debug info, so pulling it forward would slow down the thing the project exists to deliver.
Consequences now written into the plan:
-pluginon the MinGW gcc path, MSBuild passes/LTCG./GLobjects must hard-error — they contain IL, not machine code, and are not linkable at all without LTO.zackees commentedon Aug 2, 2026
Adversarial review complete — plan restructured
Six reviewers attacked the plan from different angles. Findings in
REVIEW-01.mdandREVIEW-02.md(R1–R44). The plan did not survive unamended.Two decisions refuted by evidence
D10 — "reject auto-import" is false. Measured on the local MSYS2 UCRT64 toolchain: a six-line C++ program with
std::stringand exceptions fails to link with--disable-auto-import --disable-runtime-pseudo-reloc, becauselibstdc++-6.dlldata exports are referenced from constant initializers and MinGW headers don't mark themdllimport. Auto-import + pseudo-reloc v2 are now required.D3 — gnu-first was wrong. It priced only the debug-info axis and priced MinGW compatibility at zero. Corrected, gnu additionally needs auto-import, ~25 linker-script-provided symbols the CRT references,
.rsrcon every link,.CRT$X*and.ctors, COMDAT-grouped DWARF, and long-form.idata$Nimport libs — all where radlink gives zero help. Now msvc first, carrying the shared COFF core.The finding that changed the product plan
I had scheduled I2 (daemon + warm full link) as "the first shippable win." Published lld phase data: input parsing 5.04%, string merging 66.54%. Caching parsed inputs skips the 5% and repeats the 66% — corroborated by wild's own benchmark page ("link time here is dominated by how quickly we can deduplicate strings").
Worse, string merging is also a soundness hole: the I1 fingerprint is structurally blind to
SHF_MERGEoffset shifts.D16 now gates the whole incremental workstream on IX-T0: measure first. If parsing is ~5% on our workloads, the parse-caching daemon is not built at all.
Other criticals
header_diff.rsfalls through_ => {}for non-ELF. COFF appears zero times in 10,195 lines. Even on ELF, coverage is ~50–70% of relocations. D17 adds a coverage floor and one malfunction site per format.IMAGE_SCN_LNK_NRELOC_OVFL→ silent mislink. Measured: plaingcc -cemits it; readingNumberOfRelocationsliterally applies 65,535 of 70,001 relocations.__unwind_infoconstruction entirely — plus kernel-enforcedMH_PIE, hard__PAGEZERO,MH_DYLDLINK(static arm64 executables don't run), andLC_MAIN.-fuse-ld=doesn't work with MinGW gcc (measured) — three phase docs relied on it.One correction in the plan's favour: I overstated P3-T1. wild already reuses the ELF relocation vocabulary across Mach-O and Wasm unchanged — 1–3 days, not the most invasive change in the phase.
Sequencing now
D15 moves incremental ahead of P4/P5. Rationale:
DESIGN.md's own ~1.5–2 person-years-per-format estimate meant the product feature didn't start for 3–4 person-years — which is precisely how wild, named for incremental linking, still hasn't reached it in two years.zackees commentedon Aug 2, 2026
[meta #2] child #4 -> CLOSED (validated by PR #12: all 13 CI checks green; Linux container 417 passed, 0 failed, 1180 expected skips; post-merge compile/license/driver/COFF/Wasm/upstream-diff gates green).
zackees commentedon Aug 2, 2026
[meta #2] child #5 -> CLOSED (validated by PR #15 / merge 7351cb8: all 14 CI, sanitizer, and stress checks green; Linux acceptance 230 passed / 595 architecture-disabled at 71% relocation coverage; differential 100/100 seeds; mold exact 407 native trials with 406 passed + 1 environment-ignore; post-merge summary/policy/reld-diff checks green).
zackees commentedon Aug 7, 2026
🤝 Handoff — session summary & continuation guide
reld went from "prints three strings and exits 2" to a linker that runs on Windows, Linux, and macOS, self-hosts, and posts competitive numbers on the published benchmark graph. The founding claim ("runs and targets everywhere" + "benchmarks auto-generated and published") is real and CI-proven.
Strategy pivot that made this fast
Rather than write native COFF/Mach-O backends first (person-years, #7/#8), reld became a polylinker / bridge: Linux links natively (inherited wild ELF core); Windows/macOS link by delegating to
lld(therust-lldin every toolchain) — COFF→lld-link, Mach-O→ld64.lld. This lit up all three platforms + the benchmark now, with native codegen as later work.Landed this session (all merged to main, CI-green)
lld-link(raw-argv pass-through,-flavordedup, exit-code propagation)rusqlite(bundled, C) program with reldld64.lld(-Clinker-flavor=ld64.lld), macos-arm64 e2eld.relddriver shim)targetper history line, per-seriesmode)agents/docs/polylinker.md(shipped-vs-designed table)Engineregistry +RELD_ENGINE/--engine=override + routing-reason logn/a(atime_linkoutput-path bug, NOT a reld bug) + surfaced link failures. reld now charts real numbers on the Linux graph.reldwithreld-link(CI gate)reldwithreldviald64.lldDesign issues filed (not implemented): #19 (linker daemon / running-process broker v2, blocked on IX-T0 per D16), #30 (polylinker flag-router — B8 implementation).
Verified current state
benchmark-statsbranch): reld charts native Linux numbers, competitive — e.g. large(512): reld 0.0445s vs wild 0.0523 / lld 0.091 / mold 0.118 / bfd 0.200.Remaining work (rough priority)
workflow_dispatchon a branch validates without publishing.-Clinker), so a rustc/warm-relink bench is needed for reld numbers on Win/mac. (Note: on those platforms reld ≈ lld + bridge overhead.)-flto→ route to a capable engine on Linux (native lacks LTO). Builds on B8a's registry.Key gotchas for the next agent
cargo/rustclocally go throughsoldr(a hook rejects bare invocations); CI uses barecargo. soldr builds undertarget/<triple>/debug/; CI's bare cargo usestarget/debug/.crates/reld-core/src/bridge.rs, routed fromcrates/reld/src/main.rs(Args::bridge_target()), format-aware viaBridgeTarget{Coff,MachO}.n/aoutput-path bug was found).n/a; keepshippedvsdesignedexplicit in docs (the polylinker router is designed, not implemented).ci/e2e/sqlite-bridge/(own workspace, root-excluded) is the 16-file/4-dep rusqlite regression used as the standard link gate.