Repository navigation
Description
Research: Windows (PE/COFF) fast-linking strategy — fork/optimize LLD-COFF vs retrofit COFF into Wild
Purpose
Decide, with evidence, which of two strategies reld pursues to dramatically improve Windows link performance. This issue collects the research; the decision will be recorded here once the research phases (appended as comments) are complete. macOS is explicitly out of scope for this cycle. Windows only.
The two candidate strategies
Option 1 — Fork LLD (lld-link / rust-lld) and optimize its COFF driver
Optimize for non-LTO, thin-LTO, and full-LTO regimes.
- Pro: lld-link already links Windows correctly, covering the full flag/feature surface. Every optimization is testable with a brutal, cheap oracle: does the optimized path produce a byte-identical deterministic binary vs the unoptimized path? Low bring-up risk.
- Con: presumably a lower performance ceiling — we inherit lld's architecture (memory model, serialization points, PDB pipeline).
Option 2 — Retrofit PE/COFF into the Wild linker
Wild is dramatically faster on ELF, which makes it the tempting choice.
- Pro: highest performance ceiling; modern parallel architecture; written in Rust.
- Con: Wild is ELF-only today. Windows linking has a long tail of machinery with no ELF analog (PDB/CodeView, import libraries, dllimport thunks, SEH/.pdata, /GUARD:CF, resources, manifests, delay-load). Bring-up could burn days-to-weeks of effort and heavy token spend before we even learn whether a blocker (most likely PDB) is fatal. Byte-identity testing vs lld is impossible by construction — a different linker produces different bytes — so the test oracle is weaker (behavioral equivalence).
Fixed constraints (decided up front)
- Both toolchain flavors are in scope: MSVC (
link.exe-style,*-pc-windows-msvc) and GNU/MinGW (*-pc-windows-gnu). (soldr preferred MSVC early on; we've since evolved — both now.) - This is a general-purpose C/C++/Rust linker. Linkers are language-agnostic: rustc emits ordinary COFF objects and
.rlibs (plainararchives whose.rmetamember a linker must skip — standard archive handling). No Rust-specific format support exists or is needed; "Rust support" = correct COFF/archive handling + accepting the flags rustc passes. (Research must verify this claim, not assume it.) - All link modes matter: non-LTO (dev inner loop), thin-LTO, full-LTO. Once the design is right, an agent grinds each mode until it is as fast as possible.
- Full
link.exeflag/feature compatibility is mandatory — the whole surface (/WHOLEARCHIVE,/ALTERNATENAME,/EXPORT,/DEF,/DELAYLOAD,/GUARD:CF,/DEBUG+ PDB, def files, manifests, resources, …). Sole MVP exception:/INCREMENTALmay be deferred. Everything else is required. - CRT selection
/MTvs/MDis super important and must be handled correctly (defaultlib resolution,/NODEFAULTLIB, mixed-CRT diagnostics). - Zig's self-hosted COFF linker is potentially super important prior art — their bring-up experience (esp. PDB) is direct evidence for the Wild-retrofit cost estimate.
Research questions
A. Scoping / baseline
- A1. Where does Windows link time actually go today (lld-link vs link.exe; symbols vs no symbols; LTO vs not)? Profile evidence, not vibes. If PDB emission dominates, that reshapes everything.
- A2. Verify constraint Meta: road to a working cross-platform link (Windows / Linux / macOS) #2: confirm rustc's linker contract on
windows-msvcandwindows-gnu(flags passed, rlib handling, self-contained mode,-fuse-ld/linker-flavor mechanics). Is there truly zero Rust-specific linker work? - A3. In thin/full LTO, is link time dominated by LLVM codegen inside the LTO plugin rather than link mechanics? If yes, does linker choice even matter for LTO builds, meaning the decision should be driven by the non-LTO dev loop?
B. LLD-fork path
- B1. How fast is lld-link today vs GNU-ld/mold/wild on comparable inputs — how much headroom exists?
- B2. Where does lld-link spend time (symbol resolution, /ICF, PDB emission, LTO)? What has upstream already parallelized (e.g. parallel PDB type merging, ghash)? What serialization points remain?
- B3. Is lld-link deterministic/reproducible by default (
/Brepro, timestamps, PDB GUIDs)? The byte-identity oracle depends on it. - B4. Fork maintenance: COFF-driver churn rate upstream; can optimizations be upstreamed instead of forked; how hard is shipping a patched lld to Rust/C++ users?
- B5. What did Rust's "lld by default on Windows" efforts learn? Known blockers?
C. Wild-retrofit path
- C1. What fraction of Wild is format-generic (symbol resolution, layout, parallelism, string merging) vs hard-wired ELF (relocations, section model, dynamic linking, TLS)? Is there any abstraction boundary today, or is ELF baked into core types? This is the load-bearing feasibility question.
- C2. Has Wild upstream stated any position on COFF/PE (or Mach-O) support? Would they accept a port, or is this a hard fork of a fast-moving project?
- C3. Enumerate the COFF machinery with no ELF analog that must be written from scratch: import/export tables + import libraries, dllimport thunks, SEH/.pdata unwind, safeseh, /GUARD:CF metadata, resources (.res), manifest embedding, delay-load, TLS callbacks, base relocations, and — the monster — PDB/CodeView writing. Estimated cost of each; which can be borrowed from existing Rust crates or LLVM?
- C4. Where does Wild's speed actually come from — and does the advantage survive once COFF's costs (esp. PDB) are added? Risk: weeks of porting to land at lld-speed anyway.
- C5. What is Wild's correctness/test story, and what would our COFF test oracle be given byte-identity vs lld is impossible?
- C6. Licensing of Wild vs LLVM (Apache-2.0 WITH LLVM-exception) — any shipping constraint?
D. Prior art & third options
- D1. Zig's self-hosted COFF linker: current status, what works, what stalled, PDB story, lessons on effort. Direct evidence for Option 2's cost.
- D2. mold/sold history: mold's author split macOS support into a separate product (sold) and later abandoned it. What does that say about cross-format code sharing in a single-format fast linker?
- D3. Any other fast-COFF efforts (e.g. Microsoft's link.exe improvements, radlink, others)?
- D4. Is there a hybrid/staged option: optimize lld now (ships this cycle) while a strictly time-boxed Wild-COFF spike answers C1–C4? GNU-flavor-first as a stepping stone (avoids some MSVC machinery)?
E. Decision criteria & kill criteria (to be finalized before any build starts)
- E1. Estimated bring-up cost to a minimum viable milestone per path: links a real Rust hello-world + one mid-size real C++/Rust project on windows-msvc and windows-gnu; binary runs; tests pass.
- E2. Written kill criteria per path (e.g. Wild: "if PDB or import-library handling has no feasible design within N effort, stop"). Purpose: never discover infeasibility at the bottom of a rabbit hole.
- E3. Is byte-for-byte reproducibility a product requirement for reld (content-addressed caching) or only a testing convenience? If product: heavy thumb on the scale for lld.
Known corner-case watchlist (adversarial pass will expand this)
PDB writing (the classic underestimated monster) · /INCREMENTAL expectations (deferred for MVP but users assume it) · full link.exe flag pass-through surface · dllimport-from-static-lib fixups · CRT selection /MT vs /MD and defaultlib resolution · import library flavors (short vs long format, MinGW .dll.a) · ARM64/ARM64EC · authenticode signing space · antivirus/mmap I/O behavior on Windows · string/COMDAT merging semantics differences · /Brepro + PDB GUID determinism.
Process
- Opus research agents gather evidence per section (LLD-COFF, Wild internals, Rust linker contract, Zig/mold prior art, link.exe compatibility surface). Each phase's findings are appended to this issue as a comment with links.
- Fable reads all findings and runs an adversarial/follow-up pass (corner cases, feasibility gaps); follow-up research appended likewise.
- Decision recorded as a final comment on this issue: chosen option, rationale, staged plan, kill criteria.
🤖 Generated with Claude Code
Activity
zackees commentedon Aug 26, 2026
Research phase 1/5 — LLD COFF driver (lld-link): performance, parallelism, determinism, fork mechanics
Report from Opus research agent, 2026-08-26. All claims link primary sources; items marked unverified/speculative are the agent's inference.
Key takeaways
lld/COFF/is ~22.0k LOC (17,764.cpp+ 3,805.h+ 417.td, 38 files, measured atmainon 2026-08-26). It shares zero code withlld/ELF/— onlylld/Common/(1,291 LOC of.cpp) and LLVM libs. Churn is ~10 commits/month (2023–2025), currently dominated by ARM64EC/ARM64X and DTLTO, not by the hot path.TypeMerger::mergeTypesWithGHash()usesparallelForEach/parallelFor/parallelSortand a lock-free priority-CAS hash table;PDBLinker::addObjectsToPDB()then callsaddDebug()in a plain serialforloop, and the driver's input-filetaskQueueis a strictly serialwhile (!taskQueue.empty()). Those two are the biggest remaining serialization points.TimeDateStamp = time(nullptr), the absolute/pdbaltpath, and anEnvBlockSymin the PDB that records cwd, absoluteargv[0], and the full command line. The last one means "optimized binary vs unoptimized binary" comparisons must run the same-named exe from the same path with the same argv.-Clinker=, no rustc rebuild — rustc invokes the linker directly (LinkerFlavor::Msvc, noccindirection). Name the binary anything other thanlld-link/lld/rust-lldand rustc emits a clean MSVC command line with no-flavorprefix.1. PERFORMANCE: how fast is lld-link, and how much headroom is left?
vs MSVC link.exe
The foundational number is Zachary Turner, Improving Link Time on Windows with clang-cl and lld, LLVM Blog, 2018-01-08:
That's 6–15x vs
/DEBUG:FULL, but only 1.3–2.0x vs MSVC's own/DEBUG:FASTLINK. Chromium switched Windows to lld on the strength of this (chromium-dev, Apr 2018).The important counter-datapoint is Alexandre Ganea (Ubisoft), Optimizing Builds on Windows, LLVM Dev Meeting, Oct 2019. On a AAA game editor (22.8 GB of MSVC
.obj, 300 MB exe, 2 GB pdb, 10M type records, 42M symbols; Xeon W-2135 6c):Same deck, slide 10: with compilation cached, the linker becomes the majority of build wall time (35 s compile vs 40 s link). That is the core argument for investing here.
Independent user reports on modern link.exe agree the gap has narrowed: gulbanana, 2023-01-15: "link.exe performance seems to have improved a lot in VS2019 and VS2022 … i'm not seeing gains from switching to rust-lld." Conversely EmbarkStudios/rust-ecosystem#15 claims 2x full / 5x incremental (anecdotal, 2019, no methodology; repo archived 2026-05-21).
There is no rigorous, current (2024–2026) published lld-link vs link.exe benchmark. That is a genuine hole in the literature.
vs fast ELF linkers (the headroom bound)
MaskRay, Recent lld/ELF performance improvements, Apr 2026, clang-23 Release+Asserts,
--gc-sections:Excluding
--gdb-index: mold 1.47–1.97x, wild 2.50–2.78x. Largest remaining lld deficit is parse: 320 ms lld vs 120 ms wild. The mold README table (16c/32t, debuginfo on) shows a wider 3.6–4.0x on MySQL/Clang/Chromium.No production-grade fast COFF linker exists. mold's own Windows support is aspirational (rui314/mold#190, targeted "by mold 3.0"); the kkent030315/mold Windows fork promised an alpha by summer 2025 and shows one commit. wild is ELF-only and is explicitly noted as often slower with lots of debug info — directly relevant to a PDB-heavy COFF workload.
Estimated headroom (agent inference, marked speculative): ~1.5–3x on non-LTO links generally, with the upper end coming from (a) parallelizing PDB symbol merging and (b) parallelizing input parsing/symbol resolution. The concurrency figure below is the most defensible evidence.
The single best modern datapoint
aganea,
[LLD][COFF] Prefetch inputs early-on, PR #169224, merged 2026-01-09, Unreal-Engine-based game, 4,169 OBJs / 26.3 GB non-lazy input / 350M input type records / 45.5M module symbol records, Threadripper PRO 3975WX 32c/64t:Derived: 259.9 s CPU / 29.7 s wall = ~8.8x average concurrency on 64 hardware threads. If the 260 s of CPU work were perfectly parallel it would finish in ~4 s; it takes 29.7 s. Roughly 25 s of that link is not effectively parallel. That is the headroom, and it is large.
2. PROFILE: where the time goes, what is already parallel, what is still serial
Published phase breakdown
llvm-dev, Making LLD PDB generation faster, Feb 2019, 141 MB binary → 1.2 GB PDB:
DenseMap::LookupBucketForalone was ~35 s. Explicit note in-thread: "there is no parallelization inside ofaddObjectsToPDB." Ganea's 2019 deck corroborates with a CPU-utilization trace showing high parallelism only during the ghash phase, with Symbols Merge and Layout PDB running near-idle.lld-link /timereports exactly these phases; the timer set is enumerated inlld/COFF/COFFLinkerContext.h:inputFile,lto,gc,icf,codeLayout,outputCommit,symbolGather,symbolStrings,write, then PDB:totalPdbLink,addObjects,typeMerging,loadGHash,mergeGHash,symbolMerging,publicsLayout,tpiStreamLayout,diskCommit.--time-trace=gives a Chrome-tracing profile with the same scopes.What upstream has ALREADY parallelized
/DEBUG:GHASHwas added by D40980 (Turner, 2017), then made parallel by Reid Kleckner, D87805 "[PDB] Merge types in parallel when using ghashing", 2020-09-16:/Z7build, 6-core Xeon:/DEBUG51 s →/DEBUG:GHASH27 sGanea's earlier RFC D55585 "Parallel GHASH generation at link-time" and his dev-meeting deck track Type Merge from 19.21 s → 7.42 s → 5.29 s (8-byte buckets) → 4.20 s (8-byte + 2 MB pages).
Complete list of
parallel*call sites inlld/COFF/atmain(grepped the tree):DebugTypes.cpp:1079,1081loadGHashes()DebugTypes.cpp:1111DebugTypes.cpp:1144parallelSort(entries)DebugTypes.cpp:1182remapTpiWithGHashesICF.cpp:243,246,280,287Writer.cpp:2654sec->chunksChunk::writeTo(section content write)Writer.cpp:2738sortExceptionTable.pdatasortSymbolTable.cpp:647__imp_fixupMapFile.cpp/LLDMapFile.cppMinGW.cpp:287Plus, in LLVM proper, publics layout is parallelized:
GSIStreamBuilder.cppusesparallelForfor name hashing and bucket sorting andparallelSortforPublicsand the address map.Serialization points that REMAIN (all verified by source read at
main)lld/COFF/Driver.hdeclaresstd::list<std::function<void()>> taskQueue;andDriver.cpp:1153–1159drains it with a plainwhile (!taskQueue.empty()) { taskQueue.front()(); taskQueue.pop_front(); }. Only the file mapping is overlapped, viacreateFutureForFile/std::async(Driver.cpp:154–167) plus the new/prefetch-inputs. Symbol resolution itself is single-threaded — the same structural problem MaskRay identifies for ELF in Why isn't ld.lld faster? (ld.lld 1.22x on 8 threads vs mold 3.26x; archive semantics resist parallel resolution).PDBLinker::addObjectsToPDB()(PDB.cpp:1160–1171) runsfor (TpiSource *source : dependencySources) addDebug(source);thenfor (TpiSource *source : objectSources) addDebug(source);— noparallelForEach.addDebugSymbols()(PDB.cpp:1017) is where the 13.2% goes. rnk's D87805 explicitly flagged this as the next step ("symbol records … can be merged in parallel since they get written to independent streams") and it has not landed. This is the single most obvious win available to a fork.tpiStreamLayoutTimer) and DBI module descriptor creation (createModuleDBIloop) are serial.diskCommitTimer) is a serial write.Is lld-link multi-threaded today?
Yes, but shallowly.
/threads:Nsetsparallel::strategy = hardware_concurrency(N)(Driver.cpp:1667–1676) and also seeds/opt:lldltojobs. Default is all hardware threads. The parallel regions are the table above; everything else is one thread.3. DETERMINISM: can two runs produce byte-identical EXE + PDB?
Yes, with the right flags. The authoritative statement is Nico Weber, Deterministic builds with clang and lld, LLVM Blog, Nov 2019: "All of LLVM's tools have deterministic outputs when run with the right flags but not necessarily by default."
PE header timestamp
Source of truth,
lld/COFF/Driver.cpp(config->timestamphandling) — precedence is/timestamp:>/Brepro>SOURCE_DATE_EPOCH>time(nullptr):time(nullptr)— not reproducible./Breprosetsconfig->repro = true;Writer::writeBuildId()then computeshash = xxh3_64bits(outputFileData)and writes the low 32 bits into bothcoff_file_header->TimeDateStampand the debug-directoryTimeDateStampfields, and emits anIMAGE_DEBUG_TYPE_REPROentry./BreproOFF-by-default was a deliberate 2018 change (D46966): "Using a deterministic value breaks Windows' AppCompat database in strange ways."/timestamp:<u32>is an lld-only extension — link.exe has no equivalent override.SOURCE_DATE_EPOCHis honored, added by PR #81326 (Feb 2024, LLVM 18+, backported torelease/18.x). Tested inlld/test/COFF/timestamp.test./Brepromeans something different in link.exe (VS2013 wrote0xFFFFFFFF, VS2017+ writes a Build ID) — see AMOSSYS and Raymond Chen, 2024-08-15. You cannot compare timestamp bytes across the two linkers.PDB GUID / signature / age — deterministic unconditionally
lld/COFF/PDB.cpp:1652setsinfoBuilder.setHashPDBContentsToGUID(true)always.PDBFileBuilder::committhen does:uint64_t Digest = xxh3_64bits({Buffer.getBufferStart(), Buffer.getBufferEnd()}); H->Age = 1; memcpy(H->Guid.Guid, &Digest, 8); memcpy(H->Guid.Guid + 8, "LLD PDB.", 8); H->Signature = (uint32_t)Digest;So the GUID is xxh3-64 of the whole PDB + the literal ASCII
"LLD PDB.",Ageis hardcoded to 1, and no wall-clock timestamp is written into the PDB. This replaced a random GUID in D51956 (2018). The same hash also drives the PE's CodeView record (Writer::writeBuildId,BuildIDHash::PDB/Binary). Collision risk is real but remote — one report at #54487.The three real hazards for a byte-identity oracle
/pdbaltpathdefaults to the absolute PDB path, made absolute and dot-removed (Driver.cpp:2627–2634), and is embedded in the PE debug directory. Use/pdbaltpath:%_PDB%.Object/source paths inside the PDB are absolutized via
pdbMakeAbsolute()unless/pdbsourcepath:<fixed>is given.The
* Linker *module'sEnvBlockSymrecordscwd,exe,pdb, andcmd—PDB.cpp:addCommonLinkerModuleSymbols():cwd=sys::fs::current_path()(or/pdbsourcepath)exe=pdbMakeAbsolute(ctx.config.argv[0])— the absolute path of the linker binary itselfcmd=quote(argv.drop_front())— the full command lineThis is the trap for the byte-identity oracle. If you compare
build\opt\my-lld-link.exeagainstbuild\base\my-lld-link.exe, the PDBs differ in theexefield, and because the GUID is a hash of the whole PDB, the EXE differs too. Run both binaries from the same path with the same argv and cwd, or diff with the linker module excluded.Good news:
fillLinkerVerRecord()hardcodes the backend version to MSVC 14.10.25019 andcs.Version = "LLVM Linker"— it does not vary with lld version, andons.Signature = 0. So a fork does not perturb these by bumping its version string.Nondeterminism sources: essentially none in the algorithms
GHashCellpacks(isItem, tpiSrcIdx+1, ghashIdx)most-to-least significant so thatoperator<is a priority function, andGHashTable::insertruns a CAS loop that keeps the highest-priority cell regardless of which thread wins. Comment in source: "lower tpiSrcIdx and ghashIdx values are preferred, which means that type record from earlier sources are more likely to prevail." A finalparallelSortfixes the ordering.llvm::stable_sorton equivalence class, and shard boundaries are computed before any mutation (ICF.cpp:236–238comment).parallelSortbeing unstable with explicit name comparisons (GSIStreamBuilder.cpp:433)./threads:1restores it.hash_combineseed is an address (MaskRay, May 2026);LLVM_ENABLE_REVERSE_ITERATIONexists to catch leaks into output. No COFF-specific escape is known; that none exists is unverified..debug$Hghash format supportsSHA1,SHA1_8, andBLAKE3variants (TypeHashing.h), so PDB bytes can differ across LLVM versions. Pin the version for the oracle.Prior art
Chromium ships byte-reproducible Windows builds using
/Breproon the compiler +/TIMESTAMPon lld-link (build/config/win/BUILD.gn). There is a long-open request to bundle the flags as one switch: #43218 "Adding /reproducible option?" (open since Nov 2019). Rust still has open Windows reproducibility bugs under rust-lang/rust#129080.Practical oracle recipe:
/Brepro /pdbaltpath:%_PDB% /pdbsourcepath:<fixed>, identicalargv[0]path, identical cwd, identical arg order, pinned LLVM version.4. ARCHITECTURE: how separable is lld/COFF?
Measured at
main, 2026-08-26 (fetched every file and counted):lld/COFF/.cpp+ 3,805.h+ 417Options.td), 38 fileslld/ELF/lld/MachO/lld/wasm/lld/Common/.cpplld/MinGW/Code shared between COFF and ELF: effectively none. Grepped every
.cpp/.hinlld/COFF/for cross-driver includes — the only two hits are comments (CallGraphSort.cpp:9"This is based on the ELF port";ICF.cpp:16"See ELF/ICF.cpp for the details"). The only shared headers arelld/Common/*:Timer.h(9 uses),LLVM.h(9),ErrorHandler.h(7),Memory.h(5),CommonLinkerContext.h(3),Filesystem.h(2),Args.h(2), and one each ofVersion.h,TargetOptionsCommandFlags.h,Strings.h,Reproduce.h,DWARF.h.bjorn3 puts it well (rust#71520, 2025-10-09): "Lld is really 4 (or 5 if you count the MinGW compat mode of the COFF linker code) separate linkers in a single executable. There is shared code, but most of it is platform specific."
Biggest COFF files:
Writer.cpp3,150 ·Driver.cpp3,031 ·PDB.cpp1,857 ·InputFiles.cpp1,584 ·SymbolTable.cpp1,519 ·Chunks.cpp1,370 ·DebugTypes.cpp1,241 ·DLL.cpp1,129.Dispatch: one
lldbinary, flavor fromargv[0]or-flavor;link→WinLink(lld/Common/DriverDispatcher.cpp:35).Churn (commits touching
lld/COFF, via GitHub API):So ~10 commits/month 2023–2025, ~5/month so far in 2026 — very manageable rebase load. Looking at the last ~45 commit subjects, the mix is: ARM64EC/ARM64X (largest bucket), DTLTO, MinGW fixes, NFC cleanups. The only perf commit in that window is aganea's
/prefetch-inputs(#169224). Almost nothing upstream is touching the hot path a fork would rewrite — that materially lowers merge-conflict risk.Maintainers: Martin Storsjö (mstorsjo) and Alexandre Ganea (aganea) (
lld/Maintainers.md). Ganea is also the person who has done essentially all the COFF perf work, which is a strong signal that well-benchmarked perf patches will get reviewed upstream.5. FORK MECHANICS
Licensing and build
lld/LICENSE.TXT) — permissive; a proprietary or renamed fork is legally straightforward.LLD_BUILT_STANDALONEis a supported build mode (lld/CMakeLists.txt:19–35):find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_DIR}"). You can build a forkedlldagainst a stock installed LLVM instead of carrying the whole monorepo. Caveat: the PDB machinery you most want to change (PDBFileBuilder,GSIStreamBuilder,TypeHashing) lives inllvm/lib/DebugInfo/PDB/, not in lld — so a serious PDB-speed fork will need to fork LLVM too, or upstream those bits.Release cadence
Two majors/year, ~6 months apart, RC1→final ~6 weeks, patch releases for ~24 weeks (HowToReleaseLLVM). A fork rebasing per release faces roughly 60–130 COFF commits per year, mostly in ARM64EC/DTLTO territory.
Fork vs upstream — agent assessment (opinion, marked as such)
Upstreaming is realistic for anything that is (a) benchmarked and (b) doesn't regress single-thread. D87805's history is the template: rnk landed a 30% win despite a 10% single-threaded regression, because the multi-thread numbers were compelling. Parallel PDB symbol merging is the obvious upstreamable candidate — rnk already named it as the next step and nobody has done it in 6 years.
Fork-only makes sense for changes that are semantically risky (new caching layers, incremental linking, on-disk indexes) or that require an API break in
llvm/DebugInfo/PDB. A hybrid — fork for velocity, upstream the clean wins — has the lowest total cost, given the small COFF surface and low churn.How rust-lld ships
rust-lldis bundled in therustcrustup component (not a separate component) — see theRustcdist step insrc/bootstrap/src/core/build_steps/dist.rs. On disk (verified onrustc 1.95.0, hostx86_64-pc-windows-msvc):rust-lld.exeis one copy of lld with all flavors compiled in. The 0.31 MBgcc-ld/*files are not lld — they are thelld-wrappershim that re-execs../rust-lld -flavor <flavor>, existing because "Windows does not support symbolic links for files."Can a patched lld-link be substituted? — YES on windows-msvc, no rustc rebuild
windows-msvc uses
LinkerFlavor::Msvc(Lld::No)(base/msvc.rs) — there is noCccomponent, so rustc invokes the linker directly with MSVC-style args. Verified viarustc --print link-argson 1.95.0:-Clinker="…\HostX64\x64\link.exe" "/NOLOGO" …rust-lld"rust-lld" "-flavor" "link" "/NOLOGO" ……\lld-link.exe"…\lld-link.exe" "-flavor" "link" "/NOLOGO" ……\my-lld-link.exe"…\my-lld-link.exe" "/NOLOGO" …The rule is
LinkerFlavor::infer_linker_hintsinrustc_target/src/spec/mod.rs— exact basename match againstwasm-ld,ld.lld,lld,rust-lld,lld-link. Recommendation: name the fork something other thanlld-link, and rustc emits a clean MSVC command line with no-flavorprefix. (Naming itlld-linkand having it be a wrapper script is a known trap: rust#160519.)Caveat on msvc:
-Zunstable-options -Clinker-features=+lldemits bare"lld" "-flavor" "link"(a PATH lookup), and-Clink-self-contained=+linkerdoes not redirect it to the bundledrust-lldthe way it does on linux-gnu. Use-Clinker=.windows-gnu is different:
x86_64_pc_windows_gnu.rssetslinker: Some("x86_64-w64-mingw32-gcc"), flavorGnu(Cc::Yes, Lld::No)— rustc drives gcc, so you substitute via-Clink-arg=-fuse-ld=<abs-path>or bypass with-Clinker=<fork> -Clinker-flavor=ld.lld(then you supply the mingw link args yourself).*-pc-windows-gnullvm(platform-support doc) is Tier 2 with host tools and already lld-based via llvm-mingw's clang; for pure-Rust programs the doc recommends installingrust-mingwand settingrust-lldas the linker with no C toolchain.Flag stability (verified on 1.95.0 stable)
-Clinker=<path>-Clinker-flavor=msvc|lld-link|ld.lld|…-Clinker-flavor=msvc-lld|gnu-lld|gnu-lld-cc|…-Clink-self-contained=y/n/off-Clink-self-contained=-linkerx86_64-unknown-linux-gnu-Clink-self-contained=+linker-Clinker-features=-lldx86_64-unknown-linux-gnu-Clinker-features=+lld-Clink-arg=-fuse-ld=lldConclusion: for a Rust-facing product on windows-msvc you need nothing but stable
-Clinker=and a differently-named binary. That is a very low integration bar.6. RUST + LLD ON WINDOWS
Linux is done. rust-lld became the default on
x86_64-unknown-linux-gnuin Rust 1.90.0 (2025-09-18) via PR #140525 (merged 2025-07-09); nightly since PR #124129 (May 2024). Measured on ripgrep: incremental linking 7x faster → ~40% end-to-end reduction; from-scratch debug ~20% (blog, 2025-09-01).Windows is stalled, but not on technical blockers. Tracking issue rust-lang/rust#71520 "Use lld by default on x64 msvc windows" (open, created 2020-04-24, last activity 2025-10-09). Its six listed blockers are all closed (verified each via the GitHub API):
lto=thin+ lld-linkonce_cell::Lazywith LTOmanifestdependency.drectveChrisDenton, 2024-12-07: "With #111480 fixed, it looks like all the blocking issues are now fixed."
Note:
/INCREMENTAL, ARM64, PDB/debuginfo, and dbghelp are NOT cited as blockers anywhere in #71520. If you've seen that claim, treat it as unverified — it could not be found in the primary sources.The two live objections are:
*-pc-windows-gnullvm.Machinery is already exercised in-tree: UEFI MSVC targets already default to
LinkerFlavor::Msvc(Lld::Yes)(base/uefi_msvc.rs) — the only target base with that value.Historical Rust-on-Windows lld numbers: PR #68623 (Zoxc, 2020-02-09), linking the compiler itself —
rustc_driver226.34s → 18.5s,rustc_macros28.69s → 7.7s,x.py build --stage 1 src/libtest12:00 → 8:29. Note these are LTO-ish rustc links, not typical user code.Open windows-gnu lld bug: #115985 STATUS_HEAP_CORRUPTION in rust-lld. Open msvc+lld bug: #131363 (wrong ASAN runtime). No tracking issue proposes lld-by-default for windows-gnu (unverified/nonexistent).
7. LTO: does linker choice even matter?
No. In an LTO link, wall time is dominated by LLVM codegen running inside the linker process — and, on Windows specifically, by allocator contention within that codegen.
The decisive experiment is Ganea, RFC: Replacing the default CRT allocator on Windows, llvm-dev, Jul 2020 — linking clang.exe with LLD +
-fltoon 36 cores, changing only the malloc implementation:A ~17x swing from swapping the allocator, same linker. Confirmed and extended by PR #91862 "Vendor rpmalloc in-tree and use it for the Windows 64-bit release" (merged 2024-06-20):
And the smoking gun for where LTO time goes: Ganea's 2019 deck, slide 33 — linking Rainbow Six: Siege with ThinLTO via lld-link on a 36-core Xeon Gold 6140 showed 4% CPU utilization, 96% idle, serialized on
RtlAllocateHeap/RtlFreeHeap, withFunctionImportGlobalProcessing::processGlobalForThinLTO,Verifier::visitMDNode, andSimpleBitstreamCursor::Readunderneath. Slide 36: clean rebuild went from >1h30m to 3m57s on 36 cores by swapping in rpmalloc.Architecturally this is expected: ThinLTO's serial thin-link step merges compact summaries, not modules (Johnson/Amini/Li, LLVM Blog, 2016-06-21; Clang ThinLTO docs).
lld/COFF/LTO.cpp:143already runscreateInProcessThinBackend(heavyweight_hardware_concurrency(thinLTOJobs)).No published percentage breakdown of "codegen vs link mechanics" inside an LTO link was found. The 17–25x allocator swings are the strongest available proxy; treat the exact split as unverified.
The one LTO lever that IS linker-side is DTLTO (Distributed ThinLTO) — the linker farms ThinLTO backend jobs out to an external distribution system (Incredibuild etc.). COFF support landed in LLVM 21 (PR #148594, merged 2025-07-20; docs), with archive support added Dec 2025 (#157043). Flags:
/thinlto-distributor:,/thinlto-remote-compiler:,-fthinlto-distributor=. This is where a fork's LTO effort should go, not into link mechanics.Conclusion: for full-LTO and thin-LTO builds, a faster COFF front-end is close to irrelevant. Scope the fork's value proposition to non-LTO (and non-LTO-with-PDB) links, plus distribution/caching for LTO.
8. LLD-LINK PARITY GAPS vs link.exe
The machine-readable source of truth is the tail of
lld/COFF/Options.td, under the header// The flags below do nothing. They are defined only for link.exe compatibility.Verbatim list atmain:/ignoreidl·/ltcg·/assemblydebug·/nologo·/throwingnew·/editandcontinue·/fastfail·/kernel·/pdbcompress·/emitpogophaseinfo·/nocoffgrpinfo·/noexp·/novcfeature·/delay:·/errorreport:·/idlout:·/ilk:·/ltcg:·/assemblydebug:·/ltcgout:·/maxilksize:·/tlbid:·/tlbout:·/verbose:·/guardsym:Three tiers matter — silently ignored (above), warned/degraded, and unrecognized → hard error.
/INCREMENTALConfig.h:344hasbool incremental = true;and it gates exactly one thing: whether the import library is rewritten when unchanged (Driver.cpp:1108–1145— writes to a temp .lib and renames only if bytes differ). It auto-disables under/OPT:REF,/OPT:ICF,/ORDER, and/profilewith warnings ("ignoring '/incremental' because ICF is enabled"). Options.td help text is literally "Keep original import library if contents are unchanged."/DEBUG:FASTLINK"/debug:fastlink unsupported; using /debug:full"Driver.cpp/LTCG,/LTCGOUT-flto/ThinLTO./EDITANDCONTINUE,/ILK:,/MAXILKSIZE:/PDBCOMPRESS,/EMITPOGOPHASEINFO,/KERNEL,/DELAY:,/TLBID:,/TLBOUT:,/IDLOUT:,/GUARDSYM:/GENPROFILE,/FASTGENPROFILEerror: could not open '/GENPROFILE': no such file or directory. MSVC PGO instrumentation is unsupported; use LLVM PGO./DRIVERand other "exotic" options.DEFfilesEXPORTS,HEAPSIZE,STACKSIZE,NAME,VERSIONare recognized/ORDER/incrementalDriver.cpp:2309/FUNCTIONPADMIN,/hotpatchcompatibleDriver.cpp/guard:cf,/guard:longjmp-Xlink./ALIGN,/INTEGRITYCHECK,/NATVIS,/DELAYLOAD,/DEPENDENTLOADFLAG,/PDBSTREAM,/PDBPAGESIZE,/PDBSTRIPPED,/SECTION,/MERGEtailMergeX64on x64 — #59639/machine:arm64ec)/machine:arm64x"complete" — treat full parity as unverified./ASSEMBLYDEBUGis an explicit no-op;/CLRIMAGETYPE,/CLRTHREADATTRIBUTE,/CLRSUPPORTLASTERRORare absent from Options.td and would error as input files. Full MSIL linking unsupported — unverified beyond the Options.td absence.lld-only extensions (relevant if the fork wants parity with lld, not link.exe):
/Brepro,/timestamp:,/threads:,/time,--time-trace=,/summary,/lldmap,/linkrepro:,/lldltocache,/opt:lld*,/pdbsourcepath:,/pdbstream:,/prefetch-inputs,/includeglob:,/discard-section(Apr 2026),/sectionlayout(Aug 2026),/build-id,/thinlto-distributor:.Highest-risk gaps for anyone adopting lld-link
/INCREMENTALis a compatibility shim; do not infer behavior from its acceptance. This is also the one axis where link.exe can genuinely win, and it is the explicit end-goal of the wild project on ELF./LTCG,/EDITANDCONTINUE,/PDBCOMPRESSaccept-and-do-nothing, so builds "succeed" with different semantics./GENPROFILEfails with a confusing "could not open file" error, not "unknown option."/Breprosemantics differ between lld-link and link.exe — you cannot compare PE timestamp bytes across the two.zackees commentedon Aug 26, 2026
Research phase 2/5 — Wild linker internals: format coupling, upstream position, speed sources, maturity, borrowable COFF machinery
Report from Opus research agent, 2026-08-26. Local read-only clone used for all file/LOC evidence:
reld-extern/wild@9e50056f5850a6b121d87938a5e8e9bdf518ec66(workspace version 0.10.0).Key takeaways
Platformimplementations in tree — ELF, Mach-O and Wasm (libwild/src/platform.rs,impl platform::Platform for Elf<C>atlibwild/src/elf.rs:648,for MachOatlibwild/src/macho.rs:1007,for Wasmatlibwild/src/wasm.rs:6426).port(coff): add MSVC link.exe-style argument parsingmerged 2026-08-11 (+959/−95).libwild/src/args/coff.rsis 759 lines today;libwild/src/lib.rs:269still bails with"PE/COFF (Windows) support is not yet implemented".symbol_db.rs(2290 L),resolution.rs(1737),string_merging.rs(1157),grouping.rs(474),input_data.rs(1122),file_writer.rs(453),value_flags.rs(345) contain zero references tocrate::elf/object::elf.layout.rs(6325 L) has exactly 2, one of which is a test import. Roughly ~22k LOC generic core vs ~20k ELF-specific vs ~4.5k Mach-O vs ~9.2k Wasm out of 66,872 LOC inlibwild.port(MachO):commits over 5 months (2026-03-22 → 2026-08-20), and per the 0.10.0 changelog it still only "can link some very simple programs." Wasm = 9,189 lines, 62 commits since 2026-05, "can link a range of programs." A COFF port is plausibly a 6–12 month, multi-person effort to reach useful, and that's with the abstraction already in place.libwild/src/platform.rsalone has 145 commits since it was created 2026-02-16, 75 of them since the Mach-O port started. A hard fork would bleed badly; upstream contribution is strictly cheaper.linker-diff(10,230 LOC) is described in its own docs as finding "differences between two ELF files"; Mach-O support is ~20 lines of partial header/arch handling and the Mach-O CI job setsWILD_TEST_IGNORE_FORMAT=1to skip format checks. A COFF port needs a COFFlinker-diffwritten from scratch, plus 221 ELF test-source dirs have no COFF analogue (Mach-O has 20).ms-pdb/pdb-rs says "THIS IMPLEMENTATION IS NOT AUTHORITATIVE AND IS NOT A REFERENCE IMPLEMENTATION." Every Wild speed advantage is on the ELF-side of a Windows link; PDB emission is the part that dominates real MSVC debug link times and has no Wild analog.1. Format coupling — what's generic, what's ELF
Verdict: the abstraction boundary exists, is real, and already has two non-ELF users. This is the single biggest correction to the premise of the question.
The boundary
libwild/src/platform.rs(1,656 LOC, created 2026-02-16) defines the whole format-abstraction surface. Traits declared there:Arch— CPU arch, parameterised byPlatform(type Platform: Platform)RelaxationPlatform— the file-format boundaryObjectFile<'data>SectionHeaderSectionType/SegmentType/SectionFlagsSymbolRelocation/RelocationSequence/RelocationListRawSymbolNameVerneedTable/DynamicTagValuesNonAddressableIndexesSectionAttributesProgramSegmentDefBuiltInSectionDetailsArgsPlatformcarries ~45 associated types (type File<'data>,SymtabEntry,SectionHeader,SectionFlags,RelocationInfo,ProgramSegmentDef,Args,LayoutExt<'data>,SectionIdentityExt,GcUnit, …) plus ~40 methods (write_output_file,section_attributes,built_in_section_details,finalise_object_sizes,finalise_layout_dynamic,apply_force_keep_sections,align_load_segment_start, …). Implementors:libwild/src/elf.rs:648—impl<C: ElfClass> platform::Platform for Elf<C>libwild/src/macho.rs:1007—impl platform::Platform for MachOlibwild/src/wasm.rs:6426—impl platform::Platform for WasmArchimplementors:elf_x86_64.rs:53,elf_aarch64.rs:59,elf_riscv64.rs:51,elf_loongarch64.rs:33,elf_ppc64.rs:16,macho_aarch64.rs:57,wasm_wasm32.rs:33. Note the comment atplatform.rs:80: "Note that implementations are file-format specific" — i.e.Archis (format × CPU), which is exactly what aCoffX86_64would slot into. Lattimore confirmed this design intent verbatim in PR #1653: "The idea as it current stands is that it's file-format + CPU architecture. SoPeFilewould implementObjectFile, then the platform would be something likePeX86_64with possible support forPeAarch64at some point."Module-by-module ELF-coupling measurement
Count of lines matching
crate::elf|object::elf|linker_utils::elfper file:libwild/src/symbol_db.rslibwild/src/resolution.rslibwild/src/string_merging.rsplatform::Platform)libwild/src/input_data.rslibwild/src/grouping.rslibwild/src/file_writer.rslibwild/src/parsing.rslibwild/src/value_flags.rslibwild/src/archive.rsarreader)libwild/src/program_segments.rsplatform::ProgramSegmentDeflibwild/src/layout.rslinker_utils::elf::RelocationKindat :83;crate::elf::Elf64at :5989 insidemod test)libwild/src/output_section_id.rslibwild/src/layout_rules.rslibwild/src/part_id.rslibwild/src/platform.rsDynamicRelocationKind,RelocationKindInfo,crate::elf::PropertyClassat :123,object::elf::SectionFlagsat :245)linker_utils::elf::RelocationKind(linker-utils/src/elf.rs:407) is a semantic relocation-kind enum (Absolute,Relative,Got,SymRelGotBase,PltRelGotBase,TlsGd, …) — the module name is historical, not a coupling. Only a couple of variants embed a rawobject::elf::RelocationType(e.g.PairSubtractionULEB128).macho.rshas 0 refs tolinker_utils::elf;wasm.rshas 0;macho_writer.rshas 2. That's direct evidence the residual leakage is tolerable for a new format.LOC split (libwild = 66,872 LOC total)
elf.rs(6745),elf_writer.rs(6165),args/elf.rs(2489),linker_script.rs(2483),version_script.rs(1184),gdb_index.rs(859),elf_x86_64.rs(648),elf_riscv64.rs(537),writable_elf.rs(461),elf_aarch64.rs(455),sframe.rs(338),elf_loongarch64.rs,elf_ppc64.rswasm.rs(7963),wasm_writer.rs(636),args/wasm.rs(480),wasm_wasm32.rs(110)macho.rs(2250),macho_writer.rs(1324),args/macho.rs(428),macho_aarch64.rs,macho_stub_library.rsargs/coff.rs— arg parsing onlylayout.rs,symbol_db.rs,resolution.rs,platform.rs,string_merging.rs,output_section_*,part_id.rs,grouping.rs,file_writer.rs,input_data.rs,parsing.rs,layout_rules.rs,symbol.rs,value_flags.rs,hash.rs,trie.rs,fs.rs,args.rsSo roughly 33% generic core / 30% ELF / 20% other-format ports / rest shared infra. The generic third is the third that matters most (parallel symbol resolution, layout graph, string merging, archive handling) and it is already format-agnostic.
Known impedance mismatches for COFF specifically
program_segments.rsis generic overProgramSegmentDef, andPlatform::align_load_segment_startis overridable.IMAGE_COMDAT_SELECT_*is not optional on Windows — this is a required, currently-absent core feature.args/is a subdir.Platform/ObjectFilerelationship at the moment... My main annoyance at the moment is the invariant lifetimes that arise from it." And: "currently its very much caters to elf" → "Yeah. My rough plan was make it less ELF-specific as we go." Expect churn in the interface you'd be porting against.2. Upstream position and churn
Stated position: pro, in-tree, incremental PRs
Issue #2320, Lattimore, 2026-08:
That last suggestion is exactly what shipped as #2374. So the port is following the maintainer's own prescribed sequence.
Caveats on upstream reception
windows-msvc, expect thin review bandwidth; ifwindows-gnu(MinGW), you get an active maintainer.CONTRIBUTING.mdhas an explicit "LLM / AI use policy" (human in the loop; don't send PRs you don't understand; don't paste LLM-written review replies), and mati865 has demanded disclosure on at least one PR (#1653). Relevant if you plan agent-assisted porting.GOVERNANCE.md: 4 maintainers (davidlattimore lead, lapla-cogito, marxin, mati865); major decisions go through the wild-linker/rfcs repo with 7-day majority votes; monthly video meetings; Zulip at wild.zulipchat.com. A COFF port is plausibly RFC-scale.github.com/davidlattimore/wild→github.com/wild-linker/wild(Cargo.tomlrepository = "https://github.com/wild-linker/wild").Churn rate — high, and hitting exactly the files you'd depend on
Commits/month (full history, 2,460 commits since 2024-02-05):
Files changed most in the last 90 days (
libwild/src+linker-utils/src):platform.rs: 145 commits since 2026-02-16 (28 in Feb, 47 in Mar, then 11–18/month). 75 commits touchedplatform.rssince the Mach-O port began on 2026-03-22, out of 579 total commits in that window. Translation: the format-abstraction interface changes roughly weekly, driven by whichever port is currently pushing on it.Fork verdict: a hard fork of Wild for COFF is a bad trade. You'd be rebasing against ~120 commits/month, ~13/month of which are on the exact trait surface your port implements. Upstream contribution is the only economically sane path, and upstream has explicitly asked for it.
Releases are roughly quarterly: 0.3.0 (2024-12-03), 0.4.0 (2025-03-01), 0.5.0 (2025-05-14), 0.6.0 (2025-09-23), 0.7.0 (2025-11-04), 0.8.0 (2026-01-16), 0.9.0 (2026-05-24), 0.10.0 (2026-08-04).
3. Where the speed comes from, and what survives on Windows
Author-stated sources
From
DESIGN.md(45 lines, the canonical short statement):args.rs→input_data.rs(mmap + archive split) →string_merging.rs→symbol_db.rs→resolution.rs→layout.rs→elf_writer.rs. "Each phase borrows data immutably from the previous phases." That is the zero-copy discipline that makes the parallelism safe.par_iter... In a couple of cases however, we have graph algorithms that don't fit neatly into rayon's model. In those cases, we spawn one rayon scoped task per thread and then do job control ourselves." Expanded in Graph Algorithms in Rayon (2025-11-27).From Wild Performance Tricks, RustForge 2025-09-02 — six named techniques, all format-agnostic:
SymbolIdallocation +split_off_mutso each thread gets a disjoint mutable slice — no synchronisation, good cache locality.sharded-vec-writer— parallel initialisation of uninitialised heap capacity, no placeholder-fill pass.Vecconversion, exploiting identical layout — the conversion "becomes a no-op and is optimised away."reuse_vec<T,U>()buffer recycling across loop iterations.MaybeUninitlifetime-stripping to move non-'staticbuffers to another thread for drop.Plus
mimallocin the workspace deps.String merging
libwild/src/string_merging.rs:1-27documents a two-phase, thread-alternating bucket-hash algorithm usingPassThroughHashMap/PreHashedandcrossbeam_queue::ArrayQueue. This is what theclang-debugbenchmark measures — "Clang with debug info has massive quantities of debug strings that need to be deduplicated." Wild deliberately skips suffix merging (March 2024 update) — a work-avoidance choice.Archive semantics
Wild ignores
--start-group/--end-groupentirely (libwild/src/args/elf.rs:223-225: "Just like other modern linkers, we don't need groups in order to resolve cycles"). Archive member activation is decided in the parallelresolution.rsphase, not by an ordered multi-pass sweep. Wild ships its own zero-copyarreader (libwild/src/archive.rs, 218 LOC).mmap / output strategy
libwild/src/fs.rs+file_writer.rs: inputs mmapped (memmap2), output is an mmappedMmapMutwritten in parallel.FileReplacementModehas three modes —UnlinkAndReplace,UpdateInPlace,UpdateInPlaceWithFallback(default), retrying asUnlinkAndReplaceonETXTBSY. New in 0.10.0: defaults to--no-mmap-output-fileon btrfs/vfat.What survives on Windows COFF — assessment (partly speculative, flagged)
Survives unchanged (high confidence — proven format-agnostic by Mach-O/Wasm):
symbol_db.rs, 0 ELF refs)..libstatic archives are the samear-family format;archive.rsneeds MSVC-variant long-name/second-linker-member handling but is 218 lines..rdata$...grouped sections; the bucket-hash algorithm is content-based).layout.rs, 2 ELF refs).windows-latestin CI (.github/workflows/ci.yml:184, build-only).Degrades or is lost on Windows (speculative where marked):
/DEBUGMSVC link, PDB writing is typically the dominant cost. Wild's advantages are all on the object-graph side; a from-scratch PDB writer means Wild's Windows numbers are gated by code that doesn't exist and has never been optimised./DEBUGis currently in the "recognised and ignored" list in PR #2374.Use UnlinkAndReplace for outputs.4. Maturity
What it links today
From
README.md"What's working?": x86-64 / ARM64 / RISC-V / LoongArch64 (initial) / PPC64LE (initial), all on Linux. Static non-PIE, static-PIE, dynamic executables, shared objects. Rust proc-macros; "Most of the top downloaded crates on crates.io have been tested with Wild and pass their tests"; debug info; partial linker scripts; linker-plugin LTO with known open issues. Self-hosting since 0.6.0; Chromium since 0.6.0 (~1.4 GiB with debug info); librustc-driver, zed, rust-analyzer, clang, bevy-dylib (>500k dynamic symbols), mold itself all benchmarked. 0.9.0: Linux kernel modules; compressed debug info; aarch64 range-extension thunks. Firefox: unverified — no claim found. Maintainer hedge (0.6.0): "Wild is still intended primarily for fast development."What's missing
README "What isn't yet supported?", roughly sorted by current priority: Incremental linking → more complex linker scripts → Mach-O support → Windows support. Windows is last on the stated priority list.
Incremental linking: designed-ish, not started. Issue #184 open since 2024-11-08; design write-up is Designing Wild's incremental linking (2024-11-19); ~21 months with no implementation. Lattimore told the COFF contributor explicitly to leave incremental alone until COFF support is reasonably complete.
Port status per 0.10.0 changelog (2026-08-04): "The Wasm port can now link a range of programs. Mach-O still has a way to go, but can link some very simple programs." Both behind non-default cargo features (
wasm,macho,wip).Test suite approach — expensive to replicate for COFF
DESIGN.md: compiles C/C++/Rust/asm programs, links with reference linkers (GNU ld, sometimes LLD), links with Wild, compares with the customlinker-difftool, then executes the binaries. Concretely:wild/tests/integration_tests.rs— 7,848 LOC harness.elf= 221 dirs,wasm= 61,macho= 20. COFF starts at 0.linker-diff/— 10,230 LOC; its own docs: finds "differences between two ELF files." Mach-O support is ~20 lines. No COFF/PE support at all. The arch-level asm diffing (iced-x86) transfers to COFF x64; the header/symtab/segment/reloc comparators do not.WILD_TEST_IGNORE_FORMAT=1(format checks relaxed). Expect the same crutch for COFF v1.external_test_suites/lld→ wild-linker/lld-tests, wired up 2026-08-15 by PR #2399, ELF only). Silver lining:lld/test/COFF/exists upstream and the vendoring machinery is now in place — a COFF port could bootstrap a large conformance suite for little harness work; likely the single highest-leverage move available.windows-latestbuild-only job.5. License
MIT OR Apache-2.0, dual. No constraint on forking or shipping, including closed-source (attribution + license text; Apache-2.0 patent grant). Inbound=outbound, no CLA.
GOVERNANCE.mdwind-down note transfers project assets to the Rust Foundation if Wild ends — trademarks/infrastructure, not a code-license constraint.6. Dependencies — what COFF machinery can be borrowed
Wild's object parsing
object(gimli-rs) 0.40.0, workspace-pinned, features["compression", "elf", "macho", "read_core", "std", "unaligned", "archive", "names"](+write_stdin libwild).coffandpeare NOT enabled — enabling them is a one-line change. ELF output is written by hand (writable_elf.rs, 461 LOC +zerocopy), not viaobject::write— a COFF writer would be hand-rolled the same way usingobject::pe::*struct definitions. Also:gimli(DWARF read),iced-x86(x86-64 disassembly in linker-diff — transfers to COFF),symbolic-demangle(handlesmsvcdemangling upstream, lightly verified),winnow,zerocopy 0.8.What the
objectcrate already gives you for COFF/PE (verified on docs.rs 0.40.0)object::read::coff—CoffFile(unifiedObjecttrait),CoffHeaderabstractingpe::ImageFileHeaderandpe::AnonObjectHeaderBigobj(bigobj covered), sections, symbols, relocations, COMDAT group handling.object::read::coff::ImportFile— short imports in import libraries are parseable today (side API).object::read::pe—PeFileetc. for reading PE executables (needed for a COFF linker-diff and reading DLL exports).object::write::coff+object::write::pe— raw-struct-level writers handling "both relocatable and executable files.".libvariant.Bottom line: parsing/emission plumbing is mostly borrowable — a meaningfully better starting position than the Mach-O port had.
What is NOT borrowable
pdb(getsentry): read-only.pdb2: read-oriented fork.ms-pdb/ microsoft/pdb-rs: "reading, creating, and modifying PDB files", MIT — but "THIS IMPLEMENTATION IS NOT AUTHORITATIVE AND IS NOT A REFERENCE IMPLEMENTATION", no support commitment, no claim of linker-grade from-scratch PDB generation.pdb-sdk: pure-Rust read+write, hobbyist-scale, unverified for linker use.bao-pdb: narrow scope.PDB.cpp+DebugTypes.cpptype-merging (TpiSource, GHASH, precomp//Zi) is arguably a bigger project than the COFF linking core itself..res→.rsrcconversion (cvtres). No Rust crate does it (embed-resource/winresourceshell out torc.exe/windres). From scratch..defparsing / export-table + import-library generation (/IMPLIB). No crate; from scratch (modest)..pdata/.xdataunwind handling for x64 — from scratch.linker-diff— ~10k LOC of ELF-shaped verification to re-create.7. Performance numbers
Source:
benchmarks/ryzen-9955hx.md, regenerated for 0.10.0 (2026-08-04). AMD Ryzen 9 9955HX 16C/32T, 92 GiB RAM, output on tmpfs. Comparators: LLD 21.1.8, mold 2.40.4/2.41.0, GNU ld 2.46. Percentages are the published chart labels (baseline = Wild); ms figures derived by the agent from SVG bar geometry (±2%, not official).* GNU ld figure from the
wild-debugchart.Headline: roughly 2× faster than mold and 3–9× faster than LLD across most real workloads, on 32 threads with tmpfs output.
Caveats that matter for a Windows decision:
Sources
wild-linker/wild (README, DESIGN.md, GOVERNANCE.md, CONTRIBUTING.md, CHANGELOG.md, benchmarks/, libwild/src) · #2320 Windows support · PR #2374 coff arg parsing · PR #1653 design discussion · #235 COMDAT · #184 incremental design · Wild Performance Tricks · Graph Algorithms in Rayon · 0.6.0 post · incremental design post · object 0.40 read::coff · object 0.40 write · microsoft/pdb-rs · MaskRay — Linker notes on PE/COFF
zackees commentedon Aug 26, 2026
Research phase 3/5 — The rustc↔linker contract on Windows: verifying "linkers need zero Rust-specific support"
Report from Opus research agent, 2026-08-26. Empirical claims verified against rustc 1.94.1 (windows-gnu host), 1.97.0-nightly (windows-msvc host), and rustc
main.Key takeaways
ararchives, and ordinary link.exe-/GNU-ld-style flags. But a correct linker must parse.drectvesections (for/DEFAULTLIB:from MSVC CRT objects and, since PR #158294, for/EXPORT:from rustc's ownsymbols.o), and must honorIMAGE_SCN_LNK_REMOVE(that's howlib.rmetadisappears).libcore-*.rlibonwindows-msvcis a COFF/MSVC-format archive (two/symbol-table members); onwindows-gnuit is a GNU-format archive (one/member).archive_formatis"coff"vs default"gnu".lib.rmetais a valid COFF object, not raw bytes: machine0x8664, one.rmetasection with characteristics0x00100800(IMAGE_SCN_LNK_REMOVE), one@feat.00absolute symbol. Verified by parsing shipped rlibs from both toolchains.symbols.ofull of undefined references so rlib members get pulled in, precisely because--whole-archiveis too expensive (#93791) and-u/EXTERN()would make them GC roots (#47384). A linker that eagerly loads archive members, or that treats undefined symbols in an input object as GC roots, breaks Rust semantics./NODEFAULTLIBis never passed onwindows-msvcby default (deliberately — see §6).windows-gnuis materially a second linker implementation, mostly because of import libraries. MinGWlibkernel32.a= 1751 full COFF objects with.idata$*; Windows SDKkernel32.Lib= 1396 short-format import objects (Machine==0, Sig2==0xFFFF) + 3 real objects. Plus: direct-.dlllinking, positional.definputs, auto-import + runtime pseudo-relocs (both default-ON inldand in LLD's MinGW driver),.dll.anaming,-Bstatic/-Bdynamicstate machine.lld,lld-link, orrust-lldand rustc will invoke it as<path> -flavor {link,gnu} …. Name it anything unrecognized on awindows-gnutarget and rustc keeps the target defaultGnu(Cc::Yes, …)— i.e. it treats you as a gcc driver and sends-Wl,-prefixed args and-lfoo."-quoted with\"escaping; GNU gets raw bytes with\-escaping of\and space.1. RLIB handling
Is an .rlib a plain
ararchive?Yes. Written by
ArArchiveBuilderon top of thear_archive_writercrate (a Rust port of LLVM's ArchiveWriter). Format chosen bytarget.archive_format:windows-msvc→"coff";windows-gnu→ default"gnu".Empirical confirmation (parsed the shipped rlibs directly):
libcore-*.rlib(1.97-nightly, msvc)/(41604B),/(40526B),//,lib.rmeta/,/0libcore-*.rlib(1.94.1, gnu)/(46116B),//,lib.rmeta/,/0,/58/) → GNU layoutrustc is tolerant on input:
archive_kinds_compatibleexplicitly allowsGnu ↔ Coff("GNU and COFF archives share the same magic and member header format; only the symbol table layout differs") — a mismatch is a warning. In practice either symbol-table layout works, but a linker must read both.Passed directly, or extracted?
Passed directly — "Linking to a rlib involves just passing it to the linker (the linker will slurp up the object files inside)" (
add_upstream_rust_crates). Only exception: fat/thin LTO without linker-plugin-lto, where rustc rebuilds the archive into tmpdir, droppinglib.rmetaand LTO-folded objects. Confirmed via--print link-args: every rlib appears verbatim as a bare path for both msvc and gnu.whole_archive: false— rustc never whole-archives rlibs (the only whole-archive use is sanitizer runtimes).Must the linker tolerate the non-object members?
The
.rmetamember needs no special-casing — it is a legal COFF object:Matches
metadata.rs::create_wrapper_file: COFF wrapper objects useIMAGE_SCN_LNK_REMOVE. Hard requirement: honorIMAGE_SCN_LNK_REMOVE(0x00000800) — emit it and every binary bloats; error on it and every link fails. Also present: absolute@feat.00symbol (bit 0 set on i386 for/SAFESEHcompat, #96498).Other members possible:
lib.rmeta-link(rustcmainonly), bundled native static libs (.bundled_libwrapper objects), and — Windows-specific — raw-dylib import-library archives appended into the rlib (ab.add_archive(...); see §5). Bytecode remnants are gone in modern rustc.2. Flag surface —
x86_64-pc-windows-msvcReal output from
rustc --print link-args(1.97-nightly), hello-world exe:cdylib adds
/DEF:…\lib.def(moved to the very front),/DLL,/IMPLIB:mylib.dll.lib.Complete emitted-flag inventory from
impl Linker for MsvcLinker:/NOLOGO,/OUT:,/DLL+/IMPLIB:<out>.dll.lib(note the.dll.libdouble extension),/DEF:(onmainthe file is an emptyLIBRARY\nEXPORTS\nstub kept only because "link.exe otherwise skips the import library for DLLs with no exports"; pre-1.96 it contained the full EXPORTS list),/WHOLEARCHIVE:(only for+whole-archivenative libs), barename.libpositionals,/LIBPATH:,/OPT:REF,ICF//OPT:REF,NOICF(NOICF at opt-level 0 — "MSVC's ICF … is slow for Rust"),/DEBUG(unconditional, even at-Cdebuginfo=0),/PDBALTPATH:%_PDB%,/NATVIS:,/NXCOMPAT,/SUBSYSTEM:+/ENTRY:mainCRTStartup(only with#![windows_subsystem], per RFC 1665),/guard:cf//guard:ehcont(opt-in),/INFERASANLIBS(ASAN with real link.exe only).Nothing exotic. No
/EXPORT:on the command line (moved into.drectveonmain), no/MANIFEST,/ORDER,/ALIGN,/BASE,/MACHINE,/STACK,/INCREMENTAL,/SAFESEH,/DYNAMICBASE.link.exe is located via VS discovery only when neither
-Clinkernor the target-spec linker is set — so-Clinker=<your.exe>cleanly bypasses it. rustc setsVSLANG=1033/LC_ALL=Con the child for English diagnostics.3. Flag surface —
x86_64-pc-windows-gnuDefault flavor is
Gnu(Cc::Yes, Lld::No)withlinker: Some("x86_64-w64-mingw32-gcc")— rustc drives gcc, not ld, and there is no rust-lld default. Real output (1.94.1):Direct-ld self-contained mode (
-Clinker-flavor=ld -Clinker=ld -Clink-self-contained=yes) is the same content in GNU-ld spelling plus the CRT startup objectcrt2.ofromlib\rustlib\...\self-contained\.Notes:
--enable-auto-image-baseis NOT used — rustc passes--disable-auto-image-base("ASLR will rebase it anyway"). Plus--dynamicbase,--nxcompat,--high-entropy-va,-m i386pep.-Bstatic/-Bdynamicstate machine applies: rlibs arrive under-Bstatic, system libs under-Bdynamic. A linker must track it.--out-implib=libfoo.dll.afor dylib/cdylib;--gc-sectionsfor executables;-nodefaultlibsalways (windows-gnu spells its libs out explicitly, listed twice on purpose — "mingw's msvcrt is a weird hybrid import library and static library", PR #47483)..deffile (list.def,EXPORTS\n "name"[ DATA]), not--version-script. LLD's MinGW driver special-cases positional*.definputs into-def:. A GNU-flavor Windows linker must accept a.defpath as a positional input.--enable-auto-import/--enable-runtime-pseudo-relocare never passed by rustc but default ON in binutils ld and LLD's MinGW driver. Real MinGW libraries need them.crt2.o/dllcrt2.oin self-contained mode (pre_mingw_self_contained()); otherwise gcc supplies them. The shipped windows-gnu sysroot is a complete MinGW installation (crt objects, libgcc/libmingwex/libmsvcrt + 30 import libs, plus bundledld.exe,dlltool.exe,x86_64-w64-mingw32-gcc.exe).-Clinker-features=+lld/-Clink-self-contained=+linkerare stable only on x86_64-unknown-linux-gnu.*-pc-windows-gnullvmis a third variant:linker: Some("clang"),-nolibc --unwindlib=none, no libgcc,CfgAbi::Llvm(which notably disables the dlltool path in §5).4. Linker selection
Three knobs:
-Clinker=<path>,-Clinker-flavor=<flavor>, cargo[target.<triple>].linker(passed through as-C linker; there is no[target.*].linker-flavor— flavor must go through rustflags).Windows-relevant flavor spellings:
msvc(stable),lld-link(stable legacy →Msvc(Lld::Yes)),ld(stable legacy → raw GNU-ld flags — the practical way to get raw-ld flags on windows-gnu today, verified working on stable 1.94.1),gcc/ld.lld(stable legacy),msvc-lld/gnu/gnu-cc/gnu-lld/gnu-lld-cc(unstable).Gotcha 1 — flavor is inferred from the linker's file stem (
infer_linker_hints)lld,lld-link,rust-lld,ld.lld,wasm-ld→ invoked as<path> -flavor {link|gnu} …— the binary must accept-flavoras argv[1].reld,myld) → target default wins. On windows-msvc that'sMsvc(Lld::No)(clean link.exe-style args — good). On windows-gnu that'sGnu(Cc::Yes, …)— rustc treats the binary as a gcc driver (-Wl,args,-lfoo). Pass-Clinker-flavor=ldexplicitly.*-ld→ raw GNU-ld flags with no CLI flag needed. Trailing-<digits>version suffixes are stripped before matching..batnames get wrapped ascmd /c.Gotcha 2 — response files
Triggered near the ~32768-char Windows spawn limit or on E2BIG; rustc writes
<tmpdir>\linker-argumentsand re-spawns with@<path>."-wrapped,\"escaping, UTF-16LE + BOM\-escape of\and spaceA linker taking
-Clinker-flavor=msvcmust parse UTF-16LE-with-BOM@-files.Gotcha 3 — no version probing, but stderr sniffing
rustc never runs the linker with
--version(retry-on-failure covers-no-pie/-fuse-ld=lld/-static-pie, allGnu(Cc::Yes)only). It does pattern-match linker stderr for thelinker-messageslint; custom linkers fall into the generic path — harmless.5. Rust-specific edge cases a linker must get right
5a. The synthetic
symbols.o— the real Rust-ismadd_linked_symbol_objectemits an object passed first on the link line. Two jobs:linked_symbol, forcing lazy-archive pull-in — deliberately instead of--whole-archive(too expensive, #93791) or-u(would create GC roots, #47384). Contracts that fall out: (a) lazy archive semantics; (b) an undefined symbol in a regular input object must not become a/OPT:REFGC root..drectve/EXPORT:directives (MSVC, rustcmain/1.96+ via PR #158294):/EXPORT:"name"[,DATA][,EXPORTAS,"other"]— quoted names and the ARM64EC-eraEXPORTASkeyword included. The object always carries an empty.text("MSVC will hang if the input object file contains no sections").Version boundary: rustc ≤1.95 wrote a full
EXPORTS.defand passed/DEF:— no.drectvefrom rustc (confirmed empirically on 1.97-nightly: symbols.o has no.drectve; exports are inlib.def).mainhas flipped. Support both shapes.5b.
#[link(kind = "raw-dylib")]— the linker sees a normal import libraryrustc synthesizes it on disk (
<tmpdir>\<dll>.dll_imports.lib) and passes the path like any other library. Two producers:ar_archive_writer::write_import_library— verified 7-member COFF archive:__IMPORT_DESCRIPTOR_*,__NULL_IMPORT_DESCRIPTOR,*_NULL_THUNK_DATAreal objects + short-format import objects (Sig1=0, Sig2=0xFFFF). rustc passes the/WHOLEARCHIVE-compat flagtruebecause of #129020 — duplicate__NULL_IMPORT_DESCRIPTOR-family symbols across import libs must be deduped, not errored.is_using_dlltool: windows && gnu && CfgAbi::Unspecified) because "the binutils linker … cannot read the import libraries generated by LLVM" (produced AV-crashing exes). Result is a GNU archive of full COFF head/tail/per-symbol objects (_head_*,*_iname, fthunk) — no short imports at all.Also: on Windows the raw-dylib import libs are added into the rlib archive itself, so an rlib can legitimately contain import-library members, short-format objects included.
5c. dllimport/dllexport for Rust dylibs
dllexport; exports arrive via.drectve /EXPORT:(msvc, main) or.def(gnu, and msvc pre-1.96).<path>.dll.libif present, silently nothing otherwise. GNU — rustc puts the.dllpath itself on the command line: a GNU-flavor linker must support linking directly against a PE DLL (binutils "direct linking to a dll"; search orderlibxxx.dll.a → … → xxx.dll).dll_tls_export: falseon both bases (rustc never exports TLS symbols from a Windows DLL).5d. Debuginfo / NATVIS
Only
/DEBUG+/PDBALTPATH:%_PDB%+/NATVIS:<file>— but/NATVISmeans the linker must embed .natvis XML into the PDB or Rust types render as raw bytes in debuggers. msvc:DebuginfoKind::Pdb,SplitDebuginfo::Packedonly. gnu: DWARF in-image, no split.5e. Unwinding / SEH — nothing beyond correct COFF (verified by object dump)
.text/.rdata/.xdata/.pdatain a rustc-msvc object isIMAGE_SCN_LNK_COMDAT; COMDAT selection incl.IMAGE_COMDAT_SELECT_ASSOCIATIVE(tying.pdata/.xdatato.text) is mandatory and exercised hard (one COMDAT per function).panic=unwindon MSVC uses MSVC C++ EH funclets (__CxxFrameHandler3,$cppxdata$,$stateUnwindMap$,$ip2state$) — ordinary symbols, no special handling..pdatarequirement: merge COMDATs and sort by BeginAddress.requires_uwtable: true.libgcc_s_seh); i686-pc-windows-gnu uses DWARF-2 unwinding (.eh_frame,libgcc_s_dw2) — extra machinery if 32-bit gnu matters.eh_frame_header: false(no--eh-frame-hdr).5f. Symbol names — just names
v0(_R…) and legacy (_ZN…) manglings are plain ASCII identifiers. Only requirement: don't truncate long names (Rust symbols routinely exceed 100 chars — archive//longnames member and COFF string table are exercised constantly). i386 stdcall decoration is applied by rustc, not the linker.6. CRT selection on windows-msvc
The
/MT-vs-/MDchoice is made bycorevia a#[link]hack (library/core/src/ffi/mod.rs):Verified: default →
/defaultlib:msvcrt;-Ctarget-feature=+crt-static→/defaultlib:libcmt. Because of+verbatimit arrives as a raw lowercase argument — handle/DEFAULTLIB:case-insensitively on the command line and in.drectve./NODEFAULTLIBis never emitted by default on windows-msvc —windows_msvc.rssetsno_default_libraries: falsewith this rationale (the single best primary-source statement of the.drectverequirement):Confirmed: a COFF linker MUST parse
.drectve.vcruntime.libanducrt.libare never on rustc's command line; they arrive only via directives insidemsvcrt.lib's members. windows-gnu is the mirror image:-nodefaultlibsis always emitted and every mingw lib is spelled out explicitly.The
.drectvedirective set to implement (LLD's accept-list, tokenized "using Windows shell rules"):/EXPORT:,/DEFAULTLIB:,/NODEFAULTLIB:,/INCLUDE:,/EXCLUDE-SYMBOLS:,/ALTERNATENAME:,/ALIGNCOMM:,/ENTRY:,/SUBSYSTEM:,/STACK:,/SECTION:,/MERGE:,/RELEASE,/FAILIFMISMATCH:,/MANIFESTDEPENDENCY:, plus accepted-and-ignored/EDITANDCONTINUE,/GUARDSYM:,/THROWINGNEW,/INFERASANLIBS; anything else errors. Rust objects don't emit/FAILIFMISMATCH:, but any C/C++ static lib linked into a Rust binary will.7. Dual-flavor reality: is windows-gnu a second linker?
Substantially yes. Shared: PE/COFF writing, COMDAT, relocations,
.pdatasorting, base relocs, archive reading,.defparsing,IMAGE_SCN_LNK_REMOVE. Different:/FLAG:value, case-insensitive,@utf16response files--flag/-l/-L,-Bstatic/-Bdynamicstate machine,@utf8response files/members (COFF layout)/member (GNU layout)kernel32.Lib= 1396 short-import objects + 3 reallibkernel32.a= 1751 full COFF objects, head/tail (_head_*,*_iname), zero short importsfoo.lib, implibfoo.dll.lib,/IMPLIB:libfoo.dll.asearch chain,--out-implib=.dlllinking.dlls positionally)__NULL_IMPORT_DESCRIPTORfamily (#129020)__RUNTIME_PSEUDO_RELOC_LIST[_END]__synthesis +_pei386_runtime_relocatorcooperation.drectve /DEFAULTLIB:crt2.o/dllcrt2.o+ mingw lib list (duplicated on purpose).pdata/.xdata.eh_frame)/NATVIS.drectve /EXPORT:(+ empty/DEF:)list.defAgent's read: LLD's own structure is the honest answer —
lld/COFF/is one linker andlld/MinGW/Driver.cppis a ~700-line argument translator into the same COFF core. That's the proven architecture: one backend, two front-ends, plus genuinely new backend work for (a) both import-library styles, (b) direct-DLL linking, (c) auto-import + runtime pseudo-relocs, (d) DWARF unwinding for i686-gnu. "One binary, two flavors" is achievable, but "windows-gnu is free once msvc works" is not.Caveats / unverified
.drectve /EXPORT:mechanism (PR #158294, merged 2026-07-01) is on rustcmainbut not in 1.94/1.95/1.97-nightly (those still write a full EXPORTS.def).lib.rmeta-linkis likewisemain-only. A linker must handle both shapes for several releases..drectvedirective set above comes from LLD's implementation (the de-facto reference); the exact MS-documented short-importNameTypesemantics were not verified against a Microsoft primary source (LLVM'sCOFFImportFile.cpp/ar_archive_writerare the practical references).archive_kinds_compatibleasserts it, warning-only) was not measured empirically; likewise ld with a COFF-format rlib.zackees commentedon Aug 26, 2026
Research phase 4/5 — Prior art: Zig's COFF linker, mold/sold, lld's own COFF history, PDB ecosystem, radlink, effort calibration
Report from Opus research agent, 2026-08-26.
Key takeaways
+9274/-14124, deleting the 2022 one), is still not the default on any Windows target, and emits no debug info at all: current master contains exactly one PDB reference, the comment// TODO: Convert .debug$* sections into PDB(src/link/Coff.zig:4478). Zig still ships LLD for every release build, including Windows.sold(mold + Mach-O) is the cleanest natural experiment:elf/861 KB,macho/324 KB,common/77 KB — the Mach-O side was a second linker written from scratch sharing only glob/tar/mmap/cmdline scaffolding. After sold was abandoned, mold deleted the format split entirely and is a flat ELF-onlysrc/again./OPT:ICF, DEF files, and COMDAT weak-symbol handling — ~22 months in and still filling in MSVC-parity basics.microsoft/pdb-rs(MIT, Rust, actively developed, "supports reading, creating, and modifying PDB files"), and PascalBeyer/PDB-Documentation ships a from-scratchwrite_pdb.c(108 KB) + toy COFF linker. The oldmicrosoft/microsoft-pdbspec repo has been archived since 2023-04-27 and was never complete.write_pdb.c(108 KB) >linker.c(83 KB). LLVM: PDB+CodeView+MSF libs ≈ 1.27 MB vslld/COFFat 792 KB.platform.rstrait abstraction (Mach-O and wasm ports already underway on it), PDB deferred, incremental deferred, "a number of PRs before a trivial program could be run".1. Zig's self-hosted COFF linker
Status today (Zig master, Aug 2026)
src/link/Coff.zig, 310,316 bytes / 7,751 linessrc/link// TODO: Convert .debug$* sections into PDBsrc/link/Coff.zig:4478selfHostedBackendIsAsRobustAsLlvmreturnstrueonly for.elfsrc/target.zig:298src/Compilation/Config.zig:359,419The timeline (8 years, two from-scratch rewrites, still not shipped)
NtTerminateProcesssyscall, hardcoded_start..res→COFF (cvtres-equivalent) dependency.+9274/-14124— the 2022 linker deleted wholesale.Coff.zig: symbol-table rework, weak externals, dll-import handling, absolute-symbol relocs, import thunks,.ctor/.dtor,.bssmerging, archive second-linker-member alignment, 32-bit fixups. The "actually link real object files" phase, ~8 months after the rewrite landed.lib/std/pdb.zig) but has never written one.What Zig's experience says about the COFF effort curve
_startexe (single PR).__imp_handling, entry autodetection, thunks,.ctor/.dtor, resource conversion, MinGW-vs-MSVC dual ABI — exactly the 2026-06 commit list, arriving 4 years after "we can link a program."Person-years (estimate —⚠️ not stated by any source): calendar span 8 years; concentrated engineering ~1.5–3 developer-years (kubkon 2021–2024, jacobly0 2025, kcbanner 2026; 362+ commits touching
Coff.zig). Order-of-magnitude only.2. mold / sold — the cross-format-sharing lesson
Timeline (primary sources)
bluewhalesystems/soldcreatedHow much code could actually be shared? ~6%.
sold is the only fast linker that ever shipped two formats in one tree:
elf/macho/common/And
common/is utilities (glob, tar, compress, uuid, demangle, filepath, output-file, perf), not linking. Each format has its ownmold.h(84 KB vs 34 KB),main.cc,input-files.cc,output-chunks.cc,cmdline.cc, and per-arch relocation backends. rui314 wrote a second linker essentially from scratch. The postscript: today's moldsrc/is a flat, ELF-only tree — the multi-format split was deleted once sold died.This mirrors his 2015 argument for splitting lld's ports (LLD improvement plan, llvm-dev): "the symbol resolution semantics are not the same on three architectures… but we only have one 'core' linker" — the ports would share less code, on purpose.
rui314 on Windows/COFF for mold — repeatedly negative, on economics
From #190, #1052, #1069:
The objection is never "COFF is too hard" — it's (a) opportunity cost, (b) lld already exists, (c) fear of being obsoleted by the platform vendor. (c) transfers directly to the reld decision.
3. LLD's own COFF history — how big is COFF, really?
Calibration: COFF linking ≈ 3 months for the world expert on his second attempt. COFF to MSVC parity including PDB ≈ 3.3 years wall-clock, with the PDB half alone ~1.5–2 person-years by a specialist (Turner) plus Kleckner et al. — with Microsoft's partial source dump. Current sizes:
lld/COFF792 KB (of which PDB.cpp 71 KB + DebugTypes.cpp 48 KB) — the smallest of lld's three mature ports. COFF-the-format is genuinely simpler than ELF; it's the debug format that isn't.4. PDB/CodeView specifically
How hard, in bytes
llvm/lib/DebugInfo/CodeView+ headersllvm/lib/DebugInfo/PDB/Native+ headersllvm/lib/DebugInfo/MSF+ headerslld/COFFlinkerCorroboration from a minimal implementation: PascalBeyer/PDB-Documentation — toy linker
linker.c83 KB next towrite_pdb.c108 KB +msf.c22 KB. The PDB writer is bigger than the linker. (Plus 222 KBvalidate.c— validation is itself a project.)Is microsoft-pdb still the only spec? No — and it never was sufficient.
microsoft/microsoft-pdb— archived 2023-04-27; "only able to upload a subset"; "didn't compile… half of it was missing" (LLVM blog)./names, TPI/IPI, DBI, module streams, GSI/PSI, CodeView records). Snapshot pinned to MSVC 19.28.microsoft/pdb-rs(MIT, created 2024-10-18, pushed 2026-08-24) — the big change since 2018: Microsoft's own Rust crates,ms-pdb-msf("reading, creating, and modifying" MSF),ms-pdb("supports reading, creating, and modifying PDB files"), pluscodeview/andcoff/crates. Caveats in-repo: "NOT AUTHORITATIVE… NOT A REFERENCE IMPLEMENTATION", no compat guarantees.ms-pdbcan emit a from-scratch, linker-grade PDB (full TPI/IPI type merge, GSI/PSI hash streams, section contributions, line info) vs only modifying existing PDBs. This is the single highest-value follow-up check for any Rust COFF linker — the difference between "reimplement 1.2 MB of PDB machinery" and "wire up a vendor-authored MIT crate."Could a non-LLVM linker link against LLVM's PDB libraries?
Technically yes —⚠️ Speculation: for a Rust linker, FFI to
llvm/lib/DebugInfo/{PDB/Native,CodeView,MSF}is portable C++ with no Windows API dependency ("100% portable", LLVM blog), andlld/COFF/PDB.cppis the reference consumer. The cost is inheriting LLVM as a build dependency — the exact thing Zig spent 8 years escaping ("The Zig compiler binary goes from about 150 MiB to 5 MiB", #16270).libLLVMDebugInfoPDBis mechanically feasible but likely more painful thanms-pdb, because LLVM's writer API is intertwined with lld's ownDebugTypes.cpptype-merging/GHASH machinery rather than being a clean standalone "write me a PDB" entry point.5. Other fast-COFF efforts
radlink (RAD / Epic Games) — public, MIT, the most relevant prior art
Lives in
EpicGamesExt/raddebugger(MIT, 7.4k stars); first shipped v0.9.13-alpha, 2024-10-18 — "an in-progress drop-in replacement for MSVC's linker." README: "designed to be very fast when creating gigantic executables… generates standard PDB files… command line syntax is fully compatible with MSVC"; ~50% faster link times on multi-GB debug info;/rad_large_pagesanother ~25%; no LTO yet.Code size (a hard reference for "COFF+PDB from scratch, done properly"):
src/linker/(incl.lnk.c299 KB,lnk_config.c134 KB,lnk_debug_info.c131 KB,pdb_ext/211 KB,codeview_ext/74 KB)src/codeviewsrc/coffsrc/pesrc/pdb+src/msfEffort signal: v0.9.28-alpha, 2026-08-21 — 22 months after first ship — is still landing
/OPT:ICF, DEF/SECTION support, COMDAT weak-symbol fixes, import/export edge cases, forwarder detection. A well-funded expert C team took ~2 years from launch to/OPT:ICF, still alpha.Microsoft's own link.exe
/DEBUG:FASTLINK(VS2015u1→VS2022): ~2× inner loop; deprecated and removed in VS2026 — "/DEBUG:FULL linking times have improved significantly, and /DEBUG:FASTLINK isn't always faster.""lld as default on Windows"
lld-link won the third-party fight (Chromium default since 2018, Firefox), but has never shipped incremental linking — the stated trade-off at Chromium switch time. Incremental remains the one axis where link.exe is unbeaten, and is exactly the eventual Wild differentiator (deferred by Wild upstream until COFF is complete).
Rust ecosystem
No production COFF linker in Rust exists. Wild's README lists Windows support dead last in priority. On wild#2320 the contributor's v1 scope explicitly excludes PDB ("Debug info is by far the biggest and least documented part of a Windows linker"), and Lattimore's guidance: in-tree, use the trait abstraction, defer incremental, "a number of PRs before a trivial program could be run." Co-maintainer mati865: "MSVC doesn't matter to me" — MinGW/GNU-flavored COFF may get more maintainer buy-in in Wild than MSVC-flavored. Format friction reference: MaskRay, Linker notes on PE/COFF.
6. Effort calibration
What consumed calendar time in each prior effort
_start-only exe (2022)/OPT:ICF, still alpha(a) Optimize an existing correct COFF linker (lld fork)
Effort class: 1–3 engineer-quarters to first credible win; correctness budget ~zero. Start at 100% MSVC parity and PDB output; the work is pure perf engineering on a known-serial codebase (parallel PDB symbol merging, parallel input parsing, GHASH-by-default, allocator, mmap output). This is the option AI-agent labor helps least relative to a human expert (perf work is measurement-bound, not typing-bound), but the only option whose risk is bounded. Two headwinds: (i) the hot path is
PDB.cpp/DebugTypes.cpp— surgery on the hardest 15% of the code; (ii) Microsoft closed a 3–6× link.exe gap between VS2017 and VS2019 by pure data-structure work.(b) COFF+PDB bring-up in a new/retrofitted linker (e.g. Wild)
Effort class: multiple engineer-years, dominated by two subsystems that are not the linker.
/OPT:REF— 1–2 engineer-years per Zig 2022→2026 and radlink 2024→2026. Broad, shallow, spec-following, heavily testable against lld-link diffs — the single best fit for AI-agent labor in this entire problem; an agent fleet plausibly compresses 18 months to 4–6.ms-pdb(microsoft/pdb-rs) can genuinely construct a linker-grade PDB, this line item drops from years to months. Verify before costing option (b)..debug$H); per LLVM it is "by far the slowest" part of a Windows link. A COFF linker that is fast at everything except PDB is a COFF linker that is not fast.Bottom line
The two options are not two points on one curve — they're different projects:
A defensible hybrid no source rules out (⚠️ agent inference): do (b) for the linking core inside Wild's trait abstraction and acquire PDB as a dependency (
ms-pdb, or LLVM's DebugInfo libs) rather than building it — the whole history above is the argument for why that boundary is the one worth buying.zackees commentedon Aug 26, 2026
Research phase 5/5 — The full link.exe compatibility surface: flags, .drectve, CRT, import/export, Windows metadata, COMDAT semantics, determinism
Report from Opus research agent, 2026-08-26.
.drectve/CRT claims verified locally against VS2022 BuildTools withdumpbin.Key takeaways
Options.tdis the best available spec of that subset: ~130 implemented, 27 accepted-and-ignored under an explicit "flags below do nothing" banner, and the CLR/WinMD/MIDL/PGO families simply unknown (warn, not error)..drectveis the load-bearing mechanism, not the command line. Every MSVC object carries/DEFAULTLIB,/FAILIFMISMATCH,/alternatename,/EXPORTdirectives, and CRT import libraries themselves carry further/DEFAULTLIBand/FAILIFMISMATCHrecords (verified locally with dumpbin). /MT-vs-/MD correctness is not a command-line feature — it is a fixed-point algorithm inside the linker's archive-loading loop, and cannot be bolted on afterwards./MTvs/MDrequires exactly two mechanisms: transitive/DEFAULTLIBresolution during lazy archive member loading, and a globalkey=valuemap for/FAILIFMISMATCHfed from both command line and every.drectveencountered (lld's whole implementation is ~12 lines, Driver.cpp:684-698). S/M difficulty — the risk is architectural (when directives are processed), not algorithmic.__imp_thunk synthesis (M), and.rsrctree construction from.res(M). lld/COFF is ~752 KB of source across 37 files (Writer.cpp 114 KB, Driver.cpp 106 KB, PDB.cpp 69 KB, DebugTypes.cpp 46 KB) on top of LLVM's DebugInfo/{MSF,CodeView,PDB}, Object/COFF, WindowsResource and WindowsManifest libraries.SELECT_LARGEST/SELECT_SAME_SIZE/SELECT_EXACT_MATCHand associative chains where ELFSHT_GROUPhas only "same signature → keep one"; COFF has noSHF_MERGE(string dedup rides on COMDAT); and$-suffix section ordering (.text$mn,.CRT$XCU,.gfids$y) is a lexical-sort layout rule with no ELF equivalent./Breprois ~6 lines in lld. Byte-reproducible PDBs additionally require deterministic GUID/Age,/pdbsourcepath,/PDBALTPATH:%_PDB%. Ecosystem tolerance is proven (Chromium/Firefox ship this); one known caveat (tools parsing the timestamp as a date) has the/timestamp:escape hatch.__RUNTIME_PSEUDO_RELOC_LIST__table and CRT cooperation (_pei386_runtime_relocator); plus auto-export-all,--kill-at, stdcall fixup,.ctors/.dtorssentinels, a different default-merge table.libwild/src/args/coff.rs(759 lines) — but it is argument parsing only. No COFF reader, no PE writer, no.drectvehandling, no PDB. Retrofitting COFF into Wild is a from-scratch PE/COFF backend that reuses Wild's parallel resolution/layout architecture, not a port.1. Flag inventory: link.exe vs lld-link vs from-scratch cost
Difficulty rated for a from-scratch linker that must be correct.
@file--rsp-quoting=posix)/LIBPATH,/DEFAULTLIB,/NODEFAULTLIB[:lib],/WHOLEARCHIVE,%LIB%/winsysroot,/start-lib, …).drectve-/DEFAULTLIBfixed point (§2/§3)./NODEFAULTLIBmust beat/DEFAULTLIBregardless of discovery order./OUT /DLL /ENTRY /NOENTRY /SUBSYSTEM /MACHINE /BASE /FIXED /ALIGN /FILEALIGN /HEAP /STACK /STUB /VERSION /SECTION /MERGE /ORDER /RELEASE /SWAPRUN /DRIVER /KERNEL /APPCONTAINER/KERNEL(no-op).idata=.rdata .didat=.rdata .edata=.rdata .xdata=.rdata .00cfg=.rdata .bss=.data, Driver.cpp:2154-2159) — match it or layout diverges from link.exe./INCLUDE,/ALTERNATENAME(undocumented),/FORCE,/IGNORE,/WX,/ALIGNCOMM/includeglob,/wrap, …)/ALTERNATENAMEis a weak-alias mechanism MSVC headers rely on unconditionally (observed/alternatename:_Avx2WmemEnabled=…in every object including<string>). Not optional./EXPORT /DEF /IMPLIB /DELAYLOAD /DELAY:{UNLOAD,NOBIND} /NOEXP/delay:,/noexpno-ops.edata. lld does not implement/DELAY:UNLOAD/NOBINDsemantics./DEBUG[:FULL|FASTLINK|NONE] /DEBUGTYPE /PDB /PDBALTPATH /PDBSTRIPPED /NATVIS /SOURCELINK /MAP /ILK/Zitype-server and/Z7paths. Everything else in this table combined is smaller./OPT:{REF,NOREF,ICF[=n],NOICF,LBR}/opt:safeicf); LBR ignored/OPT:REF= COMDAT-granularity GC, not--gc-sections. Defaults flip with/DEBUG./LTCG* /GENPROFILE /USEPROFILE /PGD /SPGO…/LTCGno-op; PGO absent; lld has its own-fltomachinery/DYNAMICBASE /HIGHENTROPYVA /NXCOMPAT /LARGEADDRESSAWARE /TSAWARE /ALLOWBIND /ALLOWISOLATION /INTEGRITYCHECK /GUARD:{CF,EHCONT} /SAFESEH /CETCOMPAT /DEPENDENTLOADFLAG /FUNCTIONPADMIN/GUARD:CF/MANIFEST* + .resinput.res→COFF (cvtres) is in-process in lld (convertResToCOFF)./CLR* /ASSEMBLY* /KEYFILE…/WINMD*/IDLOUT /TLBOUT /TLBID /MIDL /IGNOREIDL/INCREMENTAL /ILK /MAXILKSIZE.ilkdesign is fundamentally at odds with/OPT:REF//OPT:ICF(link.exe itself disables them under/INCREMENTAL)./VERBOSE /TIME /LINKREPRO*/MACHINE:ARM64X,/MACHINE:ARM64EC/Brepro,/TIMESTAMP(lld ext),/GUARDSYM,/THROWINGNEW,/EDITANDCONTINUE,/PDBCOMPRESS…/Brepro✅; rest no-ops/Brepromandatory (§7)./GUARDSYM//THROWINGNEWarrive via.drectveand must at minimum be swallowed.Bottom line: of ~120 documented options, ~30 are one-bit header writes, ~25 legitimate no-ops, ~20 CLR/WinMD/IDL/PGO to refuse outright (lld's precedent). The residual ~45 are where the work is, and roughly 60% of that work is PDB.
2. The
.drectvemechanismWhat it is (PE/COFF spec): a section named
.drectvewithIMAGE_SCN_LNK_INFO, containing a text string of linker options (ANSI or UTF-8-with-BOM), removed by the linker after processing, no relocations allowed. lld tokenizes it with Windows shell rules unconditionally and hard-errors on unrecognized directives ("<flag>is not allowed in .drectve").What's actually allowed inside — Microsoft documents only the
#pragma comment(linker,…)whitelist (/DEFAULTLIB /EXPORT /INCLUDE /MANIFESTDEPENDENCY /MERGE /SECTION); the real set is larger. lld'sparseDirectives(Driver.cpp:550-670) is the de-facto spec:/EXPORT(bulk fast path, deduped across objects),/INCLUDE(GC root),/EXCLUDE-SYMBOLS,/ALIGNCOMM,/ALTERNATENAME(weak alias),/DEFAULTLIB,/ENTRY,/MERGE,/NODEFAULTLIB,/SECTION,/STACK,/SUBSYSTEM,/RELEASE,/FAILIFMISMATCH,/MANIFESTDEPENDENCY,/ARM64XSAMEADDRESS, plus accepted-and-ignored/EDITANDCONTINUE /GUARDSYM /THROWINGNEW /INFERASANLIBS; anything else errors.Why this makes /MT-vs-/MD linker-internal. Measured on VS2022 BuildTools (
cl /c /EHsc /MDon a TU including<string>with one dllexport),dumpbin /directives:Same TU with
/MT→RuntimeLibrary=MT_StaticRelease,/DEFAULTLIB:libcpmt,/DEFAULTLIB:LIBCMT. With/MDd→_ITERATOR_DEBUG_LEVEL=2,MDd_DynamicDebug. The CRT choice is never on the linker command line — MSBuild, CMake, and Cargo all rely on the compiler stamping it into every object. Ignore.drectve /DEFAULTLIB→ LNK2019 on every CRT symbol. Honor/DEFAULTLIBbut not/FAILIFMISMATCH→ silently mixed_ITERATOR_DEBUG_LEVELSTL layouts that crash at runtime./FAILIFMISMATCHsemantics (surface:#pragma detect_mismatch): globalmap<string,string>; on conflict → fatal LNK2038 naming both files. MS-defined keys:_MSC_VER,_ITERATOR_DEBUG_LEVEL,RuntimeLibrary,_PPLTASKS_WITH_WINRT; values likeMT_StaticRelease/MD_DynamicRelease/etc. lld's entire implementation is ~12 lines.The architectural trap:
msvcprt.libitself carries/FAILIFMISMATCH:RuntimeLibrary=MD_DynamicRelease(verified), so the mismatch map must be updated from directives of archive members pulled in lazily during symbol resolution — resolution and directive processing are mutually recursive. This is a design constraint on any linker whose natural shape is "read all inputs, then resolve" (i.e. Wild's phase pipeline). Difficulty: S (algorithm) / M (plumbing) / L (if the resolution core wasn't designed for it).3. CRT linking: the full /MT vs /MD story
Since VS2015 the CRT is four layers (CRT library features):
/MT/MTd/MD/MDdHow the choice propagates — measured, not inferred. The compiler emits only the top two layers into
.drectve; the rest arrive transitively from the libraries' own.drectverecords:So
/DEFAULTLIBresolution is a worklist to fixed point, with self-references, requiring case-insensitive canonicalized dedup (MSVCRTfrom the compiler vsmsvcrt.libfrom the library; lld lowercases for/nodefaultlib)./DEFAULTLIB:OLDNAMES(POSIX aliases) is always present and must resolve./NODEFAULTLIBprecedence (docs): explicit libs →/DEFAULTLIBlibs → obj-embedded defaultlibs;/NODEFAULTLIB:xoverrides/DEFAULTLIB:x; bare/NODEFAULTLIBsuppresses all (how#[no_std]/custom-CRT builds work).Failure modes: (1) detected — LNK2038 via
/FAILIFMISMATCH; (2) undetected — both libcmt and msvcrt on the list → LNK4098 + LNK2005 duplicate-symbol shower (a from-scratch linker gets the duplicates for free but won't emit LNK4098 unless it models conflicting CRT sets — lld doesn't either); (3) runtime-only — cross-DLL CRT state, undetectable by any linker.Cost: M. ~300 lines. The risk is entirely in where it sits in the pipeline.
4. Import/export machinery
Import libraries: short vs long format
Both live in a standard
!<arch>archive with first/second linker members (spec §7; note the second member is little-endian + sorted, the first big-endian — both must be written correctly for lib.exe interop). Long format member = a real COFF object. Short format (spec §8) = 20-byte import header (Sig1=IMAGE_FILE_MACHINE_UNKNOWN,Sig2=0xFFFF, Type: CODE/DATA/CONST, NameType: ORDINAL/NAME/NAME_NOPREFIX/NAME_UNDECORATE) + two strings — "sufficient information to accurately reconstruct the entire contents of the member." The linker synthesizes the.idatacontributions and__imp_<name>from 20 bytes + 2 strings. Difficulty: M (~500 lines read+write; subtlety is x86 name-type handling_foo@8↔foo).__imp_and thunk synthesisdllimportcalls go indirect via__imp_<name>; calls withoutdllimportleave a directcall foo, and the linker synthesizesfoo: jmp [__imp_foo]. Data imports withoutdllimportare not fixable on MSVC. Difficulty: S (a few arch-specific byte arrays)./DELAYLOADLinker rewrites IAT slots to per-import thunks tail-calling a per-DLL stub →
__delayLoadHelper2(delayimp.lib) → LoadLibrary/GetProcAddress → patch. Structures: Delay-Load Directory Table,dlattrRvaform. lld's DLL.cpp shows the real cost: hand-encoded thunks × 4 architectures,__imp___load_<name>synthetics for CFG's.giats, and synthetic.pdata/.xdatafor the generated thunks on x64. Inherited constraints: no data imports, no delay-loading kernel32, no binding of forwarders. Difficulty: M/L (~1000 fiddly lines).Export table generation
Four input paths that must converge: (1)
dllexport→ compiler emits/EXPORT:<decorated>into.drectve; (2).defEXPORTS(with forwardersother.sym, ordinal forwardersother.#42,@ordinal,NONAME,PRIVATE,DATA); (3)/EXPORT:on the command line; (4)#pragma comment(linker,"/export:…"). Output is the five-table.edata(name pointer table sorted ascending — the loader binary-searches). Undecorated→decorated fuzzy matching is a documented linker responsibility. lld's.defsupport is partial (EXPORTS, HEAPSIZE, STACKSIZE, NAME, VERSION only). Difficulty: M — layout trivial, matching rules are where compat bugs live.MinGW:
.dll.a, auto-import, pseudo-relocsPer binutils ld WIN32 docs:
-lxxxsearches 8 forms including direct linking against a.dllwith no import library. Auto-export-everything by default (disabled by.def/dllexport, re-enabled--export-all-symbols). Auto-import rewrites data references into IAT indirections; non-zero addends are impossible statically → runtime pseudo-relocations: the linker emits an (IAT-slot RVA, target RVA, size) table between__RUNTIME_PSEUDO_RELOC_LIST__/__RUNTIME_PSEUDO_RELOC_LIST_END__and the CRT's_pei386_runtime_relocatorfixes them at startup (lld Writer.cpp:2419-2467; runtime side in mingw-w64-crt pseudo-reloc.c). Additional MinGW-persona obligations in lld: different default merge table (.ctors=.rdataetc.),__CTOR_LIST__/__DTOR_LIST__sentinels,--kill-at, stdcall fixup,--out-implib,--output-def, different decoration predicate.Honest assessment: import/export is ~70% mechanical, ~30% genuinely tricky — concentrated in (a) undecorated↔decorated matching, (b) delay-load thunks + unwind, (c) auto-import/pseudo-reloc (a whole parallel relocation model).
5. Windows-specific sections/metadata the linker must synthesize
.relocbase relocationsHIGHLOW/DIR64/ARM64 forms; suppressed by/FIXED..pdata/.xdata.pdataby function address (spec requirement); (2) synthesize unwind for linker-generated code (delay-load & range thunks); (3) COMDAT-associative discard propagation so a GC'd function's.pdatadies with it./SAFESEH(x86-32 only).sxdatasymbol indices +@feat.00LSB, dedupe/sort, emit RVA table into load config. If any object lacks@feat.00the image silently loses the table./GUARD:CF.gfids$y/.gljmp$y/.giats$y/.gehcont$y, skip entries whose section was GC'd (subtle), map.giatsto delay-load thunks, build sorted RVA tables in.00cfg, patchGuardCFFunctionTable/Count,GuardFlags(with the 4-bit stride subfield),GuardCFCheckFunctionPointer, setIMAGE_DLLCHARACTERISTICS_GUARD_CF._load_config_usedand the linker patches fields in place + sets the data directory (lldprepareLoadConfig). "Patch a CRT-provided struct" has no ELF analogue._tls_usedsymbol (spec-mandated technique), set TLS data directory,$-sort.tls$contributions, fix the alignment field. Raw Data Start/End are VAs → need base relocations..rsrcfrom.res).res, build the 3-level Type→Name→Language binary-sorted tree./MANIFESTINPUT(lld: libxml2 or shell out to mt.exe), wrap as RT_MANIFEST resource./DEPENDENTLOADFLAG,/CETCOMPAT/CETCOMPATforces a debug directory to exist.IMAGE_DEBUG_TYPE_CODEVIEW(GUID+Age+path), optionalIMAGE_DEBUG_TYPE_REPRO; the PDB itself: MSF container, DBI/TPI/IPI/GSI/PSI streams, CodeView type merging across.debug$T.6. COMDAT / section semantics — how much ELF layout logic transfers
COMDAT selection: 6 kinds vs ELF's 1
PE spec:
NODUPLICATES(error on dup),ANY(keep one),SAME_SIZE(error if sizes differ),EXACT_MATCH(error if contents differ),ASSOCIATIVE(linked iff the parent COMDAT is linked; per-section back-pointer DAG, cycle-checked),LARGEST(keep largest). ELFSHT_GROUPhas only "same signature → keep one."Delta for an ELF linker:
ANYtransfers;ASSOCIATIVEis group membership inverted (.pdata/.xdata/.gfids/.debug$Sall associative to their.text$mn— get it wrong and unwind info survives a GC'd function);LARGEST/SAME_SIZE/EXACT_MATCH/NODUPLICATEShave no ELF analogue (LARGESTis used by MSVC forselectanydata and vftables).String/constant merging
COFF has no
SHF_MERGE. MSVC puts each string literal in its ownSELECT_ANYCOMDAT.rdatasection named by content hash (??_C@…). Consequences: ELF string-merge machinery is dead weight for COFF; dedup falls out of COMDAT resolution +/OPT:ICF(which folds read-only data too and is on by default on Windows). Net: COFF has more input sections but simpler per-section semantics./OPT:REFvs--gc-sectionsNot equivalent.
/OPT:REFis on by default and operates at COMDAT granularity only — lld'smarkLiveseeds the worklist with every non-COMDAT chunk ("COMDAT section chunks are dead by default. Add non-COMDAT chunks"), so an object compiled without/Gyis one indivisible.text. The GC core transfers; the seeding rule and default-on-ness must change, and/INCLUDEbecomes a first-class root source from.drectve./OPT:ICFSame algorithm as ELF ICF (lld's comment says so), but: default-on for COFF; must respect COMDAT associativity (
assocEquals);/OPT:ICF=niterations;/opt:safeicfextension.Layout
$-suffix ordering (spec, Grouped Sections): contributions sorted lexically by the part after$, then$and suffix discarded. This is how.CRT$XCA…XCZstatic-init ordering and.gfids$yaggregation work. No ELF analogue; must be exact or C++ static init breaks.SectionAlignment(default 4096) vsFileAlignment(default 512) independent knobs.PT_LOADsegments — the ELF "assign sections to segments by permission" pass becomes "merge sections by name per the merge table"; permissions are per-section characteristics.Verdict: the skeleton (parallel parse, symbol table, GC, ICF, address assignment, parallel relocation, output write) transfers well — exactly Wild's strength. The semantics layer (COMDAT kinds, associativity,
$ordering,.drectve, merge tables, no SHF_MERGE) is substantially all-new. Rough split: ~50% of layout code reusable in shape, ~15% verbatim.7. Determinism on Windows
What
/Breproactually doesUndocumented by Microsoft; lld's implementation is the readable spec (
Writer::writeBuildId): xxh3 the output buffer; low 32 bits → COFF headerTimeDateStamp+ debug-directory timestamps; PDB70 record gets Age=1 + 8 hash bytes +"LLD PDB."; plus an emptyIMAGE_DEBUG_TYPE_REPROentry marking "timestamp is a hash." Image-level determinism is ~6 lines./TIMESTAMP:n(lld extension) is the escape hatch for tools wanting a plausible date.Full checklist for byte-reproducible EXE/DLL + PDB
TimeDateStamp/Breproor/TIMESTAMP:/PDBALTPATH:%_PDB%/pdbsourcepath:+ controlled build dirIMAGE_EXPORT_DIRECTORY.TimeDateStampIMAGE_RESOURCE_DIRECTORY.TimeDateStampDatefields + short-import timestamps/IMPLIBwriter).objtimestampsclang-cl /Brepro__DATE__/__TIME__-D…= -Wno-builtin-macro-redefined/INCREMENTALThe ducible post-processor exists because link.exe leaves several of these nondeterministic; a from-scratch linker should just get them right. Caveat from that post: the PDB DBI header carries the toolchain build number, so cross-machine PDB reproducibility additionally requires identical toolchain versions.
Does the MSVC ecosystem tolerate it?
Empirically yes: Chromium and Firefox ship lld-link-built
/Breprobinaries in production (exercising WinDbg, crash reporting, symbol servers daily); rustc 1.69+ passes/BreprowhenSOURCE_DATE_EPOCHis set; debuggers/symbol servers key on PDB GUID+Age, not timestamp. One documented failure mode: tools parsing the timestamp as a date (Win7 app-compat DB) — mitigate with/timestamp:. (SymSrv indexing of binaries by TimeDateStamp+SizeOfImage still works with hashed timestamps, but no primary source guarantees it — unverified.)Difficulty: S. Determinism is the cheapest requirement on the list and should be the default mode, not a flag.
Implementation-scale reference point
lld/COFFis 37 files, ~752 KB: Writer.cpp 114 KB, Driver.cpp 106 KB, PDB.cpp 69 KB, InputFiles.cpp 58 KB, SymbolTable.cpp 51 KB, Chunks.cpp 47 KB, DebugTypes.cpp 46 KB, DLL.cpp 39 KB — plusllvm/Object/COFF*,llvm/DebugInfo/{MSF,CodeView,PDB},llvm/Object/WindowsResource,llvm/WindowsManifest, and the tablegen option parser. That is the size of exactly the stated reld scope ("full link.exe compatibility minus /INCREMENTAL, minus CLR/WinMD/MIDL/PGO/FASTLINK"). Any from-scratch estimate should anchor to that number — with the caveat that ~25% of it (PDB + CodeView type merging) is a self-contained subsystem that could in principle be linked against LLVM rather than reimplemented.zackees commentedon Aug 26, 2026
Adversarial synthesis + DECISION
Fable's cross-examination of the five research reports above, followed by the decision. 2026-08-26.
What the evidence actually says (cross-checked across all five reports)
1. The LTO question is settled: linker choice is irrelevant for LTO builds. The 17–25x allocator swings (38m47s → 2m15s linking clang.exe by changing malloc alone) and the 96%-idle ThinLTO trace prove LTO wall time is LLVM codegen + allocator behavior inside the linker process, not link mechanics. Wild's own benchmark confirms from the other side:
wild-ltoloses to mold and lld. Consequence: the decision must be driven entirely by the non-LTO dev loop, and the LTO deliverable is allocator + DTLTO + caching work, which lives naturally in the LLVM/lld world.2. On Windows debug links, the linker IS the PDB writer. 96.8% of an 81.9s link is PDB emission. Every fast-linker project in history has either taken years on PDB (LLVM: ~3 years with Microsoft's source dump; Epic radlink: ~2 years in, still alpha), deferred it indefinitely (Zig: 8 years, still a TODO comment; the Wild COFF port explicitly excludes it), or refused the format entirely (mold). Wild's entire speed advantage is on the object-graph side — the part that is under 3% of a Windows debug link.
3. The user constraint "full link.exe compatibility mandatory (except /INCREMENTAL)" is the decisive constraint. lld-link is that compatibility surface today, shipping Chromium and Firefox, including PDB, both MSVC and MinGW personas, .drectve, CRT defaultlib fixed-point, CFG, delay-load, ARM64EC. The Wild path has 759 lines of argument parsing and none of the rest; the honest estimate assembled from Zig/radlink/Mach-O-port calibration is 1–2 engineer-years to MSVC-parity linking without PDB, plus the PDB discontinuity on top. That is not an MVP-cycle deliverable under this constraint.
4. The byte-identity test oracle — the reason to prefer the lld path — is confirmed real, with a documented recipe.
/Brepro /pdbaltpath:%_PDB% /pdbsourcepath:<fixed>, same argv[0] path, same cwd, pinned LLVM version. The three traps (EnvBlockSym recording exe/cmd/cwd, default absolute pdbaltpath, wall-clock timestamp default) are all controllable. Parallel type merging and ICF are deterministic by construction. On the Wild path this oracle is impossible by construction and the replacement apparatus (a COFF linker-diff + test corpus) is ~10k LOC + 221 test dirs of work that doesn't exist.5. The headroom for an lld-COFF fork is real and localized. Best modern datapoint: a 26 GB Unreal link burns 259.9s CPU in 29.7s wall on 64 threads — ~8.8x average concurrency, ~25s effectively serial. The serial points are enumerated and small in number: input-file taskQueue (fully serial), PDB symbol merging (serial; flagged as the obvious next step by upstream in 2020 and untouched for 6 years), TPI/IPI stream layout, MSF disk commit. Plus the parse-speed gap (lld 320ms vs wild 120ms on the same inputs). A 1.5–3x non-LTO win is a defensible target; the first candidate (parallel PDB symbol merging) is even upstreamable.
6. Both flavors come nearly free on the lld path, and are expensive on the Wild path. lld's MinGW driver is a ~700-line argument translator over the same COFF core; rustc integration is stable
-Clinker=on msvc (name the binary anything butlld-link) and-Clinker-flavor=ldon gnu. On the Wild path, MinGW auto-import/pseudo-relocs, both import-library styles, and direct-DLL linking are net-new backend work — and Wild's MSVC flavor has no maintainer champion ("MSVC doesn't matter to me").Adversarial findings — the strongest case AGAINST the recommendation, stated fairly
llvm/lib/DebugInfo/PDB/, not in lld — a serious PDB-speed fork forks LLVM too, or upstreams. Budget for that.objectcrate +ms-pdbmake the starting position better than Mach-O's was.Open questions carried forward (tracked, not blocking)
/time+--time-trace) — where does OUR time go: PDB type merge vs symbol merge vs input parse? Decides optimization order.microsoft/pdb-rsconstruct a linker-grade PDB from scratch (full TPI/IPI merge, GSI/PSI, line info)? If yes, the future Wild-COFF cost collapses from years to months. Cheap spike; do it once, file the answer here.DECISION
Chosen: Option 1 — fork LLD's COFF driver (plus the needed
llvm/DebugInfo/PDBbits) and optimize it, hybrid-style: fork for velocity, upstream the clean wins.Rejected for this cycle: Option 2 (Wild retrofit) — not on performance ceiling, but on (a) the mandatory full-link.exe-compat constraint, which only lld already satisfies; (b) the PDB discontinuity, which has defeated or been deferred by every fast-linker project except Epic's ~2-year effort; (c) the missing test oracle; (d) fork-economics against a 120-commit/month moving abstraction. Revisit trigger: the upstream Wild COFF port reaches "links real MSVC programs" AND the ms-pdb spike (question 2) comes back positive.
Plan sketch:
LLD_BUILT_STANDALONEagainst pinned LLVM; binary named NOTlld-link(clean rustc integration via stable-Clinker=); determinism-by-default (/Brepro-equivalent +%_PDB%+ fixed pdbsourcepath) as the fork's default mode.Kill criteria (written before build starts, per the no-rabbit-hole rule):
🤖 Generated with Claude Code
zackees commentedon Aug 26, 2026
Follow-on implementation is tracked in #92.
It sequences the selected LLD-COFF strategy as follows:
zackees/mimalloc-pprofintegration; establish system vsMI_PPROF=OFFvs sampled-profiling measurements while preserving byte-identical linker artifacts and native execution.zackees/llvm-ldas a minimal C/C++ library-only fork/extraction of the current LLD COFF driver (MSVC + MinGW). It will own the pinned LLVM source, narrow C ABI, vendored allocator replacement, and manual upstream LLD imports.llvm-ld: reld will own the Rust wrapper and vendor the pinned C/C++ source below_vendor/through a git-backed import, not crates.io.Research note:
mun-lang/lld-rsis useful prior art but not the base: it is LLVM-14-era, links every LLD driver, and its docs.rs build fails. Current LLD's COFF-as-a-library API plus a small C ABI shim is the lower-maintenance base.zackees commentedon Sep 18, 2026
Closing per #154's checklist ("audit and close"). The research question is answered and the decision is recorded in this issue's final comment: Windows goes through an LLD-COFF fork, not a COFF retrofit into wild. That route has since been built in zackees/llvm-ld, and #96 tracks the reld-side integration. Keeping this open made a settled decision look undecided.