Skip to content

Commit 70751d7

Browse files
committed
docs: document nightly linker options
Document nightly rustc and fast-linker env vars Add install guidance and build/test examples.
1 parent f7f1aa9 commit 70751d7

2 files changed

Lines changed: 76 additions & 15 deletions

File tree

README.md

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ To opt into nightly (for parallel rustc or other nightly-only features), use one
4848
If you prefer explicit file selection, temporarily copy or symlink `rust-toolchain-nightly.toml` to
4949
`rust-toolchain.toml`. Stable builds do not enable nightly-only flags globally.
5050

51+
Nightly-specific tooling flags are controlled via environment variables:
52+
53+
- `PLATFORM_RUST_NIGHTLY=1` forces nightly toolchains in scripts.
54+
- `PLATFORM_DISABLE_NIGHTLY=1` disables nightly flags even on nightly.
55+
- `PLATFORM_NIGHTLY_RUSTFLAGS` adds nightly-only rustc flags like `-Z threads=0`.
56+
5157
### Faster Builds (Parallel rustc + Fast Linker)
5258

5359
The repository ships with `.cargo/config.toml` configured to use all available CPU cores for compilation
@@ -58,10 +64,10 @@ Nightly-only parallel rustc is enabled by default when you use the nightly toolc
5864
(`rust-toolchain-nightly.toml`). It sets `PLATFORM_NIGHTLY_RUSTFLAGS="-Z threads=0"`, which lets nightly
5965
use all CPU threads. If you opt into nightly via `RUSTUP_TOOLCHAIN=nightly` or `cargo +nightly`, set
6066
`PLATFORM_NIGHTLY_RUSTFLAGS` yourself (for example, `-Z threads=0` or `-Z threads=8`). Opt out by
61-
unsetting `PLATFORM_NIGHTLY_RUSTFLAGS` (or setting it to an empty string). The
62-
`scripts/verify-nightly-config.sh`, `scripts/test-all.sh`, and `scripts/test-comprehensive.sh` helpers also
63-
honor `PLATFORM_DISABLE_NIGHTLY=1` for an explicit opt-out, and accept `PLATFORM_RUST_NIGHTLY=1` to force
64-
nightly toolchains during scripted runs.
67+
unsetting `PLATFORM_NIGHTLY_RUSTFLAGS` (or setting it to an empty string) or setting
68+
`PLATFORM_DISABLE_NIGHTLY=1`. The `scripts/verify-nightly-config.sh`, `scripts/test-all.sh`, and
69+
`scripts/test-comprehensive.sh` helpers also honor `PLATFORM_DISABLE_NIGHTLY=1` for an explicit opt-out,
70+
and accept `PLATFORM_RUST_NIGHTLY=1` to force nightly toolchains during scripted runs.
6571

6672
Fast linker support is opt-in via environment variables; if you leave these unset,
6773
Rust falls back to the system linker. Supported linkers:
@@ -93,6 +99,17 @@ when this is set). To override defaults explicitly, set `PLATFORM_LINKER_RUSTFLA
9399
or `PLATFORM_LINKER_RUSTFLAGS_DARWIN` (macOS); these override the opt-in fast-linker values
94100
when present.
95101

102+
103+
Example: faster build/test runs with nightly + linker selection:
104+
105+
```bash
106+
export RUSTUP_TOOLCHAIN=nightly
107+
export PLATFORM_NIGHTLY_RUSTFLAGS="-Z threads=0"
108+
export PLATFORM_FAST_LINKER_RUSTFLAGS="-C link-arg=-fuse-ld=mold"
109+
110+
cargo build
111+
cargo test
112+
```
96113
Fast linker prerequisites (Ubuntu/Debian):
97114

98115
```bash
@@ -102,6 +119,13 @@ sudo apt-get install -y mold
102119
sudo apt-get install -y lld
103120
```
104121

122+
Fast linker prerequisites (macOS):
123+
124+
```bash
125+
brew install llvm
126+
brew install zld
127+
```
128+
105129
### CI Nightly Opt-In
106130

107131
CI runs stable by default. To run nightly builds/tests, trigger the workflow manually and set

docs/validator.md

Lines changed: 48 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,23 @@ Validator development builds can take advantage of nightly parallel rustc and fa
9191
toolchain file (`rust-toolchain-nightly.toml`) sets `PLATFORM_NIGHTLY_RUSTFLAGS="-Z threads=0"`, which
9292
uses all available CPU threads. If you opt into nightly with `RUSTUP_TOOLCHAIN=nightly` or
9393
`cargo +nightly`, set `PLATFORM_NIGHTLY_RUSTFLAGS` yourself (for example, `-Z threads=0` or
94-
`-Z threads=8`). To opt out, unset `PLATFORM_NIGHTLY_RUSTFLAGS` or set it to an empty string. The
95-
`scripts/verify-nightly-config.sh`, `scripts/test-all.sh`, and `scripts/test-comprehensive.sh` helpers
96-
respect `PLATFORM_DISABLE_NIGHTLY=1` for a forced opt-out and accept `PLATFORM_RUST_NIGHTLY=1` to force
97-
nightly toolchains during scripted checks.
94+
`-Z threads=8`). To opt out, unset `PLATFORM_NIGHTLY_RUSTFLAGS` or set it to an empty string, or set
95+
`PLATFORM_DISABLE_NIGHTLY=1`. The `scripts/verify-nightly-config.sh`, `scripts/test-all.sh`, and
96+
`scripts/test-comprehensive.sh` helpers respect `PLATFORM_DISABLE_NIGHTLY=1` for a forced opt-out and
97+
accept `PLATFORM_RUST_NIGHTLY=1` to force nightly toolchains during scripted checks.
98+
99+
Nightly and linker-related environment variables:
100+
101+
- `PLATFORM_RUST_NIGHTLY=1`: force nightly toolchains in scripts.
102+
- `PLATFORM_DISABLE_NIGHTLY=1`: disable nightly flags even on nightly.
103+
- `PLATFORM_NIGHTLY_RUSTFLAGS`: nightly-only rustc flags (for example, `-Z threads=0`).
104+
- `PLATFORM_FAST_LINKER_RUSTFLAGS`: opt-in fast-linker flags for Linux.
105+
- `PLATFORM_FAST_LINKER_RUSTFLAGS_DARWIN`: opt-in fast-linker flags for macOS.
106+
- `PLATFORM_LINKER_RUSTFLAGS`: explicit linker flags for Linux (override fast-linker defaults).
107+
- `PLATFORM_LINKER_RUSTFLAGS_DARWIN`: explicit linker flags for macOS (override fast-linker defaults).
108+
- `PLATFORM_DISABLE_FAST_LINKER=1`: disable fast-linker flags in scripts.
98109

99110
Supported fast linkers:
100-
101111
- **Linux**: `mold`, `lld`
102112
- **macOS**: `lld`, `zld`
103113

@@ -117,12 +127,32 @@ export PLATFORM_FAST_LINKER_RUSTFLAGS="-C link-arg=-fuse-ld=mold"
117127
cargo build
118128
```
119129

120-
Opt out of fast linker flags by unsetting `PLATFORM_FAST_LINKER_RUSTFLAGS`/
121-
`PLATFORM_FAST_LINKER_RUSTFLAGS_DARWIN`, setting `PLATFORM_LINKER_RUSTFLAGS` (Linux) /
122-
`PLATFORM_LINKER_RUSTFLAGS_DARWIN` (macOS) to an empty string, or exporting
123-
`PLATFORM_DISABLE_FAST_LINKER=1` for scripted runs. To override defaults explicitly, set
124-
`PLATFORM_LINKER_RUSTFLAGS` (Linux) or `PLATFORM_LINKER_RUSTFLAGS_DARWIN` (macOS); these override the
125-
opt-in fast-linker values when present.
130+
Fast linker prerequisites (Ubuntu/Debian):
131+
132+
```bash
133+
sudo apt-get update
134+
sudo apt-get install -y mold
135+
# or
136+
sudo apt-get install -y lld
137+
```
138+
139+
Fast linker prerequisites (macOS):
140+
141+
```bash
142+
brew install llvm
143+
brew install zld
144+
```
145+
146+
Example: faster build/test runs with nightly + linker selection:
147+
148+
```bash
149+
export RUSTUP_TOOLCHAIN=nightly
150+
export PLATFORM_NIGHTLY_RUSTFLAGS="-Z threads=0"
151+
export PLATFORM_FAST_LINKER_RUSTFLAGS="-C link-arg=-fuse-ld=mold"
152+
153+
cargo build --release --bin validator-node
154+
cargo test
155+
```
126156

127157
### Bittensor
128158

@@ -218,6 +248,13 @@ sudo apt-get install -y mold
218248
sudo apt-get install -y lld
219249
```
220250

251+
Install a fast linker (macOS):
252+
253+
```bash
254+
brew install llvm
255+
brew install zld
256+
```
257+
221258
To opt out for tests, export `PLATFORM_DISABLE_NIGHTLY=1` (disable nightly flags) and/or
222259
`PLATFORM_DISABLE_FAST_LINKER=1` (disable fast linker flags). To override Linux/macOS linker flags
223260
explicitly, set `PLATFORM_LINKER_RUSTFLAGS` or `PLATFORM_LINKER_RUSTFLAGS_DARWIN`.

0 commit comments

Comments
 (0)