Skip to content

Commit 68e1f09

Browse files
committed
Switch from ld (the default linker) to using lld for GNU Linux targets
**What's wrong with `ld`?** It's very slow and uses a lot of memory. **Why `lld`?** It's fast, mature, and well-supported. Meta and Google use it for all their linking workloads. We're already using it for macos and x86-64 Windows. There is [ongoing work to make it the default for rustc](rust-lang/rust#71515), and it already is default on a few platforms. **Why not `mold`?** Mold is generally faster, but the margin is slim enough for our workloads that it doesn't really matter. Mold only recently got support for LTO, doesn't support v0 rust symbol demanging, doesn't support BOLT (though we don't use that yet), etc. Mold is maturing quickly, but `lld` still seems like the "safer" choice.
1 parent 829012c commit 68e1f09

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

.cargo/config.toml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,18 @@ rustdocflags = ["-Znormalize-docs"]
1515
[target.x86_64-pc-windows-msvc]
1616
linker = "rust-lld"
1717

18-
[target.aarch64-apple-darwin]
18+
[target.'cfg(target_os = "macos")']
1919
linker = "rust-lld"
2020

21-
[target.x86_64-apple-darwin]
22-
linker = "rust-lld"
21+
[target.'cfg(all(target_os = "linux", target_env = "gnu"))']
22+
rustflags = [
23+
"--cfg",
24+
"tokio_unstable",
25+
"-Zshare-generics=y",
26+
"-Zthreads=8",
27+
"-Csymbol-mangling-version=v0",
28+
"-Clink-arg=-fuse-ld=lld",
29+
]
2330

2431
[alias]
2532
xtask = "run --package xtask --"

CONTRIBUTING.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ Thanks for your interest in contributing to Turbo!
2929
- [Rust](https://www.rust-lang.org/tools/install)
3030
- [cargo-groups](https://github.com/nicholaslyang/cargo-groups) (used to group crates into Turborepo-specific ones and Turbopack-specific ones)
3131

32+
### Linux Dependencies
33+
34+
- LLD (LLVM Linker), as it's not installed by default on many Linux distributions (e.g. `apt install lld`).
35+
3236
## Contributing to Turborepo
3337

3438
### Building Turborepo

0 commit comments

Comments
 (0)