Skip to content

Commit 9963b90

Browse files
author
Rajkumar Natarajan
committed
issue-130 incorporate the review comments
1 parent d7c7678 commit 9963b90

6 files changed

+89
-63
lines changed

src/SUMMARY.md

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
- [About this guide](./about-this-guide.md)
44
- [About the compiler team](./compiler-team.md)
55
- [How to build the compiler and run what you built](./how-to-build-and-run.md)
6+
- [Build and Install distribution artifacts](./build-install-distribution-artifacts.md)
7+
- [Documenting Compiler](./compiler-documenting.md)
68
- [Coding conventions](./conventions.md)
79
- [Walkthrough: a typical contribution](./walkthrough.md)
810
- [The compiler testing framework](./tests/intro.md)

src/build-install-distribution-artifacts.md

+8-4
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
You might want to build and package up the compiler for distribution.
44
You’ll want to run this command to do it:
55

6-
`./x.py dist`
6+
```
7+
./x.py dist
8+
```
79

8-
Other Flags
10+
## Other Flags
911

1012
The same flags from build are available here.
1113
You might want to consider adding on the -j flag for faster builds
@@ -21,7 +23,9 @@ when building a distribution artifact.
2123
If you’ve built a distribution artifact you might want to install it and
2224
test that it works on your target system. You’ll want to run this command:
2325

24-
`./x.py install`
26+
```
27+
./x.py install
28+
```
2529

26-
Other Flags
30+
## Other Flags
2731
The same flags from build are available

src/compiler-documenting.md

+18-8
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,21 @@
33
You might want to build documentation of the various components
44
available like the standard library. There’s two ways to go about this.
55
You can run rustdoc directly on the file to make sure the HTML is
6-
correct which is fast or you can build the documentation as part of the
7-
build process through x.py. Both are viable methods since documentation
8-
is more about the content.
6+
correct, which is fast. Alternatively, you can build the documentation
7+
as part of the build process through x.py. Both are viable methods
8+
since documentation is more about the content.
99

1010
## Document everything
1111

12-
`./x.py doc`
12+
```
13+
./x.py doc
14+
```
1315

1416
## If you want to avoid the whole Stage 2 build
1517

16-
`./x.py doc --stage 1`
18+
```
19+
./x.py doc --stage 1
20+
```
1721

1822
First the compiler and rustdoc get built to make sure everything is okay
1923
and then it documents the files.
@@ -35,15 +39,21 @@ Mostly because this is useless for the average user. However, you might need
3539
to have it available so you can understand the types. Here’s how you can
3640
compile it yourself. From the top level directory where x.py is located run:
3741

42+
```
3843
cp config.toml.example config.toml
44+
```
3945

4046
Next open up config.toml and make sure these two lines are set to true:
4147

42-
docs = true
43-
compiler-docs = true
48+
```
49+
docs = true
50+
compiler-docs = true
51+
```
4452
When you want to build the compiler docs as well run this command:
4553

46-
`./x.py doc`
54+
```
55+
./x.py doc
56+
```
4757

4858
This will see that the docs and compiler-docs options are set to true
4959
and build the normally hidden compiler docs!

src/how-to-build-and-run.md

+57-3
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ debuginfo-lines = true
4747
use-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

5260
One 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+
```
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+
83137
For hacking, often building the stage 1 compiler is enough, but for
84138
final testing and release, the stage 2 compiler is used.
85139

@@ -183,8 +237,8 @@ you will likely need to build at some point; for example, if you want
183237
to run the entire test suite).
184238

185239
```bash
186-
rustup toolchain link stage1 build/<host-triple>/stage1
187-
rustup toolchain link stage2 build/<host-triple>/stage2
240+
> rustup toolchain link stage1 build/<host-triple>/stage1
241+
> rustup toolchain link stage2 build/<host-triple>/stage2
188242
```
189243

190244
The `<host-triple>` would typically be one of the following:
@@ -309,4 +363,4 @@ If you need to run this then rustbuild is most likely not acting right and
309363
you should file a bug as to what is going wrong. If you do need to clean
310364
everything up then you only need to run one command!
311365

312-
`./x.py clean`
366+
`./x.py clean`

src/tests/running.md

+4-6
Original file line numberDiff line numberDiff line change
@@ -93,23 +93,21 @@ This is much faster, but doesn't always work. For example, some tests
9393
include directives that specify specific compiler flags, or which rely
9494
on other crates, and they may not run the same without those options.
9595

96-
### Run specific tests
97-
98-
# Run only the tidy script
96+
### Run only the tidy script
9997
```bash
10098
> ./x.py test src/tools/tidy
10199
```
102-
# Run tests on the standard library
100+
### Run tests on the standard library
103101
```bash
104102
> ./x.py test src/libstd
105103
```
106104

107-
# Run tests on the standard library and run the tidy script
105+
### Run tests on the standard library and run the tidy script
108106
```bash
109107
> ./x.py test src/libstd src/tools/tidy
110108
```
111109

112-
# Run tests on the standard library using a stage 1 compiler
110+
### Run tests on the standard library using a stage 1 compiler
113111
```bash
114112
> ./x.py test src/libstd --stage 1
115113
```

src/what-is-x-py.md

-42
This file was deleted.

0 commit comments

Comments
 (0)