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