rustd
A Rust compiler that stays running. After an edit it compiles the functions that changed and links them into the program rustc already built.
curl -fsSL https://dioxuslabs.github.io/rustd/install.sh | sh
Then cargo rustd run in a workspace. Needs Rust 1.99.0 with
rust-src; the details.
This is rustd itself, built as WebAssembly and compiling the program on the left in your browser. Edit it while it runs. The full playground shows each build and says what the browser version cannot do.
What it is
rustd is a daemon that keeps rust-analyzer's analysis of your workspaces in memory and compiled functions on disk.
$ cargo rustd run # first build is cargo's; the daemon loads behind it
$ $EDITOR src/main.rs
$ cargo rustd run # the daemon compiles what changed, no cargo process runs
cargo and rustc start from the file system on every build. They parse, resolve, type-check and generate code for a whole crate again when one function in it changed, and a second checkout of the same repository starts from nothing. rustd keeps that work. Git worktrees of one repository share one database, and a function compiled once is found again by the hash of what it was compiled from, in any workspace on the machine or, through an S3 bucket, on another machine.
This is a prototype, published for the first time. rustc still does the first build, rustd has no diagnostics and no borrow checker of its own, and it is pinned to Rust 1.99.0. Read the Status section before relying on it.
Install
macOS arm64, Linux x86-64 and Linux AArch64:
curl -fsSL https://dioxuslabs.github.io/rustd/install.sh | sh
Windows x86-64, in PowerShell:
irm https://dioxuslabs.github.io/rustd/install.ps1 | iex
Both download the latest release,
check it against the release's SHA-256 sums and put rustd, cargo-rustd
and rustd-rustc in ~/.cargo/bin. Set RUSTD_VERSION=nightly
for the newest build of main. rustd also needs the toolchain it is pinned to:
rustup toolchain install 1.99.0 --component rust-src
On Windows the daemon runs and is tested, but cargo rustd does not link programs
there yet: a build fails and says so. Linux is where the numbers below come from.
The downloads have the Cranelift backend. The LLVM backend needs LLVM 20 on the machine and is built from source.
Use
There are two ways in. The first is a cargo subcommand, in any project built with 1.99.0:
cargo rustd build
cargo rustd run -- --some-flag
cargo rustd test
cargo rustd check
The second switches it on for plain cargo, for agents and scripts that call cargo themselves.
rustd enable adds one key to ~/.cargo/config.toml and
rustd disable puts the file back as it was.
rustd enable
cargo run
rustd status
rustd disable
When rustd cannot build something, the build fails and says why; nothing of the workspace is handed to cargo. The cargo guide has the details, and the platform notes say what has been run where.
Numbers
Linux x86-64, 8 CPUs, Cranelift, seconds, plain cargo against cargo rustd. Both
use the same linker, cargo is warm and incremental, the daemon is warm, and the program both
produce is run and compared. No cargo check runs beside a rustd build and nothing
is handed back to cargo, so the numbers that used to be here no longer apply.
Edits in a generated workspace of 200 crates, median of three:
| Edit | cargo | rustd | |
|---|---|---|---|
| A function body in the program's crate | 1.76 | 0.42 | 4.2x |
| A function body in the crate every other depends on | 6.33 | 0.60 | 10.6x |
| Function bodies in 30 crates at once | 6.26 | 0.62 | 10.1x |
| A new function | 2.09 | 0.56 | 3.7x |
| A signature whose callers are in every crate | 13.87 | 10.87 | 1.3x |
The last row is barely ahead: the edit changes 2,390 files and 6,806 functions are compiled again. That is open.
Real projects, one run each, a line added to a function:
| Project | No-change build | Build after an edit |
|---|---|---|
| ripgrep 15.1.0 | 0.42 / 0.02 | 1.28 / 0.36 |
| fd 10.3.0 | 0.41 / 0.03 | 0.52 / 0.17 |
| hyperfine 1.19.0 | 0.33 / 0.03 | 0.36 / 0.15 |
First build from an empty target directory, where cargo builds the dependencies and rustd the workspace's crates, one run each except nushell:
| Project | cargo build | cargo rustd build |
|---|---|---|
| ripgrep 15.1.0 | 5.43 | 6.05 |
| fd 10.3.0 | 20.5 | 22.0 |
| nushell 0.108.0 | 42.7, 42.9 | 66.4, 68.1, 89.9 |
rustd is behind on first builds, and far behind on nushell. How correctness is checked against rustc is in the results.
What it does not do
- It does not replace rustc. rustc builds the dependencies, and of the workspace its build scripts and proc macros.
- It finds no borrow or move errors.
cargo rustd checkiscargo check. - It does not optimise across functions. The code is for the edit loop, not for release.
- It has been wrong: a fuzzer found twenty-one problems, most of them miscompiles. The ones still open are listed in the support notes.