@@ -47,6 +47,14 @@ debuginfo-lines = true
4747use-jemalloc = false
4848```
4949
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+
5058### Running x.py and building a stage1 compiler
5159
5260One thing to keep in mind is that ` rustc ` is a _ bootstrapping_
@@ -80,6 +88,52 @@ compiling `rustc` is done in stages:
8088 can build the libraries with the stage2 compiler. The result ought
8189 to be identical to before, unless something has broken.
8290
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+
83137For hacking, often building the stage 1 compiler is enough, but for
84138final testing and release, the stage 2 compiler is used.
85139
@@ -134,37 +188,25 @@ build`) has quite a few more steps:
134188
135189<a name =toolchain ></a >
136190
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-
155191### Build specific components
156192
157193 Build only the libcore library
158194
159- ` ./x.py build src/libcore `
195+ ``` bash
196+ > ./x.py build src/libcore
197+ ```
160198
161199 Build the libcore and libproc_macro library only
162200
163- ` ./x.py build src/libcore src/libproc_macro `
201+ ``` bash
202+ > ./x.py build src/libcore src/libproc_macro
203+ ```
164204
165205 Build only libcore up to Stage 1
166206
167- ` ./x.py build src/libcore --stage 1 `
207+ ``` bash
208+ > ./x.py build src/libcore --stage 1
209+ ```
168210
169211Sometimes you might just want to test if the part you’re working on can
170212compile. 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
183225to run the entire test suite).
184226
185227``` 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
188230```
189231
190232The ` <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
309351you should file a bug as to what is going wrong. If you do need to clean
310352everything up then you only need to run one command!
311353
312- ` ./x.py clean `
354+ ``` bash
355+ > ./x.py clean
356+ ```
0 commit comments