@@ -47,6 +47,14 @@ debuginfo-lines = true
47
47
use-jemalloc = false
48
48
```
49
49
50
+ ### what is x.py?
51
+
52
+ x.py is the script used to orchestrate the tooling in the rustc repository.
53
+ It is the script that can build docs, run tests, and compile rustc.
54
+ It is the now preferred way to build rustc and it replaces the old makefiles
55
+ from before. Below are the different ways to utilize x.py in order to
56
+ effectively deal with the repo for various common tasks.
57
+
50
58
### Running x.py and building a stage1 compiler
51
59
52
60
One thing to keep in mind is that ` rustc ` is a _ bootstrapping_
@@ -80,6 +88,52 @@ compiling `rustc` is done in stages:
80
88
can build the libraries with the stage2 compiler. The result ought
81
89
to be identical to before, unless something has broken.
82
90
91
+
92
+ #### Build Flags
93
+
94
+ There are other flags you can pass to the build portion of x.py that can be
95
+ beneficial to cutting down compile times or fitting other things you might
96
+ need to change. They are:
97
+
98
+ ```
99
+ Options:
100
+ -v, --verbose use verbose output (-vv for very verbose)
101
+ -i, --incremental use incremental compilation
102
+ --config FILE TOML configuration file for build
103
+ --build BUILD build target of the stage0 compiler
104
+ --host HOST host targets to build
105
+ --target TARGET target targets to build
106
+ --on-fail CMD command to run on failure
107
+ --stage N stage to build
108
+ --keep-stage N stage to keep without recompiling
109
+ --src DIR path to the root of the rust checkout
110
+ -j, --jobs JOBS number of jobs to run in parallel
111
+ -h, --help print this help message
112
+ ```
113
+
114
+ One thing to keep in mind is that ` rustc ` is a _ bootstrapping_ compiler. That
115
+ is, since ` rustc ` is written in Rust, we need to use an older version of the
116
+ compiler to compile the newer version. In particular, the newer version of the
117
+ compiler, ` libstd ` , and other tooling may use some unstable features
118
+ internally. The result is the compiling ` rustc ` is done in stages.
119
+
120
+ - ** Stage 0:** the stage0 compiler can be your existing
121
+ (perhaps older version of)
122
+ Rust compiler, the current _ beta_ compiler or you may download the binary
123
+ from the internet.
124
+ - ** Stage 1:** the code in your clone (for new version)
125
+ is then compiled with the stage0
126
+ compiler to produce the stage1 compiler.
127
+ However, it was built with an older compiler (stage0),
128
+ so to optimize the stage1 compiler we go to next stage.
129
+ - ** Stage 2:** we rebuild our stage1 compiler with itself
130
+ to produce the stage2 compiler (i.e. it builds
131
+ itself) to have all the _ latest optimizations_ .
132
+ - _ (Optional)_ ** Stage 3** : to sanity check of our new compiler,
133
+ we can build it again
134
+ with stage2 compiler which must be identical to itself,
135
+ unless something has broken.
136
+
83
137
For hacking, often building the stage 1 compiler is enough, but for
84
138
final testing and release, the stage 2 compiler is used.
85
139
@@ -183,8 +237,8 @@ you will likely need to build at some point; for example, if you want
183
237
to run the entire test suite).
184
238
185
239
``` bash
186
- rustup toolchain link stage1 build/< host-triple> /stage1
187
- rustup toolchain link stage2 build/< host-triple> /stage2
240
+ > rustup toolchain link stage1 build/< host-triple> /stage1
241
+ > rustup toolchain link stage2 build/< host-triple> /stage2
188
242
```
189
243
190
244
The ` <host-triple> ` would typically be one of the following:
@@ -309,4 +363,4 @@ If you need to run this then rustbuild is most likely not acting right and
309
363
you should file a bug as to what is going wrong. If you do need to clean
310
364
everything up then you only need to run one command!
311
365
312
- ` ./x.py clean `
366
+ ` ./x.py clean `
0 commit comments