]> git.proxmox.com Git - rustc.git/blame_incremental - src/doc/rustc-dev-guide/src/building/prerequisites.md
New upstream version 1.65.0+dfsg1
[rustc.git] / src / doc / rustc-dev-guide / src / building / prerequisites.md
... / ...
CommitLineData
1# Prerequisites
2
3## Dependencies
4
5Before building the compiler, you need the following things installed:
6
7* `python` 3 or 2.7 (under the name `python`; `python2` or `python3` will not work)
8* `curl`
9* `git`
10* `ssl` which comes in `libssl-dev` or `openssl-devel`
11* `pkg-config` if you are compiling on Linux and targeting Linux
12
13If building LLVM from source (the default), you'll need additional tools:
14
15* `g++`, `clang++`, or MSVC with versions listed on <!-- date-check: Aug 2022 -->
16 [LLVM's documentation](https://releases.llvm.org/13.0.0/docs/GettingStarted.html#host-c-toolchain-both-compiler-and-standard-library)
17* `ninja`, or GNU `make` 3.81 or later (ninja is recommended, especially on Windows)
18* `cmake` 3.13.4 or later
19
20Otherwise, you'll need LLVM installed and `llvm-config` in your path.
21See [this section for more info][sysllvm].
22
23[sysllvm]: ./new-target.md#using-pre-built-llvm
24
25### Windows
26
27* Install [winget](https://github.com/microsoft/winget-cli)
28
29`winget` is a Windows package manager. It will make package installation easy
30on Windows.
31
32Run the following in a terminal:
33
34```powershell
35winget install -e Python.Python.3
36winget install -e Kitware.CMake
37```
38
39If any of those is installed already, winget will detect it.
40Then edit your systems `PATH` variable and add: `C:\Program Files\CMake\bin`.
41
42For more information about building on Windows,
43see [the `rust-lang/rust` README](https://github.com/rust-lang/rust#building-on-windows).
44
45## Hardware
46
47You will need an internet connection to build. The bootstrapping process
48involves updating git submodules and downloading a beta compiler. It doesn't
49need to be super fast, but that can help.
50
51There are no strict hardware requirements, but building the compiler is
52computationally expensive, so a beefier machine will help, and I wouldn't
53recommend trying to build on a Raspberry Pi! We recommend the following.
54* 30GB+ of free disk space. Otherwise, you will have to keep
55 clearing incremental caches. More space is better, the compiler is a bit of a
56 hog; it's a problem we are aware of.
57* 8GB+ RAM
58* 2+ cores. Having more cores really helps. 10 or 20 or more is not too many!
59
60Beefier machines will lead to much faster builds. If your machine is not very
61powerful, a common strategy is to only use `./x.py check` on your local machine
62and let the CI build test your changes when you push to a PR branch.
63
64Building the compiler takes more than half an hour on my moderately powerful
65laptop. The first time you build the compiler, LLVM will also be built unless
66you use CI-built LLVM ([see here][config]).
67
68Like `cargo`, the build system will use as many cores as possible. Sometimes
69this can cause you to run low on memory. You can use `-j` to adjust the number
70concurrent jobs. If a full build takes more than ~45 minutes to an hour, you
71are probably spending most of the time swapping memory in and out; try using
72`-j1`.
73
74If you don't have too much free disk space, you may want to turn off
75incremental compilation ([see here][config]). This will make compilation take
76longer (especially after a rebase), but will save a ton of space from the
77incremental caches.
78
79[config]: ./how-to-build-and-run.md#create-a-configtoml
80
81## `rustc` and toolchain installation
82
83Follow the installation given in the [Rust book][install] to install a working
84`rustc` and the necessary C/++ toolchain on your platform.
85
86[install]: https://doc.rust-lang.org/book/ch01-01-installation.html