@@ -86,13 +86,17 @@ benchmarks, generate documentation, install a fresh build of Rust, and more.
86
86
It's your best friend when working on Rust, allowing you to compile & test
87
87
your contributions before submission.
88
88
89
- All the configuration for the build system lives in [ the ` mk ` directory] [ mkdir ]
90
- in the project root. It can be hard to follow in places, as it uses some
91
- advanced Make features which make for some challenging reading. If you have
92
- questions on the build system internals, try asking in
93
- [ ` #rust-internals ` ] [ pound-rust-internals ] .
89
+ The build system lives in [ the ` src/bootstrap ` directory] [ bootstrap ] in the
90
+ project root. Our build system is itself written in Rust and is based on Cargo
91
+ to actually build all the compiler's crates. If you have questions on the build
92
+ system internals, try asking in [ ` #rust-internals ` ] [ pound-rust-internals ] .
94
93
95
- [ mkdir ] : https://github.com/rust-lang/rust/tree/master/mk/
94
+ [ bootstrap ] : https://github.com/rust-lang/rust/tree/master/src/bootstrap/
95
+
96
+ > ** Note** : the build system was recently rewritten from a jungle of makefiles
97
+ > to the current incarnation you'll see in ` src/bootstrap ` . If you experience
98
+ > bugs you can temporarily revert back to the makefiles with
99
+ > ` --disable-rustbuild ` passed to ` ./configure ` .
96
100
97
101
### Configuration
98
102
@@ -119,42 +123,111 @@ configuration used later in the build process. Some options to note:
119
123
120
124
To see a full list of options, run ` ./configure --help ` .
121
125
122
- ### Useful Targets
123
-
124
- Some common make targets are:
125
-
126
- - ` make tips ` - show useful targets, variables and other tips for working with
127
- the build system.
128
- - ` make rustc-stage1 ` - build up to (and including) the first stage. For most
129
- cases we don't need to build the stage2 compiler, so we can save time by not
130
- building it. The stage1 compiler is a fully functioning compiler and
131
- (probably) will be enough to determine if your change works as expected.
132
- - ` make $host/stage1/bin/rustc ` - Where $host is a target triple like x86_64-unknown-linux-gnu.
133
- This will build just rustc, without libstd. This is the fastest way to recompile after
134
- you changed only rustc source code. Note however that the resulting rustc binary
135
- won't have a stdlib to link against by default. You can build libstd once with
136
- ` make rustc-stage1 ` , rustc will pick it up afterwards. libstd is only guaranteed to
137
- work if recompiled, so if there are any issues recompile it.
138
- - ` make check ` - build the full compiler & run all tests (takes a while). This
126
+ ### Building
127
+
128
+ Although the ` ./configure ` script will generate a ` Makefile ` , this is actually
129
+ just a thin veneer over the actual build system driver, ` x.py ` . This file, at
130
+ the root of the repository, is used to build, test, and document various parts
131
+ of the compiler. You can execute it as:
132
+
133
+ ``` sh
134
+ python x.py build
135
+ ```
136
+
137
+ On some systems you can also use the shorter version:
138
+
139
+ ``` sh
140
+ ./x.py build
141
+ ```
142
+
143
+ To learn more about the driver and top-level targets, you can execute:
144
+
145
+ ``` sh
146
+ python x.py --help
147
+ ```
148
+
149
+ The general format for the driver script is:
150
+
151
+ ``` sh
152
+ python x.py < command> [< directory> ]
153
+ ```
154
+
155
+ Some example commands are ` build ` , ` test ` , and ` doc ` . These will build, test,
156
+ and document the specified directory. The second argument, ` <directory> ` , is
157
+ optional and defaults to working over the entire compiler. If specified,
158
+ however, only that specific directory will be built. For example:
159
+
160
+ ``` sh
161
+ # build the entire compiler
162
+ python x.py build
163
+
164
+ # build all documentation
165
+ python x.py doc
166
+
167
+ # run all test suites
168
+ python x.py test
169
+
170
+ # build only the standard library
171
+ python x.py build src/libstd
172
+
173
+ # test only one particular test suite
174
+ python x.py test src/test/rustdoc
175
+
176
+ # build only the stage0 libcore library
177
+ python x.py build src/libcore --stage 0
178
+ ```
179
+
180
+ You can explore the build system throught the various ` --help ` pages for each
181
+ subcommand. For example to learn more about a command you can run:
182
+
183
+ ```
184
+ python x.py build --help
185
+ ```
186
+
187
+ To learn about all possible rules you can execute, run:
188
+
189
+ ```
190
+ python x.py build --help --verbose
191
+ ```
192
+
193
+ ### Useful commands
194
+
195
+ Some common invocations of ` x.py ` are:
196
+
197
+ - ` x.py build --help ` - show the help message and explain the subcommand
198
+ - ` x.py build src/libtest --stage 1 ` - build up to (and including) the first
199
+ stage. For most cases we don't need to build the stage2 compiler, so we can
200
+ save time by not building it. The stage1 compiler is a fully functioning
201
+ compiler and (probably) will be enough to determine if your change works as
202
+ expected.
203
+ - ` x.py build src/rustc --stage 1 ` - This will build just rustc, without libstd.
204
+ This is the fastest way to recompile after you changed only rustc source code.
205
+ Note however that the resulting rustc binary won't have a stdlib to link
206
+ against by default. You can build libstd once with ` x.py build src/libstd ` ,
207
+ but it is is only guaranteed to work if recompiled, so if there are any issues
208
+ recompile it.
209
+ - ` x.py test ` - build the full compiler & run all tests (takes a while). This
139
210
is what gets run by the continuous integration system against your pull
140
211
request. You should run this before submitting to make sure your tests pass
141
212
& everything builds in the correct manner.
142
- - ` make check-stage1-std NO_REBUILD= 1` - test the standard library without
143
- rebuilding the entire compiler
144
- - ` make check TESTNAME=<substring-of-test-name> ` - Run a matching set of tests.
213
+ - ` x.py test src/libstd --stage 1` - test the standard library without
214
+ recompiling stage 2.
215
+ - ` x.py test src/test/run-pass --filter TESTNAME ` - Run a matching set of tests.
145
216
- ` TESTNAME ` should be a substring of the tests to match against e.g. it could
146
217
be the fully qualified test name, or just a part of it.
147
218
` TESTNAME=collections::hash::map::test_map::test_capacity_not_less_than_len `
148
219
or ` TESTNAME=test_capacity_not_less_than_len ` .
149
- - ` make check-stage1-rpass TESTNAME=<substring-of-test-name> ` - Run a single
150
- rpass test with the stage1 compiler (this will be quicker than running the
151
- command above as we only build the stage1 compiler, not the entire thing).
152
- You can also leave off the ` -rpass ` to run all stage1 test types.
153
- - ` make check-stage1-coretest ` - Run stage1 tests in ` libcore ` .
154
- - ` make tidy ` - Check that the source code is in compliance with Rust's style
155
- guidelines. There is no official document describing Rust's full guidelines
156
- as of yet, but basic rules like 4 spaces for indentation and no more than 99
157
- characters in a single line should be kept in mind when writing code.
220
+ - ` x.py test src/test/run-pass --stage 1 --filter <substring-of-test-name> ` -
221
+ Run a single rpass test with the stage1 compiler (this will be quicker than
222
+ running the command above as we only build the stage1 compiler, not the entire
223
+ thing). You can also leave off the directory argument to run all stage1 test
224
+ types.
225
+ - ` x.py test src/libcore --stage 1 ` - Run stage1 tests in ` libcore ` .
226
+ - ` x.py test src/tools/tidy ` - Check that the source code is in compliance with
227
+ Rust's style guidelines. There is no official document describing Rust's full
228
+ guidelines as of yet, but basic rules like 4 spaces for indentation and no
229
+ more than 99 characters in a single line should be kept in mind when writing
230
+ code.
158
231
159
232
## Pull Requests
160
233
@@ -172,19 +245,17 @@ amount of time you have to wait. You need to have built the compiler at least
172
245
once before running these will work, but that’s only one full build rather than
173
246
one each time.
174
247
175
- $ make -j8 rustc-stage1 && make check-stage1
248
+ $ python x.py test --stage 1
176
249
177
250
is one such example, which builds just ` rustc ` , and then runs the tests. If
178
251
you’re adding something to the standard library, try
179
252
180
- $ make -j8 check-stage1-std NO_REBUILD=1
181
-
182
- This will not rebuild the compiler, but will run the tests.
253
+ $ python x.py test src/libstd --stage 1
183
254
184
255
Please make sure your pull request is in compliance with Rust's style
185
256
guidelines by running
186
257
187
- $ make tidy
258
+ $ python x.py test src/tools/ tidy
188
259
189
260
Make this check before every pull request (and every new commit in a pull
190
261
request) ; you can add [ git hooks] ( https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks )
0 commit comments