Quick Start
For experienced developers who want to get started quickly:For a detailed explanation and configuration options, continue reading below.
Prerequisites
Before building, ensure you have all required dependencies installed.Step-by-Step Build Process
Clone the Repository
Clone the Rust source code from GitHub:The repository is large (several GB), so cloning may take some time.
Configure the Build
Choose one of the following configuration methods:
- Interactive Setup (Recommended)
- Configure Script
- Manual Configuration
Run the interactive setup to configure your build profile:You’ll be prompted to select a profile:
- library - For contributing to the standard library
- compiler - For contributing to the compiler
- codegen - For contributing to code generation
- tools - For contributing to tools like Clippy or rustfmt
- user - For general usage and experimentation
- LSP (Language Server Protocol) with rust-analyzer
- Git hooks for commit validation
- Editor integration
Build the Compiler
Build Rust using the This builds:
x.py script:- Standard Build
- Stage 2 Build
- Specific Components
- Parallel Build
- The stage 1 compiler
- The standard library
- Core tools (if
extended = true)
First-time builds can take 30 minutes to several hours depending on your hardware and whether you’re downloading or building LLVM.
Install (Optional)
Install the built compiler to your system:By default, this installs to The installation includes:
/usr/local. Customize the installation directory:- Using DESTDIR
- Using Configure
- Using bootstrap.toml
rustc- The Rust compilerrustdoc- Documentation generatorcargo- Package manager (ifextended = true)- Additional tools based on your configuration
Advanced Configuration Examples
Cross-Compilation Setup
Cross-Compilation Setup
Example configuration for cross-compiling to ARM64 Linux:Or in
bootstrap.toml:Optimized Development Build
Optimized Development Build
Configuration optimized for fast rebuilds during development:
bootstrap.toml
Production Release Build
Production Release Build
Configuration for building a production release:
Custom LLVM Build
Custom LLVM Build
Building with custom LLVM settings:
bootstrap.toml
Using Configure and Make
For those familiar with traditional Unix build systems:The
Makefile is a wrapper around x.py. We recommend using x.py directly for better control and error messages.Testing Your Build
After building, verify everything works:Building Documentation
Build the Rust documentation:build/<target>/doc directory.
Troubleshooting
Build Fails: Out of Memory
Build Fails: Out of Memory
LLVM compilation is memory-intensive. Solutions:
- Use pre-built LLVM:
- Reduce parallel jobs:
- Limit linker jobs:
Build is Very Slow
Build is Very Slow
Speed up builds:
- Download LLVM instead of building
- Use Ninja instead of Make for LLVM
- Enable ccache
- Disable documentation builds
- Use incremental compilation
bootstrap.toml
Submodule Errors
Submodule Errors
Update git submodules:Or let bootstrap manage them:
Next Steps
Configuration Options
Explore all available configuration options
Rustc Dev Guide
Learn about compiler internals and contributing