@@ -77,22 +77,24 @@ recommend trying to build on a Raspberry Pi :P
77
77
78
78
Building the compiler takes more than half an hour on my moderately powerful
79
79
laptop. The first time you build the compiler, LLVM will also be built unless
80
- you use your system's LLVM (see below).
80
+ you use your system's LLVM ([ see below] [ configsec ] ).
81
+
82
+ [ configsec ] : #configuring-the-compiler
81
83
82
84
Like ` cargo ` , the build system will use as many cores as possible. Sometimes
83
85
this can cause you to run low on memory. You can use ` -j ` to adjust the number
84
86
concurrent jobs.
85
87
86
88
Also, if you don't have too much free disk space, you may want to turn off
87
- incremental compilation (see the "Configuring" section below). This will make
89
+ incremental compilation ([ see below] [ configsec ] ). This will make
88
90
compilation take longer, but will save a ton of space from the incremental
89
91
caches.
90
92
91
93
### Cloning
92
94
93
95
You can just do a normal git clone:
94
96
95
- ``` shell
97
+ ``` sh
96
98
git clone https://github.com/rust-lang/rust.git
97
99
```
98
100
@@ -107,9 +109,6 @@ git submodule update --init --recursive
107
109
git submodule update
108
110
```
109
111
110
- ** Pro tip** : if you contribute often, you may want to look at the git worktrees
111
- tip in [ this chapter] [ suggested ] .
112
-
113
112
### Configuring the Compiler
114
113
115
114
The compiler has a configuration file which contains a ton of settings. We will
@@ -120,7 +119,7 @@ this chapter for more info][config].
120
119
121
120
In the top level of the repo:
122
121
123
- ``` shell
122
+ ``` sh
124
123
cp config.toml.example config.toml
125
124
```
126
125
@@ -134,13 +133,16 @@ the following settings:
134
133
Also, it can consume a lot of disk space. This has the same effect as the
135
134
` -i ` or ` --incremental ` flags.
136
135
- ` llvm-config ` : enables building with system LLVM. [ See this chapter] [ sysllvm ]
137
- for more info. This avoids building LLVM, which can take a while.
136
+ for more info. This avoids building LLVM, which can take a while (45 minutes
137
+ on my laptop; others have reported 15 minutes or faster with incremental
138
+ compilation).
138
139
139
140
[ sysllvm ] : ./building/suggested.html#building-with-system-llvm
140
141
141
142
### ` ./x.py ` Intro
142
143
143
- ` rustc ` is a _ bootstrapping_ compiler, which means that it is written in Rust and thus needs to be compiled by itself. So where do you
144
+ ` rustc ` is a _ bootstrapping_ compiler, which means that it is written in Rust
145
+ and thus needs to be compiled by itself. So where do you
144
146
get the original compiler from? We use the current beta compiler
145
147
to build a new compiler. Then, we use that compiler to build itself. Thus,
146
148
` rustc ` has a 2-stage build. You can read more about bootstrapping
@@ -179,7 +181,7 @@ To build and test everything:
179
181
180
182
For most contributions, you only need to build stage 1, which saves a lot of time:
181
183
182
- ``` shell
184
+ ``` sh
183
185
# Build the compiler (stage 1)
184
186
./x.py build --stage 1
185
187
@@ -216,7 +218,7 @@ While working on the compiler, it can be helpful to see if the code just
216
218
compiles (similar to ` cargo check ` ) without actually building it. You can do
217
219
this with:
218
220
219
- ``` shell
221
+ ``` sh
220
222
./x.py check
221
223
```
222
224
@@ -226,7 +228,7 @@ completes in a couple of minutes on my laptop.
226
228
Finally, the CI ensures that the codebase is using consistent style. To format
227
229
the code:
228
230
229
- ``` shell
231
+ ``` sh
230
232
# Actually format
231
233
./x.py fmt
232
234
@@ -237,7 +239,9 @@ the code:
237
239
* Note* : we don't use stable ` rustfmt ` ; we use a pinned version with a special
238
240
config, so this may result in different style from normal ` rustfmt ` if you have
239
241
format-on-save turned on. It's a good habit to run ` ./x.py fmt ` before every
240
- commit, as this reduces conflicts later.
242
+ commit, as this reduces conflicts later. The pinned verson is built under
243
+ ` build/<target>/stage0/bin/rustfmt ` , so if you want, you can use it for a
244
+ single file or for format-on-save in your editor, which can be faster than ` ./x.py fmt ` .
241
245
242
246
On last thing: you can use ` RUSTC_LOG=XXX ` to get debug logging. [ Read more
243
247
here] [ logging ] . Notice the ` C ` in ` RUSTC_LOG ` . Other than that, it uses normal
@@ -347,8 +351,10 @@ writing `r? @user` (e.g. `r? @eddyb`) in either the original post or a followup
347
351
comment.
348
352
349
353
The reviewer may request some changes using the GitHub code review interface.
350
- They may also request special procedures (such as a crater run; see below) for
351
- some PRs.
354
+ They may also request special procedures (such as a [ crater] run; [ see
355
+ below] [ break ] ) for some PRs.
356
+
357
+ [ break ] : #breaking-changes
352
358
353
359
When the PR is ready to be merged, the reviewer will issue a command to
354
360
` @bors ` , the CI bot. Usually, this is ` @bors r+ ` or ` @bors r=@user ` to approve
@@ -386,7 +392,7 @@ channels: stable, beta, and nightly.
386
392
387
393
In order to implement a new feature, usually you will need to go through [ the
388
394
RFC process] [ rfc ] to propose a design, have discussions, etc. In some cases,
389
- small features can be added with only an FCP (see below). If in doubt, ask the
395
+ small features can be added with only an FCP ([ see below] [ break ] ). If in doubt, ask the
390
396
compiler, language, or libs team (whichever is most relevant).
391
397
392
398
[ rfc ] : https://github.com/rust-lang/rfcs/blob/master/README.md
@@ -399,7 +405,8 @@ The feature then needs to be implemented behind a feature gate, which prevents
399
405
it from being accidentally used.
400
406
401
407
Finally, somebody may propose stabilizing the feature in an upcoming version of
402
- Rust. This requires a Final Comment Period (see below) to get the approval of the relevant teams.
408
+ Rust. This requires a Final Comment Period ([ see below] [ break ] ) to get the
409
+ approval of the relevant teams.
403
410
404
411
After that, the feature gate can be removed and the feature turned on for all users.
405
412
0 commit comments