From 15dcecee996c276f154e2d3683675b7f84b8acb4 Mon Sep 17 00:00:00 2001 From: Martin Pool Date: Sun, 14 Sep 2025 10:15:24 -0700 Subject: [PATCH 1/6] Configure Mold in ci-config.toml, not in config.toml This retains Mold in CI and lets developers choose anything locally. --- .cargo/ci-config.toml | 12 ++++++++++++ .cargo/config.toml | 8 -------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.cargo/ci-config.toml b/.cargo/ci-config.toml index 09e1af5c18174f..d5e312c2429ad8 100644 --- a/.cargo/ci-config.toml +++ b/.cargo/ci-config.toml @@ -10,3 +10,15 @@ # Here, we opted to use `[target.'cfg(all())']` instead of `[build]` because `[target.'**']` is guaranteed to be cumulative. [target.'cfg(all())'] rustflags = ["-D", "warnings"] + +# Use Mold on Linux, because it's faster than GNU ld and LLD. +# +# We no longer set this in the default `config.toml` so that developers can opt in to Wild, which +# is faster than Mold, in their own ~/.cargo/config.toml. +[target.x86_64-unknown-linux-gnu] +linker = "clang" +rustflags = ["-C", "link-arg=-fuse-ld=mold"] + +[target.aarch64-unknown-linux-gnu] +linker = "clang" +rustflags = ["-C", "link-arg=-fuse-ld=mold"] diff --git a/.cargo/config.toml b/.cargo/config.toml index 717c5e18c8d294..0bb7b6cf930eba 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -5,14 +5,6 @@ rustflags = ["-C", "symbol-mangling-version=v0", "--cfg", "tokio_unstable"] [alias] xtask = "run --package xtask --" -[target.x86_64-unknown-linux-gnu] -linker = "clang" -rustflags = ["-C", "link-arg=-fuse-ld=mold"] - -[target.aarch64-unknown-linux-gnu] -linker = "clang" -rustflags = ["-C", "link-arg=-fuse-ld=mold"] - [target.'cfg(target_os = "windows")'] rustflags = [ "--cfg", From 0dd0c23c20184ccdd4b528d40a30b1cd12078c7c Mon Sep 17 00:00:00 2001 From: Martin Pool Date: Sun, 14 Sep 2025 10:15:24 -0700 Subject: [PATCH 2/6] Describe and recommend Wild or Mold in the Linux dev docs --- docs/src/development/linux.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/docs/src/development/linux.md b/docs/src/development/linux.md index a0f9af5f264d7a..a6799378bc00b5 100644 --- a/docs/src/development/linux.md +++ b/docs/src/development/linux.md @@ -20,6 +20,33 @@ Clone down the [Zed repository](https://github.com/zed-industries/zed). If you are looking to develop Zed collaboration features using a local collaboration server, please see: [Local Collaboration](./local-collaboration.md) docs. +### Linkers {#linker} + +On Linux, Rust's default linker is [LLVM's `lld`](https://blog.rust-lang.org/2025/09/18/Rust-1.90.0/). Alternative linkers, especially [Wild](https://github.com/davidlattimore/wild) and [Mold](https://github.com/rui314/mold) can significantly improve clean and incremental build time. + +At present Zed uses Mold in CI because it's more mature. For local development Wild is recommended because it's 5-20% faster than Mold. + +These linkers can be installed with `script/install-mold` and `script/install-wild`. + +To use Wild as your default, add these lines to your `~/.cargo/config.toml`: + +```toml +[target.x86_64-unknown-linux-gnu] +linker = "clang" +rustflags = ["-C", "link-arg=--ld-path=wild"] + +[target.aarch64-unknown-linux-gnu] +linker = "clang" +rustflags = ["-C", "link-arg=--ld-path=wild"] +``` + +To use Mold as your default: + +```toml +[target.'cfg(target_os = "linux")'] +rustflags = ["-C", "link-arg=-fuse-ld=mold"] +``` + ## Building from source Once the dependencies are installed, you can build Zed using [Cargo](https://doc.rust-lang.org/cargo/). From b3ed2b1f3e5117755af1d1b7ac104e46f4b6f0e4 Mon Sep 17 00:00:00 2001 From: Martin Pool Date: Sat, 20 Sep 2025 09:18:19 -0700 Subject: [PATCH 3/6] Add a script to download Wild if it's not already on the path --- script/install-wild | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 script/install-wild diff --git a/script/install-wild b/script/install-wild new file mode 100755 index 00000000000000..da87b7b3c542df --- /dev/null +++ b/script/install-wild @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +# Install wild-linker official binaries from GitHub Releases. + +set -euo pipefail + +WILD_VERSION="${WILD_VERSION:-${1:-0.5.0}}" +if [ "$(uname -s)" != "Linux" ]; then + echo "Error: This script is intended for Linux systems only." + exit 1 +elif [ -z "$WILD_VERSION" ]; then + echo "Usage: $0 [version]" + exit 1 +elif which -s wild && wild --version | grep -Fq "$WILD_VERSION" ; then + echo "Warning: existing wild $WILD_VERSION found at $(which wild). Skipping installation." + exit 0 +fi + +if [ "$(whoami)" = root ]; then SUDO=; else SUDO="$(command -v sudo || command -v doas || true)"; fi + +ARCH="$(uname -m)" +WILD_REPO="${WILD_REPO:-https://github.com/davidlattimore/wild}" +WILD_PACKAGE="wild-linker-${ARCH}-unknown-linux-gnu" +WILD_URL="${WILD_URL:-$WILD_REPO}/releases/download/$WILD_VERSION/${WILD_PACKAGE}.tar.xz" + +echo "Downloading from $WILD_URL" +curl -fsSL --output - "$WILD_URL" \ + | $SUDO tar -C /usr/local/bin --strip-components=1 --no-overwrite-dir -xJf - \ + "wild-linker-${ARCH}-unknown-linux-gnu/wild" From ec49ec8e0d3e126fea5df6406696c2593e857228 Mon Sep 17 00:00:00 2001 From: Martin Pool Date: Sat, 20 Sep 2025 09:43:24 -0700 Subject: [PATCH 4/6] script/linux: Show recommended Wild config fragment --- script/linux | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/script/linux b/script/linux index 5523d876871a1d..3d619858d1b042 100755 --- a/script/linux +++ b/script/linux @@ -11,12 +11,23 @@ fi function finalize { # after packages install (curl, etc), get the rust toolchain which rustup > /dev/null 2>&1 || curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y - # verify the mold situation - if ! command -v mold >/dev/null 2>&1; then - echo "Warning: Mold binaries are unavailable on your system." >&2 - echo " Builds will be slower without mold. Try: script/install-mold" >&2 - fi - echo "Finished installing Linux dependencies with script/linux" + cat < Date: Wed, 24 Sep 2025 15:04:49 -0700 Subject: [PATCH 5/6] Wild now ships .tar.gz not .tar.xz MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Mateusz Mikuła --- script/install-wild | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/install-wild b/script/install-wild index da87b7b3c542df..374ff92c3c72c6 100755 --- a/script/install-wild +++ b/script/install-wild @@ -21,7 +21,7 @@ if [ "$(whoami)" = root ]; then SUDO=; else SUDO="$(command -v sudo || command - ARCH="$(uname -m)" WILD_REPO="${WILD_REPO:-https://github.com/davidlattimore/wild}" WILD_PACKAGE="wild-linker-${ARCH}-unknown-linux-gnu" -WILD_URL="${WILD_URL:-$WILD_REPO}/releases/download/$WILD_VERSION/${WILD_PACKAGE}.tar.xz" +WILD_URL="${WILD_URL:-$WILD_REPO}/releases/download/$WILD_VERSION/${WILD_PACKAGE}.tar.gz" echo "Downloading from $WILD_URL" curl -fsSL --output - "$WILD_URL" \ From 375ec4397f4c1b61a6decf009b374743c056245f Mon Sep 17 00:00:00 2001 From: Martin Pool Date: Wed, 24 Sep 2025 15:05:03 -0700 Subject: [PATCH 6/6] Update to Wild 0.6.0! MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Mateusz Mikuła --- script/install-wild | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/install-wild b/script/install-wild index 374ff92c3c72c6..7e35452db7f627 100755 --- a/script/install-wild +++ b/script/install-wild @@ -4,7 +4,7 @@ set -euo pipefail -WILD_VERSION="${WILD_VERSION:-${1:-0.5.0}}" +WILD_VERSION="${WILD_VERSION:-${1:-0.6.0}}" if [ "$(uname -s)" != "Linux" ]; then echo "Error: This script is intended for Linux systems only." exit 1