@@ -24,52 +24,24 @@ cd rust
24
24
## Create a ` config.toml `
25
25
26
26
To 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.
30
28
31
29
Alternatively, 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.
55
31
56
32
If you have already built ` rustc ` and you change settings related to LLVM, then you may have to
57
33
execute ` rm -rf build ` for subsequent configuration changes to take effect. Note that `./x.py
58
34
clean` will not cause a rebuild of LLVM.
59
35
60
36
## What is ` x.py ` ?
61
37
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.
67
40
68
41
This 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
73
45
74
46
### Running ` x.py ` slightly more conveniently
75
47
@@ -79,48 +51,14 @@ of a checkout. It also looks up the appropriate version of `python` to use.
79
51
80
52
You can install it with ` cargo install --path src/tools/x ` .
81
53
82
- [ bootstrap ] : ./bootstrapping.md
83
-
84
54
## Building the Compiler
85
55
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
-
90
56
Note that building will require a relatively large amount of storage space.
91
57
You may want to have upwards of 10 or 15 gigabytes available to build the compiler.
92
58
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
-
121
59
Once you've created a ` config.toml ` , you are now ready to run
122
60
` 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 :
124
62
125
63
``` bash
126
64
./x.py build library
@@ -144,6 +82,10 @@ see [the section on avoiding rebuilds for std][keep-stage].
144
82
145
83
[ keep-stage ] : ./suggested.md#faster-builds-with---keep-stage
146
84
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
+
147
89
Note that this whole command just gives you a subset of the full ` rustc `
148
90
build. The ** full** ` rustc ` build (what you get with `./x.py build
149
91
--stage 2 compiler/rustc`) has quite a few more steps:
@@ -165,6 +107,8 @@ Instead, you can just build using the bootstrap compiler.
165
107
./x.py build --stage 0 library
166
108
```
167
109
110
+ If you choose the ` library ` profile when running ` x.py setup ` , you can omit ` --stage 0 ` (it's the default).
111
+
168
112
## Creating a rustup toolchain
169
113
170
114
Once you have successfully built ` rustc ` , you will have created a bunch
@@ -273,7 +217,7 @@ in other sections:
273
217
- ` ./x.py build ` – builds everything using the stage 1 compiler,
274
218
not just up to ` std `
275
219
- ` ./x.py build --stage 2 ` – builds everything with the stage 2 compiler including
276
- ` rustdoc ` (which doesn't take too long)
220
+ ` rustdoc `
277
221
- Running tests (see the [ section on running tests] ( ../tests/running.html ) for
278
222
more details):
279
223
- ` ./x.py test library/std ` – runs the unit tests and integration tests from ` std `
0 commit comments