@@ -108,6 +108,29 @@ of a checkout. It also looks up the appropriate version of `python` to use.
108
108
109
109
You can install it with ` cargo install --path src/tools/x ` .
110
110
111
+ Using ` x ` rather than ` x.py ` is recommended as:
112
+
113
+ > ` ./x ` is the most likely to work on every system (on Unix it runs the shell script
114
+ > that does python version detection, on Windows it will probably run the
115
+ > powershell script - certainly less likely to break than ` ./x.py ` which often just
116
+ > opens the file in an editor).[ ^ 1 ]
117
+
118
+ Notice that this is not absolute, for instance, using Nushell in VSCode on Win10,
119
+ typing ` x ` or ` ./x ` still open the ` x.py ` in editor rather invoke the program :)
120
+
121
+ In the rest of documents, we use ` x ` to represent the straightly usage of ` x.py ` , which
122
+ means the following command:
123
+
124
+ ``` bash
125
+ ./x check
126
+ ```
127
+
128
+ could been replaced by:
129
+
130
+ ``` bash
131
+ ./x.py check
132
+ ```
133
+
111
134
## Create a ` config.toml `
112
135
113
136
To start, run ` ./x setup ` and select the ` compiler ` defaults. This will do some initialization
@@ -123,9 +146,9 @@ If you have already built `rustc` and you change settings related to LLVM, then
123
146
execute ` rm -rf build ` for subsequent configuration changes to take effect. Note that `./x
124
147
clean` will not cause a rebuild of LLVM.
125
148
126
- ## Common ` x.py ` commands
149
+ ## Common ` x ` commands
127
150
128
- Here are the basic invocations of the ` x.py ` commands most commonly used when
151
+ Here are the basic invocations of the ` x ` commands most commonly used when
129
152
working on ` rustc ` , ` std ` , ` rustdoc ` , and other tools.
130
153
131
154
| Command | When to use it |
@@ -141,9 +164,9 @@ serious development work. In particular, `./x build` and `./x test`
141
164
provide many ways to compile or test a subset of the code, which can save a lot
142
165
of time.
143
166
144
- Also, note that ` x.py ` supports all kinds of path suffixes for ` compiler ` , ` library ` ,
145
- and ` src/tools ` directories. So, you can simply run ` x.py test tidy ` instead of
146
- ` x.py test src/tools/tidy ` . Or, ` x.py build std ` instead of ` x.py build library/std ` .
167
+ Also, note that ` x ` supports all kinds of path suffixes for ` compiler ` , ` library ` ,
168
+ and ` src/tools ` directories. So, you can simply run ` x test tidy ` instead of
169
+ ` x test src/tools/tidy ` . Or, ` x build std ` instead of ` x build library/std ` .
147
170
148
171
[ rust-analyzer ] : suggested.html#configuring-rust-analyzer-for-rustc
149
172
@@ -156,7 +179,7 @@ Note that building will require a relatively large amount of storage space.
156
179
You may want to have upwards of 10 or 15 gigabytes available to build the compiler.
157
180
158
181
Once you've created a ` config.toml ` , you are now ready to run
159
- ` x.py ` . There are a lot of options here, but let's start with what is
182
+ ` x ` . There are a lot of options here, but let's start with what is
160
183
probably the best "go to" command for building a local compiler:
161
184
162
185
``` bash
@@ -206,7 +229,7 @@ Instead, you can just build using the bootstrap compiler.
206
229
./x build --stage 0 library
207
230
```
208
231
209
- If you choose the ` library ` profile when running ` x.py setup ` , you can omit ` --stage 0 ` (it's the
232
+ If you choose the ` library ` profile when running ` x setup ` , you can omit ` --stage 0 ` (it's the
210
233
default).
211
234
212
235
## Creating a rustup toolchain
@@ -241,7 +264,7 @@ LLVM version: 11.0
241
264
```
242
265
243
266
The rustup toolchain points to the specified toolchain compiled in your ` build ` directory,
244
- so the rustup toolchain will be updated whenever ` x.py build ` or ` x.py test ` are run for
267
+ so the rustup toolchain will be updated whenever ` x build ` or ` x test ` are run for
245
268
that toolchain/stage.
246
269
247
270
** Note:** the toolchain we've built does not include ` cargo ` . In this case, ` rustup ` will
@@ -262,7 +285,7 @@ want to build this component:
262
285
## Building targets for cross-compilation
263
286
264
287
To produce a compiler that can cross-compile for other targets,
265
- pass any number of ` target ` flags to ` x.py build ` .
288
+ pass any number of ` target ` flags to ` x build ` .
266
289
For example, if your host platform is ` x86_64-unknown-linux-gnu `
267
290
and your cross-compilation target is ` wasm32-wasi ` , you can build with:
268
291
@@ -274,7 +297,7 @@ Note that if you want the resulting compiler to be able to build crates that
274
297
involve proc macros or build scripts, you must be sure to explicitly build target support for the
275
298
host platform (in this case, ` x86_64-unknown-linux-gnu ` ).
276
299
277
- If you want to always build for other targets without needing to pass flags to ` x.py build ` ,
300
+ If you want to always build for other targets without needing to pass flags to ` x build ` ,
278
301
you can configure this in the ` [build] ` section of your ` config.toml ` like so:
279
302
280
303
``` toml
@@ -303,9 +326,9 @@ then once you have built your compiler you will be able to use it to cross-compi
303
326
cargo +stage1 build --target wasm32-wasi
304
327
```
305
328
306
- ## Other ` x.py ` commands
329
+ ## Other ` x ` commands
307
330
308
- Here are a few other useful ` x.py ` commands. We'll cover some of them in detail
331
+ Here are a few other useful ` x ` commands. We'll cover some of them in detail
309
332
in other sections:
310
333
311
334
- Building things:
@@ -335,3 +358,5 @@ everything up then you only need to run one command!
335
358
336
359
` rm -rf build ` works too, but then you have to rebuild LLVM, which can take
337
360
a long time even on fast computers.
361
+
362
+ [ ^ 1 ] : issue[ #1707 ] ( https://github.com/rust-lang/rustc-dev-guide/issues/1707 )
0 commit comments