Skip to main content

Quick Start

For experienced developers who want to get started quickly:
git clone https://github.com/rust-lang/rust.git
cd rust
./x.py setup
./x.py build
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

1

Clone the Repository

Clone the Rust source code from GitHub:
git clone https://github.com/rust-lang/rust.git
cd rust
The repository is large (several GB), so cloning may take some time.
For faster cloning, use a shallow clone:
git clone --depth 1 https://github.com/rust-lang/rust.git
However, this is not recommended if you plan to contribute.
2

Configure the Build

Choose one of the following configuration methods:
3

Build the Compiler

Build Rust using the x.py script:
./x.py build
This builds:
  • 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.
4

Install (Optional)

Install the built compiler to your system:
./x.py install
By default, this installs to /usr/local. Customize the installation directory:
export DESTDIR=/path/to/install
./x.py install
The installation includes:
  • rustc - The Rust compiler
  • rustdoc - Documentation generator
  • cargo - Package manager (if extended = true)
  • Additional tools based on your configuration
When DESTDIR is set, the prefix and sysconfdir values are combined with the DESTDIR path.

Advanced Configuration Examples

Example configuration for cross-compiling to ARM64 Linux:
./configure \
  --build=x86_64-unknown-linux-gnu \
  --target=aarch64-unknown-linux-gnu \
  --set target.aarch64-unknown-linux-gnu.linker=aarch64-linux-gnu-gcc
Or in bootstrap.toml:
[build]
build = "x86_64-unknown-linux-gnu"
target = ["x86_64-unknown-linux-gnu", "aarch64-unknown-linux-gnu"]

[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"
Configuration optimized for fast rebuilds during development:
bootstrap.toml
[llvm]
download-ci-llvm = true

[rust]
incremental = true
debug-assertions = true
debuginfo-level = 1

[build]
# Use ccache for faster rebuilds
ccache = true

# Don't build documentation
docs = false
Configuration for building a production release:
./configure \
  --enable-full-tools \
  --enable-profiler \
  --enable-sanitizers \
  --enable-compiler-docs \
  --set rust.debug-assertions=false \
  --set rust.debuginfo-level=0 \
  --set rust.codegen-units=1 \
  --set llvm.thin-lto=true
Building with custom LLVM settings:
bootstrap.toml
[llvm]
# Build LLVM from source
download-ci-llvm = false

# Use Ninja for faster builds
ninja = true

# Enable ThinLTO for LLVM
thin-lto = true

# Link LLVM dynamically
link-shared = true

# Enable specific targets
targets = "X86;ARM;AArch64"

# Optimize LLVM build
optimize = true
release-debuginfo = false

Using Configure and Make

For those familiar with traditional Unix build systems:
./configure --prefix=/usr/local
make && sudo make install
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:
./x.py check

Building Documentation

Build the Rust documentation:
# Build all documentation
./x.py doc

# Build standard library docs
./x.py doc library/std

# Build compiler docs
./x.py doc compiler
Documentation is generated in build/<target>/doc directory.

Troubleshooting

LLVM compilation is memory-intensive. Solutions:
  1. Use pre-built LLVM:
[llvm]
download-ci-llvm = true
  1. Reduce parallel jobs:
./x.py build -j 1
  1. Limit linker jobs:
[llvm]
link-jobs = 1
Speed up builds:
  1. Download LLVM instead of building
  2. Use Ninja instead of Make for LLVM
  3. Enable ccache
  4. Disable documentation builds
  5. Use incremental compilation
bootstrap.toml
[llvm]
download-ci-llvm = true
ninja = true

[build]
ccache = true
docs = false

[rust]
incremental = true
Update git submodules:
git submodule update --init --recursive
Or let bootstrap manage them:
[build]
submodules = true

Next Steps

Configuration Options

Explore all available configuration options

Rustc Dev Guide

Learn about compiler internals and contributing

Build docs developers (and LLMs) love