@@ -44,149 +44,57 @@ just create noise, so we ask that you be mindful of the fact that the
4444
4545## Cloning and Building
4646
47- The main repository is [ ` rust-lang/rust ` ] [ repo ] . This contains the compiler,
48- the standard library (including ` core ` , ` alloc ` , ` test ` , ` proc_macro ` , etc),
49- and a bunch of tools (e.g. ` rustdoc ` , the bootstrapping infrastructure, etc).
50-
51- [ repo ] : https://github.com/rust-lang/rust
52-
53- There are also a bunch of submodules for things like LLVM, ` clippy ` , ` miri ` ,
54- etc. You don't need to clone these immediately, but the build tool will
55- automatically clone and sync them (more on this later).
56-
57- [ ** Take a look at the "Suggested Workflows" chapter for some helpful
58- advice.** ] [ suggested ]
59-
60- [ suggested ] : ./building/suggested.md
61-
6247### System Requirements
6348
64- [ ** See this chapter for detailed software requirements.** ] ( ./building/prerequisites.md )
65- Most notably, you will need Python 2 or 3 to run ` x.py ` .
66-
67- There are no hard hardware requirements, but building the compiler is
68- computationally expensive, so a beefier machine will help, and I wouldn't
69- recommend trying to build on a Raspberry Pi : P
49+ Internet access is required.
7050
71- - Recommended >=30GB of free disk space; otherwise, you will have to keep
72- clearing incremental caches. More space is better, the compiler is a bit of a
73- hog; it's a problem we are aware of.
74- - Recommended >=8GB RAM.
75- - Recommended >=2 cores; having more cores really helps.
76- - You will need an internet connection to build; the bootstrapping process
77- involves updating git submodules and downloading a beta compiler. It doesn't
78- need to be super fast, but that can help.
51+ The most notable software requirement is that you will need Python 2 or 3, but
52+ there are various others.
7953
80- Building the compiler takes more than half an hour on my moderately powerful
81- laptop. The first time you build the compiler, LLVM will also be built unless
82- you use CI-built LLVM ([ see below] [ configsec ] ).
54+ The following hardware is recommended.
55+ * 30GB+ of free disk space.
56+ * 8GB+ RAM
57+ * 2+ cores
8358
84- [ configsec ] : #configuring-the-compiler
59+ More powerful machines will lead to much faster builds. There are various
60+ strategies to work around lesser hardware in the following chapters.
8561
86- Like ` cargo ` , the build system will use as many cores as possible. Sometimes
87- this can cause you to run low on memory. You can use ` -j ` to adjust the number
88- concurrent jobs. If a full build takes more than ~ 45 minutes to an hour,
89- you are probably spending most of the time swapping memory in and out;
90- try using ` -j1 ` .
62+ See [ this chapter] [ prereqs ] for more details about software and hardware prerequisites.
9163
92- On a slow machine, the build times for rustc are very painful. Consider using
93- ` ./x.py check ` instead of a full build and letting the automated tests run
94- when you push to GitHub.
95-
96- If you don't have too much free disk space, you may want to turn off
97- incremental compilation ([ see below] [ configsec ] ). This will make
98- compilation take longer (especially after a rebase),
99- but will save a ton of space from the incremental caches.
64+ [ prereqs ] : ./building/prerequisites.md
10065
10166### Cloning
10267
10368You can just do a normal git clone:
10469
10570``` sh
10671git clone https://github.com/rust-lang/rust.git
72+ cd rust
10773```
10874
109- You don't need to clone the submodules at this time. But if you want to, you
110- can do the following:
75+ ### ` x.py ` Intro
11176
112- ``` sh
113- # first time
114- git submodule update --init --recursive
77+ ` rustc ` is a [ bootstrapping] compiler, which makes it more complex than a
78+ typical Rust program. As a result, you cannot use Cargo to build it. Instead
79+ you must use the special tool ` x.py ` . It is used for the things Cargo is
80+ normally used for: building, testing, creating releases, formatting, etc.
11581
116- # subsequent times (to pull new commits)
117- git submodule update
118- ```
82+ [ bootstrapping ] : ./building/bootstrapping.md
11983
12084### Configuring the Compiler
12185
122- The compiler has a configuration file which contains a ton of settings. We will
123- provide some recommendations here that should work for most, but [ check out
124- this chapter for more info] [ config ] .
125-
126- [ config ] : ./building/how-to-build-and-run.md#create-a-configtoml
127-
12886In the top level of the repo:
12987
13088``` sh
13189$ ./x.py setup
13290```
13391
134- This will walk you through an interactive setup for ` x.py ` that looks like this:
135-
136- ```
137- $ ./x.py setup
138- Welcome to the Rust project! What do you want to do with x.py?
139- a) Contribute to the standard library
140- b) Contribute to the compiler
141- c) Contribute to the compiler, and also modify LLVM or codegen
142- d) Install Rust from source
143- Please choose one (a/b/c/d): a
144- `x.py` will now use the configuration at /home/joshua/rustc2/src/bootstrap/defaults/config.toml.library
145- To get started, try one of the following commands:
146- - `x.py check`
147- - `x.py build`
148- - `x.py test library/std`
149- - `x.py doc`
150- For more suggestions, see https://rustc-dev-guide.rust-lang.org/building/suggested.html
151- ```
152-
153- Note that by default, ` ./x.py setup ` will use CI-built LLVM if available for your
154- platform so that you don't need to build LLVM in addition to building the
155- compiler. In some circumstances, such as when updating the version of LLVM used
156- by ` rustc ` , you may want to temporarily disable this feature. See the [ "Updating
157- LLVM" section] for more.
92+ This will do some initialization and walk you through an interactive setup to
93+ create ` config.toml ` , the primary configuration file.
15894
159- If you want to download LLVM from CI without running ` ./x.py setup ` , you can set
160- the ` download-ci-llvm ` option to ` true ` in your ` config.toml ` :
95+ See [ this chapter] [ config ] for more info about configuration.
16196
162- ``` toml
163- [llvm ]
164- download-ci-llvm = true
165- ```
166-
167- [ "Updating LLVM" section ] : https://rustc-dev-guide.rust-lang.org/backend/updating-llvm.html?highlight=download-ci-llvm#feature-updates
168-
169- ### ` x.py ` Intro
170-
171- ` rustc ` is a _ bootstrapping_ compiler, which means that it is written in Rust
172- and thus needs to be compiled by itself. So where do you
173- get the original compiler from? We use the current beta compiler
174- to build a new compiler. Then, we use that compiler to build itself. Thus,
175- ` rustc ` has a 2-stage build. You can read more about bootstrapping
176- [ here] [ boot ] , but you don't need to know much more to contribute.
177-
178- [ boot ] : ./building/bootstrapping.md
179-
180- We have a special tool ` x.py ` that drives this process. It is used for
181- building the compiler, the standard libraries, and ` rustdoc ` . It is also used
182- for driving CI and building the final release artifacts.
183-
184- Unfortunately, a proper 2-stage build takes a long time depending on your
185- hardware, but it is the only correct way to build everything (e.g. it's what
186- the CI and release processes use). ** However, in most cases, you can get by
187- without a full 2-stage build** . In the following section, we give instructions
188- for how to do "the correct thing", but then we also give various tips to speed
189- things up.
97+ [ config ] : ./building/how-to-build-and-run.md#create-a-configtoml
19098
19199### Building and Testing ` rustc `
192100
0 commit comments