Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .cargo/ci-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
8 changes: 0 additions & 8 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
27 changes: 27 additions & 0 deletions docs/src/development/linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/).
Expand Down
29 changes: 29 additions & 0 deletions script/install-wild
Original file line number Diff line number Diff line change
@@ -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"
23 changes: 17 additions & 6 deletions script/linux
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<EOF
Note: It's recommended to install and configure Wild or Mold for faster builds.
Run script/install-wild or script/install-mold.
Then add these lines to your ~/.cargo/config.toml:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything following Then add these lines should probably live in script/install-wild. Since you might run install-wild after having already done install-linux and forget about those post install steps.


[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"]



Finished installing Linux dependencies with script/linux
EOF
}

# Ubuntu, Debian, Mint, Kali, Pop!_OS, Raspbian, etc.
Expand Down
Loading