Before building the compiler, you need the following things installed:
python3 or 2.7 (under the name
python3will not work)
sslwhich comes in
pkg-configif you are compiling on Linux and targeting Linux
libstdc++-staticmay be required on some Linux distributions such as Fedora and Ubuntu
If building LLVM from source (the default), you'll need additional tools:
clang++, or MSVC with versions listed on LLVM's documentation
ninja, or GNU
make3.81 or later (ninja is recommended, especially on Windows)
cmake3.13.4 or later
Otherwise, you'll need LLVM installed and
llvm-config in your path.
See this section for more info.
- Install winget
winget is a Windows package manager. It will make package installation easy
Run the following in a terminal:
winget install -e Python.Python.3 winget install -e Kitware.CMake
If any of those is installed already, winget will detect it. Then edit your system's
C:\Program Files\CMake\bin. See
this guide on editing the system
PATH from the
For more information about building on Windows,
You will need an internet connection to build. The bootstrapping process involves updating git submodules and downloading a beta compiler. It doesn't need to be super fast, but that can help.
There are no strict hardware requirements, but building the compiler is computationally expensive, so a beefier machine will help, and I wouldn't recommend trying to build on a Raspberry Pi! We recommend the following.
- 30GB+ of free disk space. Otherwise, you will have to keep clearing incremental caches. More space is better, the compiler is a bit of a hog; it's a problem we are aware of.
- 8GB+ RAM
- 2+ cores. Having more cores really helps. 10 or 20 or more is not too many!
Beefier machines will lead to much faster builds. If your machine is not very
powerful, a common strategy is to only use
./x.py check on your local machine
and let the CI build test your changes when you push to a PR branch.
Building the compiler takes more than half an hour on my moderately powerful laptop. The first time you build the compiler, LLVM will also be built unless you use CI-built LLVM (see here).
cargo, the build system will use as many cores as possible. Sometimes
this can cause you to run low on memory. You can use
-j to adjust the number
concurrent jobs. If a full build takes more than ~45 minutes to an hour, you
are probably spending most of the time swapping memory in and out; try using
If you don't have too much free disk space, you may want to turn off incremental compilation (see here). This will make compilation take longer (especially after a rebase), but will save a ton of space from the incremental caches.
Follow the installation given in the Rust book to install a working
rustc and the necessary C/++ toolchain on your platform.