Introduction
The Rust build system uses a Python script calledx.py to build the compiler, which manages the bootstrapping process. This script lives at the root of the project and handles all aspects of building, testing, and installing Rust.
The Bootstrap Process
Since the Rust compiler is written in Rust, it must be built by a precompiled “snapshot” version of itself (made in an earlier stage of development). This means:- Source builds require an Internet connection to fetch snapshots
- Your OS must be able to execute the available snapshot binaries
- Only platforms with “host tools” support have pre-compiled snapshots available
- To compile for platforms without host tools, you must cross-compile
See the Rust platform support documentation for a list of supported platforms and their tier levels.
Build Configuration
The build system uses a file namedbootstrap.toml to determine various configuration settings. You can see a full list of options in bootstrap.example.toml.
- Interactive Setup
- Configure Script
- Manual TOML
The easiest way to get started is with the interactive setup command:This will guide you through:
- Selecting a config profile (compiler, library, tools, etc.)
- Setting up LSP (rust-analyzer)
- Configuring Git hooks
- Other common development settings
Running x.py
On most Unix systems, you can runx.py directly:
build- Build the compiler and standard librarytest- Run the test suitedoc- Build documentationinstall- Install the built compilercheck- Quick syntax check without full compilationclippy- Run Clippy lintsfmt- Format code with rustfmt
Build Stages
The Rust build happens in stages:Stage 0
Uses the downloaded snapshot compiler to build the build system and compile the stage 1 compiler.
By default,
x.py build builds through stage 1. Use --stage 2 to build the final compiler.Quick Reference
| Command | Description |
|---|---|
./x.py setup | Interactive configuration |
./configure | Generate bootstrap.toml |
./x.py build | Build compiler (stage 1) |
./x.py build --stage 2 | Build final compiler |
./x.py test | Run test suite |
./x.py doc | Build documentation |
./x.py install | Install to system |
./x.py --help | Show all options |
Next Steps
Install Dependencies
Set up required dependencies for your platform
Unix Build Guide
Step-by-step instructions for Unix-like systems
Windows Build Guide
Step-by-step instructions for Windows
Configuration Options
Explore all configuration options
Additional Resources
- Rustc Dev Guide - Comprehensive guide to compiler development
- How to Build and Run - Detailed build instructions
- Getting Started - Contributing to Rust