Overview
The Rust compiler build system is configured throughbootstrap.toml (or config.toml for backward compatibility). This file controls all aspects of the build process, from compiler optimization levels to LLVM configuration.
Configuration Files
bootstrap.toml
Primary configuration file (recommended)
config.toml
Legacy configuration file (still supported)
bootstrap.example.toml
Example with all available options
Profiles
Pre-configured defaults in
src/bootstrap/defaults/Getting Started
Global Settings
profile
Use different pre-set defaults than the global defaults.Available profiles:
compiler, library, tools, distSee src/bootstrap/defaults/ for profile definitions.include
Inherit configuration from other TOML files.Paths to additional configuration files. Later files override earlier ones.Supports absolute paths and relative paths (from current directory).
change-id
Track configuration version for change detection.ID from
src/bootstrap/src/utils/change_tracker.rsBootstrap warns when this doesn’t match the latest change ID. Set to "ignore" to suppress warnings.LLVM Configuration
llvm.download-ci-llvm
Download pre-built LLVM from CI instead of building locally.
true- Always download if availablefalse- Never download, always build"if-unchanged"- Download only if llvm-project is unchanged
This is the most significant build time optimization. Downloading takes ~5 minutes vs. 30-60 minutes to build.
llvm.optimize
Build LLVM in Release mode vs. Debug mode.
llvm.thin-lto
Build LLVM with ThinLTO enabled.Requires clang, lld, llvm-ar, and llvm-ranlib in your toolchain.
llvm.assertions
Enable LLVM assertions.
llvm.tests
Enable LLVM test suite in the build.Tests aren’t run automatically - use
ninja check-llvm in LLVM build dir.llvm.enzyme
Build Enzyme as AutoDiff backend.
llvm.ninja
Use Ninja to build LLVM (much faster than make).
llvm.targets
Semicolon-separated list of LLVM targets to build support for.Turning targets off will make rustc unable to compile for those architectures.
llvm.experimental-targets
Experimental LLVM targets (not built by default).
llvm.link-jobs
Cap parallel linker invocations when compiling LLVM.Useful when building with debug info. 0 = unlimited.
Build Configuration
build.build
Build triple for the pre-compiled snapshot compiler.Defaults to output of
rustc --version --verbose or platform detection.build.host
Host triples to build a compiler toolchain for.These are machines that will RUN the compiler.
build.target
Target triples to build libraries for.These are machines the compiler will CROSS-COMPILE to.
build.build-dir
Directory to store build artifacts.Paths are relative to the repository root.
build.cargo / build.rustc
Path to cargo binary to use instead of downloading stage0.
Path to rustc binary to use instead of downloading stage0.
If you set
rustc, you should also set cargo to use a matching toolchain.build.docs
Whether to build documentation by default.You can still build docs with
./x.py doc library/std when this is false.build.docs-minification
Minify CSS, JavaScript, and HTML in generated docs.
build.compiler-docs
Build compiler documentation by default.
build.library-docs-private-items
Include private items in library documentation.
build.submodules
Automatically manage and update git submodules.
build.verbose
Verbosity level:
0- Not verbose1- Verbose2- Very verbose3- Print environment variables on each rustc invocation
build.extended
Build extended Rust tool set (Cargo, rustfmt, clippy, etc.).
build.tools
Tools to include in installation when
extended = true.build.sanitizers
Build sanitizer runtimes (AddressSanitizer, ThreadSanitizer, etc.).
build.profiler
Build profiler runtime (required for
-C profile-generate and -C instrument-coverage).build.full-bootstrap
Perform full bootstrap without uplifting artifacts.Useful for verifying reproducible builds.
build.locked-deps
Force Cargo to check that Cargo.lock is up-to-date.
build.vendor
Use vendored sources for Rust dependencies.Auto-detected for tarball sources.
build.jobs
Number of parallel jobs. 0 = number of CPU cores.
Stage Defaults
Default stage for
build subcommand.Default stage for
test subcommand.Default stage for
doc subcommand.Default stage for
dist subcommand.Default stage for
install subcommand.Default stage for
bench subcommand.Rust Compilation Options
rust.optimize
Optimization level for compiler and standard library:
trueor3- All optimizationsfalseor0- No optimizations (NOT SUPPORTED)1- Basic optimizations2- Some optimizations"s"- Optimize for binary size"z"- Optimize for size, disable loop vectorization
rust.debug
Configure build for debugging Rust.Enables debug assertions and other debug-only features.
rust.debug-assertions
Enable debug assertions in compiler and standard library.Defaults to
rust.debug value.rust.debug-assertions-std
Enable debug assertions specifically in standard library.Overrides
debug-assertions.rust.overflow-checks
Enable overflow checks in compiler and standard library.Defaults to
rust.debug value.rust.debuginfo-level
Debuginfo level (corresponds to
-C debuginfo=N):0- No debug info1- Line tables only2- Full debug info (generates gigabytes, slows linking)
1 if rust.debug = true, otherwise 0.rust.debuginfo-level-rustc / std / tools / tests
Debuginfo level for the compiler.
Debuginfo level for the standard library.
Debuginfo level for tools.
Debuginfo level for compiletest tests.
rust.incremental
Use incremental compilation when building rustc.
rust.channel
Release channel:
stable, beta, nightly, dev, or auto-detect.Stable/beta only allow stable features. Nightly/dev allow unstable features.rust.download-rustc
Download stage 1 and 2 compilers from CI:
true- Always downloadfalse- Never download"if-unchanged"- Download if compiler hasn’t changed
rust.codegen-backends
Codegen backends to build and include in sysroot.Available:
llvm, cranelift, gccrust.lld
Compile and make LLD available in sysroot.
rust.llvm-tools
Make LLVM tools available in sysroot (llvm-objdump, llvm-nm, etc.).
rust.deny-warnings
Deny warnings when compiling rustc and libraries.
rust.backtrace-on-ice
Print backtrace on internal compiler errors during bootstrap.
rust.rpath
Build rustc with rpath enabled.Makes rustc usable directly from build directory.
rust.jemalloc
Link compiler against jemalloc instead of system allocator.Only tested on Linux and macOS.
rust.lto
LTO mode for rustc compilation:
"thin-local"- Thin LTO within single crate"thin"- Thin LTO across crates"fat"- Fat LTO"off"- No LTO
Installation Options
install.prefix
Installation prefix (must be absolute path).
install.sysconfdir
System configuration directory.
install.docdir
Documentation installation directory (relative to prefix).
install.bindir
Binary installation directory (relative to prefix).
install.libdir
Library installation directory (relative to prefix).
install.mandir
Man page installation directory (relative to prefix).
Target-Specific Options
Configure options for specific target triples:Compiler Toolchain
C compiler for this target.
C++ compiler for this target (host targets only).
Archiver for this target.
Ranlib for this target.
Linker for bootstrapping Rust code.
Target Configuration
Path to llvm-config for custom LLVM installation.When specified, LLVM won’t be built for this target.
Path to LLVM FileCheck utility.
LLVM libunwind configuration:
"no"- Link to libgcc_s.so"in-tree"- Static link to in-tree llvm-libunwind"system"- Link to system libunwind
Root of musl installation for musl targets.
Root of WASI SDK for wasm32-wasip1 targets.
QEMU rootfs location for testing.
Skip building std library for this target.Auto-enabled for
*-none-*, nvptx*, and *-uefi targets.Build sanitizer runtimes for this target.
Build profiler runtime for this target, or use existing one at path.
Enable rpath for this target.
Force static/dynamic linkage of standard library.
Test runner for compiletest (e.g., QEMU, wasmtime).
Distribution Options
dist.sign-folder
Folder containing artifacts to sign with GPG.
dist.upload-addr
Remote address for artifact uploads.
dist.compression-formats
Compression formats for dist tarballs.
dist.compression-profile
Compression profile:
fast, balanced, or best.Example Configurations
Related Documentation
Bootstrap System
Learn about bootstrap architecture
x.py Reference
Explore x.py commands