ElyLD is a GNU-ld-compatible linker aimed at fast iterative development. It is a fork of Wild, named after Elysia from Honkai Impact 3rd.
--incremental can patch an existing output when inputs change (GC and GCC LTO still fall back to a
full padded link; LLVM ThinLTO restages plugin objects and can update in place). It is also used as
a drop-in ELF linker for Linux kernels (vmlinux), glibc DSOs, and as a NixOS stdenv linker.
cargo install --locked --bin elyld --git https://github.com/tyler274/ElyLD.git elyldrelease, opt, and dist profiles use ThinLTO. CI (profile.ci) and dev do not.
To bootstrap (stage1 with the system linker, then relink ElyLD with itself):
./scripts/bootstrap.sh --profile release
./scripts/bootstrap.sh --profile optGNU dist releases run a PGO build trained on the full integration_tests suite (still self-hosted):
./scripts/pgo-build.shNeeds clang (rustc linker driver) and the rustup llvm-tools-preview component.
To use this tree from Nix, see the nix documentation.
Being a drop-in replacement, ElyLD can be used similarly to other linkers by being invoked by GCC or Clang. Meaning you have several options:
- Clang's exclusive option
--ld-path=elyld - GCC 16.1+ and Clang's option
-fuse-ld=elyld(note that Clang requiresld.elyldbinary/symlink) - Generally supported
-B <path>, where<path>is the directory containingldthat points toelyld
Below are examples of integrating ElyLD with various build systems.
You can use one of the options mentioned above in ~/.cargo/config.toml:
[target.x86_64-unknown-linux-gnu]
linker = "clang"
rustflags = ["-Clink-arg=--ld-path=elyld"]Or:
[target.x86_64-unknown-linux-gnu]
# linker = "clang" # Uncomment this line if your GCC is older than version 16.
rustflags = ["-Clink-arg=-fuse-ld=elyld"]CMake 4.4 or later has CMAKE_LINKER_TYPE=WILD for upstream Wild (ld.wild). For ElyLD, pass
--ld-path=elyld / -fuse-ld=elyld, or use the generic -B instructions below.
Usually setting LDFLAGS is enough, but there are projects that implement their own solutions:
export LDFLAGS="${LDFLAGS} -fuse-ld=elyld"Or (especially useful for older GCC versions), create a symlink ld pointing to elyld and pass the
directory to GCC:
ln -s /usr/bin/elyld /tmp/ld
export CFLAGS="${CFLAGS} -B/tmp"
export CXXFLAGS="${CXXFLAGS} -B/tmp"
export LDFLAGS="${LDFLAGS} -B/tmp"Then configure the project (you might need to remove the configuration cache first) and run your usual build steps.
Due to the complexity of these build systems, you might want to verify that ElyLD was used to link a binary with readelf.
[target.x86_64-unknown-illumos]
# Absolute path to clang - on OmniOS this is likely something like /opt/ooce/bin/clang.
linker = "/usr/bin/clang"
rustflags = [
# Will silently delegate to GNU ld or Sun ld unless the absolute path to ElyLD is provided.
"-Clink-arg=-fuse-ld=/absolute/path/to/elyld"
]If you'd like to use ElyLD as your linker for Rust code in CI, see wild-action.
Mold is already very fast, however it doesn't do incremental linking and the author has stated that
they don't intend to. ElyLD implements --incremental so repeated links can patch an existing
output instead of rewriting it from scratch.
The following platforms / architectures are currently supported:
- x86-64 on Linux
- ARM64 on Linux
- RISC-V (riscv64gc) on Linux
- LoongArch64 on Linux (initial support)
- PPC64LE on Linux (initial support)
Experimental Mach-O (AArch64) and Wasm32 are available behind cargo features (macho, wasm).
The following is working with the caveat that there may be bugs:
- Output to statically linked, non-relocatable binaries
- Output to statically linked, position-independent binaries (static-PIE)
- Output to dynamically linked binaries
- Output to shared objects (.so files)
- Rust proc-macros, when linked with ElyLD work
- Most of the top downloaded crates on crates.io have been tested with ElyLD and pass their tests
- Debug info (
--gdb-index) - GNU jobserver support
--incremental/ELYLD_INCREMENTAL=1— see Incremental linking- Linux kernel
vmlinux(x86_64 vs GNU ld; Clang ThinLTO vs LLD) — see Linux kernel - glibc
ld.so/libc.so/lib%.sorelink — see Glibc - GNU ld compatible
--version(GNU ld (ElyLD) 2.44) so glibcconfigureand the kernel'sscripts/ld-version.shaccept ElyLD - Linker-plugin LTO (GNU Gold API:
liblto_plugin.so,LLVMgold.so, rustc-Clinker-plugin-lto) - GNU
--wrap, including wrap after LTO - Linker scripts used by the kernel and glibc. See the linker script support matrix
- Nix stdenv linker via
-B/ld.elyld(see nix/nix.md)
Here are some of the larger remaining gaps:
- Incremental links with GC or GCC LTO (WPA) still fall back to a full padded link
- Mach-O and Wasm are experimental (not on by default)
- Windows / COFF
- Remaining linker-script gaps listed in LINKER_SCRIPT_SUPPORT.md
Pass --incremental or set ELYLD_INCREMENTAL=1. The first link writes a {output}.incr state
directory and pads output sections so a later link can patch in place. Unchanged objects skip
payloads. Custom linker scripts skip section padding so kernel ASSERTs keep their sizes; unchanged
inputs can still skip payloads.
GC (--gc-sections) and GCC LTO (WPA) fall back to a full padded link. LLVM ThinLTO plugin objects
are copied to {output}.incr/plugin/{NNNN}.o so a later link can skip unchanged payloads. You can
also pass --plugin-opt=cache-dir=PATH for LLVM's own cache; ElyLD does not inject that option
because GCC rejects unknown plugin opts. Integration tests cover GCC, Clang (including -flto=thin),
and rustc at several -O levels, plus unchanged relinks of x86_64 vmlinux and glibc DSOs. See
DESIGN.md for the atom table and skip-update model.
ElyLD links x86_64 vmlinux with the kernel's vmlinux.lds (--no-gc-sections, --orphan-handling=error).
Key symbols (_stext, _etext, __init_begin, _end, …) are checked against GNU ld. Clang ThinLTO
vmlinux is checked against LLD. --incremental on the same objects is a padded link (not compared
to GNU addresses); a dirty init/version-timestamp.o is expected to drop skip_payloads. ThinLTO
incremental restages LLVM plugin objects and expects an in-place update.
Point ELYLD_LINUX_TREE at a tree that already has vmlinux.o and GNU vmlinux.unstripped (pack
with scripts/pack-vmlinux-objects.sh), then:
cargo test -p elyld --test integration_tests -- vmlinuxThinLTO objects: ELYLD_LINUX_LTO_TREE and scripts/pack-vmlinux-lto-objects.sh. Arch-specific
kernel-like scripts (x86_64, aarch64, riscv64, loongarch64, ppc64le) are covered by the integration
suite. Feature status is in LINKER_SCRIPT_SUPPORT.md.
ElyLD relinks GNU-built glibc objects: ld.so, libc.so, and lib%.so PIC archives (libm,
libresolv, stubs, …). --incremental on those DSOs skips unchanged object payloads and still
rewrites dynamic reloc tables.
nix develop sets ELYLD_GLIBC_TREE / ELYLD_GLIBC_BUILD and provides wild-build-glibc. Then:
cargo test -p elyld --test integration_tests -- glibcwild-glibc-check runs a glibc make test subset against the ElyLD-linked DSOs. Details:
LINKER_SCRIPT_SUPPORT.md and
nix/nix.md.
Install readelf (available from binutils package), then run:
readelf --string-dump .comment my-executableLook for a line like:
Linker: ElyLD 1.0.0 (compatible with GNU linkers)
You can probably also get away with strings (also available from binutils package):
strings my-executable | grep 'Linker:'The name is after Elysia from Honkai Impact 3rd. Linkers traditionally end in "ld" (GNU ld, gold, lld, mold); ElyLD keeps that suffix. It is a fork of Wild.
The goal of ElyLD is to be very fast via incremental linking, and as fast as we can be for non-incremental linking and for the initial link when incremental linking is enabled.
All benchmarks are run with output to a tmpfs. See BENCHMARKING.md for details on running benchmarks.
We run benchmarks on a few different systems:
- Ryzen 9 9955HX (16 core, 32 thread)
- 2020 era Intel-based laptop with 4 cores and 8 threads
- Raspberry Pi 5
Here's a few highlights.
First, we link the Chrome web browser (or technically, Chromium).
Memory consumption when linking Chromium:
librustc-driver is the shared object where most of the code in the Rust compiler lives. This benchmark shows the time to link it.
For something much smaller, this is the time to link the linker itself. This also shows a few different versions, so you can see how the link time has been tracking over releases.
Here's linking rust-analyzer on a Raspberry Pi 5.
The following is a cargo test command-line that can be used to build and test a crate using ElyLD.
This has been run successfully on a few popular crates (e.g. ripgrep, serde, tokio, rand, bitflags).
It assumes that the elyld binary is on your path. It also depends on the Clang compiler being
installed, since GCC doesn't allow using an arbitrary linker.
RUSTFLAGS="-Clinker=clang -Clink-args=--ld-path=elyld" cargo testAlternatively, with ld.elyld symlink pointing at elyld:
RUSTFLAGS="-Clinker=clang -Clink-args=-fuse-ld=elyld" cargo testFor more information on contributing to ElyLD see CONTRIBUTING.md.
For a high-level overview of ElyLD's design, see DESIGN.md.
We have a Zulip server for ElyLD-related chat. You can join here.
Many of the posts on David's blog are about various aspects of ElyLD.
If you'd like to sponsor this work, that would be very much appreciated. The more sponsorship I get the longer I can continue to work on this project full time.
This project adheres to the Rust code of conduct. If you have any moderation concerns or queries, please email wild-mod@googlegroups.com.
Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in ElyLD by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
