@@ -24,52 +24,24 @@ cd rust
2424## Create a ` config.toml `
2525
2626To start, run ` ./x.py setup ` . This will do some initialization and create a
27- ` config.toml ` for you with reasonable defaults. These defaults are specified
28- indirectly via the ` profile ` setting, which points to one of the TOML files in
29- ` src/bootstrap/defaults. `
27+ ` config.toml ` for you with reasonable defaults.
3028
3129Alternatively, you can write ` config.toml ` by hand. See ` config.toml.example `
32- for all the available settings and explanations of them. The following settings
33- are of particular interest, and ` config.toml.example ` has full explanations.
34-
35- You may want to change some of the following settings (and possibly others, such as
36- ` llvm.ccache ` ):
37-
38- ``` toml
39- [llvm ]
40- # Whether to use Rust CI built LLVM instead of locally building it.
41- download-ci-llvm = true # Download a pre-built LLVM?
42- assertions = true # LLVM assertions on?
43- ccache = " /path/to/ccache" # Use ccache when building LLVM?
44-
45- [rust ]
46- debug-logging = true # Leave debug! and trace! calls in rustc?
47- incremental = true # Build rustc with incremental compilation?
48- ```
49-
50- If you set ` download-ci-llvm = true ` , in some circumstances, such as when
51- updating the version of LLVM used by ` rustc ` , you may want to temporarily
52- disable this feature. See the [ "Updating LLVM" section] for more.
53-
54- [ "Updating LLVM" section ] : ../backend/updating-llvm.md#feature-updates
30+ for all the available settings and explanations of them. See ` src/bootstrap/defaults ` for common settings to change.
5531
5632If you have already built ` rustc ` and you change settings related to LLVM, then you may have to
5733execute ` rm -rf build ` for subsequent configuration changes to take effect. Note that `./x.py
5834clean` will not cause a rebuild of LLVM.
5935
6036## What is ` x.py ` ?
6137
62- ` x.py ` is the script used to orchestrate the tooling in the ` rustc ` repository.
63- It is the script that can build docs, run tests, and compile ` rustc ` .
64- It is the now preferred way to build ` rustc ` and it replaces the old makefiles
65- from before. Below are the different ways to utilize ` x.py ` in order to
66- effectively deal with the repo for various common tasks.
38+ ` x.py ` is the build tool for the ` rust ` repository. It can build docs, run tests, and compile the
39+ compiler and standard library.
6740
6841This chapter focuses on the basics to be productive, but
69- if you want to learn more about ` x.py ` , read its README.md
70- [ here] ( https://github.com/rust-lang/rust/blob/master/src/bootstrap/README.md ) .
71- To read more about the bootstrap process and why ` x.py ` is necessary,
72- [ read this chapter] [ bootstrap ] .
42+ if you want to learn more about ` x.py ` , [ read this chapter] [ bootstrap ] .
43+
44+ [ bootstrap ] : ./bootstrapping.md
7345
7446### Running ` x.py ` slightly more conveniently
7547
@@ -79,48 +51,14 @@ of a checkout. It also looks up the appropriate version of `python` to use.
7951
8052You can install it with ` cargo install --path src/tools/x ` .
8153
82- [ bootstrap ] : ./bootstrapping.md
83-
8454## Building the Compiler
8555
86- To build a compiler, run ` ./x.py build ` . This will build up to the stage1 compiler,
87- including ` rustdoc ` , producing a usable compiler toolchain from the source
88- code you have checked out.
89-
9056Note that building will require a relatively large amount of storage space.
9157You may want to have upwards of 10 or 15 gigabytes available to build the compiler.
9258
93- There are many flags you can pass to the build command of ` x.py ` that can be
94- beneficial to cutting down compile times or fitting other things you might
95- need to change. They are:
96-
97- ``` txt
98- Options:
99- -v, --verbose use verbose output (-vv for very verbose)
100- -i, --incremental use incremental compilation
101- --config FILE TOML configuration file for build
102- --build BUILD build target of the stage0 compiler
103- --host HOST host targets to build
104- --target TARGET target targets to build
105- --on-fail CMD command to run on failure
106- --stage N stage to build
107- --keep-stage N stage to keep without recompiling
108- --src DIR path to the root of the Rust checkout
109- -j, --jobs JOBS number of jobs to run in parallel
110- -h, --help print this help message
111- ```
112-
113- For hacking, often building the stage 1 compiler is enough, which saves a lot
114- of time. But for final testing and release, the stage 2 compiler is used.
115-
116- ` ./x.py check ` is really fast to build the Rust compiler.
117- It is, in particular, very useful when you're doing some kind of
118- "type-based refactoring", like renaming a method, or changing the
119- signature of some function.
120-
12159Once you've created a ` config.toml ` , you are now ready to run
12260` x.py ` . There are a lot of options here, but let's start with what is
123- probably the best "go to" command for building a local rust :
61+ probably the best "go to" command for building a local compiler :
12462
12563``` bash
12664./x.py build library
@@ -144,6 +82,10 @@ see [the section on avoiding rebuilds for std][keep-stage].
14482
14583[ keep-stage ] : ./suggested.md#faster-builds-with---keep-stage
14684
85+ Sometimes you don't need a full build. When doing some kind of
86+ "type-based refactoring", like renaming a method, or changing the
87+ signature of some function, you can use ` ./x.py check ` instead for a much faster build.
88+
14789Note that this whole command just gives you a subset of the full ` rustc `
14890build. The ** full** ` rustc ` build (what you get with `./x.py build
14991--stage 2 compiler/rustc`) has quite a few more steps:
@@ -165,6 +107,9 @@ Instead, you can just build using the bootstrap compiler.
165107./x.py build --stage 0 library
166108```
167109
110+ If you choose the ` library ` profile when running ` x.py setup ` , you can omit ` --stage 0 ` (it's the
111+ default).
112+
168113## Creating a rustup toolchain
169114
170115Once you have successfully built ` rustc ` , you will have created a bunch
@@ -273,7 +218,7 @@ in other sections:
273218 - ` ./x.py build ` – builds everything using the stage 1 compiler,
274219 not just up to ` std `
275220 - ` ./x.py build --stage 2 ` – builds everything with the stage 2 compiler including
276- ` rustdoc ` (which doesn't take too long)
221+ ` rustdoc `
277222- Running tests (see the [ section on running tests] ( ../tests/running.html ) for
278223 more details):
279224 - ` ./x.py test library/std ` – runs the unit tests and integration tests from ` std `
0 commit comments