@@ -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
+ ``` bash
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
@@ -134,37 +188,25 @@ build`) has quite a few more steps:
134
188
135
189
<a name =toolchain ></a >
136
190
137
- ### Build different stages
138
-
139
- ` ./x.py build --stage 0 `
140
-
141
- # Stage 1 is typically enough to test out all of your changes
142
- # to the compiler
143
-
144
- ` ./x.py build --stage 1 `
145
-
146
- # Equivalent to ./x.py build
147
-
148
- ` ./x.py build --stage 2 `
149
-
150
- You can pass the --stage flag with what stage you want to build to.
151
- It is recommended that you build to Stage 1 as this is enough to know
152
- your changes can successfully compile and should let you run tests
153
- with your changes.
154
-
155
191
### Build specific components
156
192
157
193
Build only the libcore library
158
194
159
- ` ./x.py build src/libcore `
195
+ ``` bash
196
+ > ./x.py build src/libcore
197
+ ```
160
198
161
199
Build the libcore and libproc_macro library only
162
200
163
- ` ./x.py build src/libcore src/libproc_macro `
201
+ ``` bash
202
+ > ./x.py build src/libcore src/libproc_macro
203
+ ```
164
204
165
205
Build only libcore up to Stage 1
166
206
167
- ` ./x.py build src/libcore --stage 1 `
207
+ ``` bash
208
+ > ./x.py build src/libcore --stage 1
209
+ ```
168
210
169
211
Sometimes you might just want to test if the part you’re working on can
170
212
compile. Using these commands you can test that it compiles before doing
@@ -183,8 +225,8 @@ you will likely need to build at some point; for example, if you want
183
225
to run the entire test suite).
184
226
185
227
``` bash
186
- rustup toolchain link stage1 build/< host-triple> /stage1
187
- rustup toolchain link stage2 build/< host-triple> /stage2
228
+ > rustup toolchain link stage1 build/< host-triple> /stage1
229
+ > rustup toolchain link stage2 build/< host-triple> /stage2
188
230
```
189
231
190
232
The ` <host-triple> ` would typically be one of the following:
@@ -309,4 +351,6 @@ If you need to run this then rustbuild is most likely not acting right and
309
351
you should file a bug as to what is going wrong. If you do need to clean
310
352
everything up then you only need to run one command!
311
353
312
- ` ./x.py clean `
354
+ ``` bash
355
+ > ./x.py clean
356
+ ```
0 commit comments