Overview
x.py is the main entry point for building, testing, and developing the Rust compiler. Itβs a cross-platform script that bootstraps the build system and provides a consistent interface across all platforms.Entry Points
x (Unix)
Shell script for Unix-like systems (Linux, macOS, BSD)
x.ps1 (Windows)
PowerShell script for Windows systems
x.py (Cross-platform)
Python script that works on all platforms
All three entry points provide identical functionality. Use the one most convenient for your platform.
Quick Start
Subcommands
build
Compile the compiler, libraries, or specific components.Stage to build (0, 1, or 2). Each stage uses the previous stageβs compiler.
Pass
--timings to Cargo to generate build timing information.Number of parallel jobs to run. Defaults to number of CPU cores.
check
Quickly check code for errors without producing binaries.Check all targets (lib, bin, tests, examples, benches).
check is much faster than build since it doesnβt generate code. Use it for quick validation during development.clippy
Run Clippy linter on Rust code.Automatically apply Clippy suggestions.
Allow fixing even with uncommitted changes (requires
--fix).Allow fixing even with staged changes (requires
--fix).Clippy lints to allow.
Clippy lints to deny.
Clippy lints to warn on.
test
Run test suites.Stage to test. Note that
test --stage N uses the stage N-1 compiler.Arguments to pass to the test runner (libtest, compiletest, or rustdoc).
Run all tests regardless of failures.
Automatically update expected test outputs (for UI tests).
Skip documentation tests.
Run only documentation tests.
Mode for comparing UI test output (e.g., βnext-solverβ).
Force check/build/run-pass tests to this mode.
doc
Build documentation.Open the documentation in a browser after building.
Generate JSON format documentation in addition to HTML.
fmt
Format code using rustfmt.Check if code is formatted without applying changes.
Format all files, not just modified ones.
clean
Remove build artifacts.Clean entire build directory.
Clean specific stage without touching other artifacts.
dist
Build distribution artifacts (tarballs).install
Install built artifacts to a prefix.run
Run tools from the repository.Arguments to pass to the tool.
setup
Interactive setup for development environment.Development profile to configure.
library
library
For standard library development:
- Downloads CI-built LLVM and rustc
- Minimal build configuration
- Fast iteration on stdlib changes
compiler
compiler
For compiler development:
- Downloads CI-built LLVM
- Builds rustc from source
- Optimized for compiler changes
tools
tools
For tool development (cargo, rustfmt, etc.):
- Downloads CI-built compiler
- Minimal configuration
dist
dist
For building distributions:
- Builds everything from source
- Full optimization
- Used for releases
vendor
Vendor Rust dependencies.Additional Cargo.toml files to sync and vendor.
Always include version in subdirectory names.
Global Options
These options work with all subcommands:Path to bootstrap.toml configuration file.
Build directory (overrides config).
Build target triple.
Host target triples.
Target triples to build for.
Paths to exclude from build.
Paths to skip.
Include default paths in addition to specified ones.
Verbose output. Use multiple times for more verbosity (-vv, -vvv).
Use incremental compilation.
Show what would be built without actually building.
Stages to keep without recompiling.
Standard library stages to keep without recompiling.
Control color output.
How to handle warnings.
Use JSON message format.
Command to run on failure.
Override bootstrap.toml options (e.g.,
--set rust.debug=true).Common Workflows
Quick Development Iteration
Working on Standard Library
Running Benchmarks
Cross-Compilation
Performance Tips
Use --keep-stage
Use --keep-stage
Prevent recompilation of unchanged stages:
Download CI Artifacts
Download CI Artifacts
Configure in bootstrap.toml:
Use check Instead of build
Use check Instead of build
For quick validation:
Limit Parallel Jobs on Low Memory
Limit Parallel Jobs on Low Memory
Prevent OOM errors:
Troubleshooting
Build Failures
Python Version Issues
Submodule Issues
Related Documentation
Bootstrap System
Learn about the bootstrap architecture
Configuration Options
Explore bootstrap.toml settings