Wild is a drop-in replacement for the system linker. GCC or Clang invokes it.
The same integration options apply across build systems:
- Clang's exclusive option
--ld-path=wild - GCC 16.1+ and Clang's option
-fuse-ld=wild(note that Clang requires anld.wildbinary or symlink) - Generally supported
-B <path>, where<path>is the directory containing anldthat points towild
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=wild"]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=wild"]The following cargo test command-line builds and tests a crate using Wild. This has been run
successfully on a few popular crates (e.g. ripgrep, serde, tokio, rand, bitflags). It assumes that
the wild 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=wild" cargo testAlternatively, with an ld.wild symlink pointing at wild:
RUSTFLAGS="-Clinker=clang -Clink-args=-fuse-ld=wild" cargo test[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 Wild is provided.
"-Clink-arg=-fuse-ld=/absolute/path/to/wild"
]CMake 4.4 or later supports Wild directly when used with Clang or GCC 16 or later. You can select
Wild as the linker by adding -DCMAKE_LINKER_TYPE=WILD to the cmake command-line.
For older versions of cmake, see the generic instructions below.
Usually setting LDFLAGS is enough, but there are projects that implement their own solutions:
export LDFLAGS="${LDFLAGS} -fuse-ld=wild"Or (especially useful for older GCC versions), create a symlink ld pointing to wild and pass the
directory to GCC:
ln -s /usr/bin/wild /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 Wild was used to link a binary with readelf.
Pass the wild binary and -C linker-flavor=wasm-ld. The same flags apply to wasm32-unknown-unknown.
RUSTFLAGS="-C linker=path/to/wild -C linker-flavor=wasm-ld" \
cargo build --target wasm32-wasip1[target.wasm32-wasip1]
rustflags = ["-C", "linker=path/to/wild", "-C", "linker-flavor=wasm-ld"]As with ELF, point Clang at a directory that contains a wasm-ld symlink to wild. -fuse-ld=lld makes Clang look up that wasm-ld. clang++ takes the same flags.
mkdir -p /tmp/wild
ln -sf "$(command -v wild)" /tmp/wild/wasm-ld
clang --target=wasm32-wasi -B/tmp/wild -fuse-ld=lld hello.c -o hello.wasmFor autotools, Meson, and similar drivers:
export CC="clang --target=wasm32-wasi"
export CXX="clang++ --target=wasm32-wasi"
export LDFLAGS="${LDFLAGS} -B/tmp/wild -fuse-ld=lld"Pass a directory that contains a wasm-ld symlink to wild and -fuse-ld=lld. For C++, set CMAKE_CXX_COMPILER=clang++ and CMAKE_CXX_COMPILER_TARGET=wasm32-wasi as well.
cmake -S . -B build \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_C_COMPILER_TARGET=wasm32-wasi \
-DCMAKE_EXE_LINKER_FLAGS="-B/tmp/wild -fuse-ld=lld" \
-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARYIf you'd like to use Wild as your linker for Rust code in CI, see wild-action.