Repository navigation
feat: link Windows COFF in-process through prebuilt llvm-ld-coff (reld#96) - #202
Merged
Merged
Conversation
…d#96) llvm-ld-coff (zackees/llvm-ld) is LLD's COFF linker, the lld-link/MSVC and MinGW drivers, built as a shared library with a C ABI. Every build of it links Windows PE/COFF; the Linux and macOS builds are Windows cross-linkers. reld now offers every COFF and MinGW link to it in-process before falling back to spawning lld-link: - crates/reld-core/src/llvm_ld.rs loads the library at runtime through the already-approved libloading (no new dependency, no host cfg), checks the C ABI version before any call, and treats anything short of a working library as "unavailable", so the subprocess bridge stays the fallback and the escape hatch (RELD_LLVM_LD=off). An explicit RELD_BRIDGE_LINKER bypasses it. - reld never compiles LLVM. ci/llvm_ld.lock.json pins llvm-ld v0.1.0 per host triple by SHA-256; ci/fetch_llvm_ld.py downloads, verifies and caches it. Updating llvm-ld is a lock-file change; updating reld never rebuilds it. - release.yml bundles the library next to reld in every archive except musl (static musl reld cannot load a shared library) and smokes the packaged layout, with no override, to prove reld finds and uses it. - CI proves the path on Linux (a Windows cross-link) and on Windows MSVC, where the sqlite e2e and the self-host link now run in-process. ci/llvm_ld_e2e.py requires byte-identical output to the lld-link subprocess. Measured locally: identical output to lld-link, and 8.9 ms vs 56.6 ms per small link (about 6.4x), mostly the per-link process spawn it removes. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…th /Brepro A pull_request run of release.yml exists to validate the pipeline, but it checked out the already-existing v0.1.0 tag, so the new llvm-ld staging step ran against source lacking ci/fetch_llvm_ld.py. PR runs now build the PR's commit; manual dispatches still rebuild an existing tag. The llvm-ld pin and fetch script now also trigger the workflow. The Windows e2e compared outputs of two links made a second apart; lld-link stamps the PE header with the link time, so they differed. /Brepro makes the comparison deterministic. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This was referenced Sep 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #96.
Windows COFF and MinGW links now run in-process through llvm-ld-coff, which is LLD's COFF linker (lld-link/MSVC and MinGW drivers) built as a shared library with a C ABI. It only ever links Windows PE/COFF. Its Linux and macOS builds are Windows cross-linkers.
reld never compiles LLVM
llvm-ld builds and publishes its own prebuilts for eight hosts (zackees/llvm-ld#36, release v0.1.0): Windows x64/arm64, Linux glibc and musl on x64/arm64, and macOS x64/arm64. reld only consumes them:
ci/llvm_ld.lock.jsonpins v0.1.0 per host triple by SHA-256, generated from the release's ownSHA256SUMS.ci/fetch_llvm_ld.pydownloads, verifies and caches the pinned archive. CI caches it by lock-file hash.How reld uses it
crates/reld-core/src/llvm_ld.rs): the library is loaded at runtime through the already-approvedlibloading, so there's no new dependency and no hostcfg. The C ABI version is checked before any call.lld-linksubprocess bridge, which stays the escape hatch (RELD_LLVM_LD=off). An explicitRELD_BRIDGE_LINKERbypasses the in-process path.reld-link, and MinGW for links that TargetProbe (routing: TargetProbe drives engine selection, plus Engine::MingwLld (reld#123 Phase 3, step 2) #184) identifies as PE-MinGW.llvm-ldis on by default, and clippy is clean with it off too.Release and CI
release.ymlbundles the library next to reld in every archive except musl, because a static musl reld can't load a shared library. The native legs then extract the finished archive and run thereld-linkinside it with no override, proving the shipped layout is found and used in-process. The Windows smoke asserts the same.phase1-nativedoes an in-process Windows cross-link throughlibllvm_ld.so.phase1-native-runstagesllvm_ld.dllnext toreld-link.exebefore the sqlite e2e and self-host, so all of SQLite and reld itself are linked through llvm-ld-coff in-process. It then runs the e2e and executes the result.ci/llvm_ld_e2e.pyrequires the in-process output to be byte-identical to thelld-linksubprocess's.Measured locally
These results use the published v0.1.0 library, not a local build:
libllvm_ld.sodepends only onlibc/libmbecause libstdc++ is linked statically, and it loads on NixOS even though it was built on Ubuntu.lld-linksubprocess exactly, for both the MSVC and MinGW drivers.reld-core: 266 tests.bridge-route: 13. Python: 369.🤖 Generated with Claude Code