Chapter 29: toolchains, which compiler, and why always -O3
buck2 does not ship compilers. A buck2 project names, in a toolchains
cell, which compiler each kind of rule uses, and this folder is that cell.
Every toolchain here is one of the prelude's system_* ones, which means
"whatever is on PATH". Inside nix develop, PATH is the devshell, so in
practice the flake decides the versions: rustc from fenix, clang and lld
from nixpkgs.
The interesting line is one flag on the Rust toolchain:
rustc_flags = ["-Copt-level=3", "-Cdebuginfo=1"],
Every Rust target in the repository is built optimised. Not as a release mode you switch to: always.
Aside: a game you cannot play in debug. The prelude's default is rustc's, opt-level 0, and a cycle-accurate SNES core at opt-level 0 runs below real time: 24 to 31 frames a second against the console's 60 (measured 2026-09-20). So an unoptimised build is not a slower version of the same program; the game cannot be played in it. jgenesis' own
Cargo.tomlsays the same ("most of the emulators are unusably slow without optimizations"). Debug info stays on: it costs nothing at run time and keeps backtraces readable.
test and remote_test_execution exist because rust_test asks for both.
Tests here are plain binaries run where they were built, so neither
configures anything; the prelude ships a no-op for the first and not the
second, so local_test_execution.bzl is the smallest thing that satisfies
it.
Try it.
nix develop -c buck2 test //...runs every test target with these toolchains. Outside the devshell the same command uses whatever rustc the host has, or none.
For the people who maintain it
In this folder
| Path | What |
|---|---|
| BUCK | The cell: rust (edition 2024, -Copt-level=3 -Cdebuginfo=1), cxx, python_bootstrap, genrule, the no-op test toolchain and remote_test_execution. |
| local_test_execution.bzl | The minimal RemoteTestExecutionToolchainInfo rule for purely local test runs. |
| README.md | This chapter. |
| CLAUDE.md | Do not add a debug build, for agents. |
← Previous: Chapter 28, nix/ · Up: jevsnes · Next: Chapter 30, platforms/ →