1
1
# rustbuild - Bootstrapping Rust
2
2
3
3
This is an in-progress README which is targeted at helping to explain how Rust
4
- is bootstrapped and in general some of the technical details of the build
4
+ is bootstrapped and in general, some of the technical details of the build
5
5
system.
6
6
7
7
## Using rustbuild
@@ -12,16 +12,16 @@ The rustbuild build system has a primary entry point, a top level `x.py` script:
12
12
$ python ./x.py build
13
13
```
14
14
15
- Note that if you're on Unix you should be able to execute the script directly:
15
+ Note that if you're on Unix, you should be able to execute the script directly:
16
16
17
17
``` sh
18
18
$ ./x.py build
19
19
```
20
20
21
21
The script accepts commands, flags, and arguments to determine what to do:
22
22
23
- * ` build ` - a general purpose command for compiling code. Alone ` build ` will
24
- bootstrap the entire compiler, and otherwise arguments passed indicate what to
23
+ * ` build ` - a general purpose command for compiling code. Alone, ` build ` will
24
+ bootstrap the entire compiler, and otherwise, arguments passed indicate what to
25
25
build. For example:
26
26
27
27
```
@@ -38,7 +38,7 @@ The script accepts commands, flags, and arguments to determine what to do:
38
38
./x.py build --stage 0 library/test
39
39
```
40
40
41
- If files are dirty that would normally be rebuilt from stage 0, that can be
41
+ If files that would normally be rebuilt from stage 0 are dirty, the rebuild can be
42
42
overridden using ` --keep-stage 0 ` . Using ` --keep-stage n ` will skip all steps
43
43
that belong to stage n or earlier:
44
44
@@ -47,8 +47,8 @@ The script accepts commands, flags, and arguments to determine what to do:
47
47
./x.py build --keep-stage 0
48
48
```
49
49
50
- * ` test ` - a command for executing unit tests. Like the ` build ` command this
51
- will execute the entire test suite by default, and otherwise it can be used to
50
+ * ` test ` - a command for executing unit tests. Like the ` build ` command, this
51
+ will execute the entire test suite by default, and otherwise, it can be used to
52
52
select which test suite is run:
53
53
54
54
```
@@ -75,7 +75,7 @@ The script accepts commands, flags, and arguments to determine what to do:
75
75
./x.py test src/doc
76
76
```
77
77
78
- * ` doc ` - a command for building documentation. Like above can take arguments
78
+ * ` doc ` - a command for building documentation. Like above, can take arguments
79
79
for what to document.
80
80
81
81
## Configuring rustbuild
@@ -110,12 +110,12 @@ compiler. What actually happens when you invoke rustbuild is:
110
110
compiles the build system itself (this folder). Finally, it then invokes the
111
111
actual ` bootstrap ` binary build system.
112
112
2 . In Rust, ` bootstrap ` will slurp up all configuration, perform a number of
113
- sanity checks (compilers exist for example), and then start building the
113
+ sanity checks (whether compilers exist, for example), and then start building the
114
114
stage0 artifacts.
115
- 3 . The stage0 ` cargo ` downloaded earlier is used to build the standard library
115
+ 3 . The stage0 ` cargo ` , downloaded earlier, is used to build the standard library
116
116
and the compiler, and then these binaries are then copied to the ` stage1 `
117
117
directory. That compiler is then used to generate the stage1 artifacts which
118
- are then copied to the stage2 directory, and then finally the stage2
118
+ are then copied to the stage2 directory, and then finally, the stage2
119
119
artifacts are generated using that compiler.
120
120
121
121
The goal of each stage is to (a) leverage Cargo as much as possible and failing
@@ -149,7 +149,7 @@ like this:
149
149
build/
150
150
151
151
# Location where the stage0 compiler downloads are all cached. This directory
152
- # only contains the tarballs themselves as they're extracted elsewhere.
152
+ # only contains the tarballs themselves, as they're extracted elsewhere.
153
153
cache/
154
154
2015-12-19/
155
155
2016-01-15/
@@ -172,22 +172,22 @@ build/
172
172
# hand.
173
173
x86_64-unknown-linux-gnu/
174
174
175
- # The build artifacts for the `compiler-rt` library for the target this
176
- # folder is under. The exact layout here will likely depend on the platform,
177
- # and this is also built with CMake so the build system is also likely
178
- # different.
175
+ # The build artifacts for the `compiler-rt` library for the target that
176
+ # this folder is under. The exact layout here will likely depend on the
177
+ # platform, and this is also built with CMake, so the build system is
178
+ # also likely different.
179
179
compiler-rt/
180
180
build/
181
181
182
182
# Output folder for LLVM if it is compiled for this target
183
183
llvm/
184
184
185
185
# build folder (e.g. the platform-specific build system). Like with
186
- # compiler-rt this is compiled with CMake
186
+ # compiler-rt, this is compiled with CMake
187
187
build/
188
188
189
189
# Installation of LLVM. Note that we run the equivalent of 'make install'
190
- # for LLVM to setup these folders.
190
+ # for LLVM, to setup these folders.
191
191
bin/
192
192
lib/
193
193
include/
@@ -206,18 +206,18 @@ build/
206
206
207
207
# Location where the stage0 Cargo and Rust compiler are unpacked. This
208
208
# directory is purely an extracted and overlaid tarball of these two (done
209
- # by the bootstrapy python script). In theory the build system does not
209
+ # by the bootstrap python script). In theory, the build system does not
210
210
# modify anything under this directory afterwards.
211
211
stage0/
212
212
213
- # These to build directories are the cargo output directories for builds of
214
- # the standard library and compiler, respectively. Internally these may also
213
+ # These to- build directories are the cargo output directories for builds of
214
+ # the standard library and compiler, respectively. Internally, these may also
215
215
# have other target directories, which represent artifacts being compiled
216
216
# from the host to the specified target.
217
217
#
218
218
# Essentially, each of these directories is filled in by one `cargo`
219
219
# invocation. The build system instruments calling Cargo in the right order
220
- # with the right variables to ensure these are filled in correctly.
220
+ # with the right variables to ensure that these are filled in correctly.
221
221
stageN-std/
222
222
stageN-test/
223
223
stageN-rustc/
@@ -232,8 +232,8 @@ build/
232
232
# being compiled (e.g. after libstd has been built), *this* is used as the
233
233
# sysroot for the stage0 compiler being run.
234
234
#
235
- # Basically this directory is just a temporary artifact use to configure the
236
- # stage0 compiler to ensure that the libstd we just built is used to
235
+ # Basically, this directory is just a temporary artifact used to configure the
236
+ # stage0 compiler to ensure that the libstd that we just built is used to
237
237
# compile the stage1 compiler.
238
238
stage0-sysroot/lib/
239
239
@@ -242,7 +242,7 @@ build/
242
242
# system will link (using hard links) output from stageN-{std,rustc} into
243
243
# each of these directories.
244
244
#
245
- # In theory there is no extra build output in these directories.
245
+ # In theory, there is no extra build output in these directories.
246
246
stage1/
247
247
stage2/
248
248
stage3/
@@ -265,14 +265,14 @@ structure here serves two goals:
265
265
depend on ` std ` , so libstd is a separate project compiled ahead of time
266
266
before the actual compiler builds.
267
267
2 . Splitting "host artifacts" from "target artifacts". That is, when building
268
- code for an arbitrary target you don't need the entire compiler, but you'll
268
+ code for an arbitrary target, you don't need the entire compiler, but you'll
269
269
end up needing libraries like libtest that depend on std but also want to use
270
270
crates.io dependencies. Hence, libtest is split out as its own project that
271
271
is sequenced after ` std ` but before ` rustc ` . This project is built for all
272
272
targets.
273
273
274
274
There is some loss in build parallelism here because libtest can be compiled in
275
- parallel with a number of rustc artifacts, but in theory the loss isn't too bad!
275
+ parallel with a number of rustc artifacts, but in theory, the loss isn't too bad!
276
276
277
277
## Build tools
278
278
@@ -285,13 +285,13 @@ appropriate libstd/libtest/librustc compile above.
285
285
286
286
## Extending rustbuild
287
287
288
- So you'd like to add a feature to the rustbuild build system or just fix a bug.
288
+ So, you'd like to add a feature to the rustbuild build system or just fix a bug.
289
289
Great! One of the major motivational factors for moving away from ` make ` is that
290
290
Rust is in theory much easier to read, modify, and write. If you find anything
291
- excessively confusing, please open an issue on this and we'll try to get it
292
- documented or simplified pronto.
291
+ excessively confusing, please open an issue on this, and we'll try to get it
292
+ documented or simplified, pronto.
293
293
294
- First up, you'll probably want to read over the documentation above as that'll
294
+ First up, you'll probably want to read over the documentation above, as that'll
295
295
give you a high level overview of what rustbuild is doing. You also probably
296
296
want to play around a bit yourself by just getting it up and running before you
297
297
dive too much into the actual build system itself.
@@ -326,7 +326,7 @@ A 'major change' includes
326
326
Changes that do not affect contributors to the compiler or users
327
327
building rustc from source don't need an update to ` VERSION ` .
328
328
329
- If you have any questions feel free to reach out on the ` #t-infra ` channel in
329
+ If you have any questions, feel free to reach out on the ` #t-infra ` channel in
330
330
the [ Rust Zulip server] [ rust-zulip ] or ask on internals.rust-lang.org. When
331
331
you encounter bugs, please file issues on the rust-lang/rust issue tracker.
332
332
0 commit comments