Skip to content

Commit 6d1e5a2

Browse files
author
Rajkumar Natarajan
committed
issue-130 copy contents related x.py from rust-forge
1 parent 81fd1c0 commit 6d1e5a2

6 files changed

+199
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Build distribution artifacts
2+
3+
You might want to build and package up the compiler for distribution.
4+
You’ll want to run this command to do it:
5+
6+
`./x.py dist`
7+
8+
Other Flags
9+
10+
The same flags from build are available here.
11+
You might want to consider adding on the -j flag for faster builds
12+
when building a distribution artifact.
13+
14+
```
15+
-j, --jobs JOBS number of jobs to run in parallel
16+
```
17+
18+
19+
# Install distribution artifacts
20+
21+
If you’ve built a distribution artifact you might want to install it and
22+
test that it works on your target system. You’ll want to run this command:
23+
24+
`./x.py install`
25+
26+
Other Flags
27+
The same flags from build are available

src/compiler-benchmarking.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Benchmarking rustc
2+
3+
This one is a easier compared to the others.
4+
All you’re doing is running benchmarks of the compiler itself
5+
so it’ll build it and run the one set of benchmarks available to it.
6+
The command is:
7+
8+
`./x.py bench`
9+
10+
Benchmarking lacks `--no-fail-fast` flag that `test` command has.
11+

src/compiler-documenting.md

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Documenting rustc
2+
3+
You might want to build documentation of the various components
4+
available like the standard library. There’s two ways to go about this.
5+
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.
9+
10+
## Document everything
11+
12+
`./x.py doc`
13+
14+
## If you want to avoid the whole Stage 2 build
15+
16+
`./x.py doc --stage 1`
17+
18+
First the compiler and rustdoc get built to make sure everything is okay
19+
and then it documents the files.
20+
21+
## Document specific components
22+
23+
```bash
24+
./x.py doc src/doc/book
25+
./x.py doc src/doc/nomicon
26+
./x.py doc src/doc/book src/libstd
27+
```
28+
29+
Much like individual tests or building certain components you can build only
30+
the documentation you want.
31+
32+
## Document internal rustc items
33+
By default rustc does not build the compiler docs for its internal items.
34+
Mostly because this is useless for the average user. However, you might need
35+
to have it available so you can understand the types. Here’s how you can
36+
compile it yourself. From the top level directory where x.py is located run:
37+
38+
cp config.toml.example config.toml
39+
40+
Next open up config.toml and make sure these two lines are set to true:
41+
42+
docs = true
43+
compiler-docs = true
44+
When you want to build the compiler docs as well run this command:
45+
46+
`./x.py doc`
47+
48+
This will see that the docs and compiler-docs options are set to true
49+
and build the normally hidden compiler docs!

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

+47-2
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,42 @@ This is just a subset of the full rustc build. The **full** rustc build
110110
- Build libstd with stage2 compiler.
111111
- Build librustdoc and a bunch of other things.
112112

113+
### Build different stages
114+
115+
./x.py build --stage 0
116+
117+
# Stage 1 is typically enough to test out all of your changes
118+
# to the compiler
119+
./x.py build --stage 1
120+
121+
# Equivalent to ./x.py build
122+
./x.py build --stage 2
123+
124+
You can pass the --stage flag with what stage you want to build to.
125+
It is recommended that you build to Stage 1 as this is enough to know
126+
your changes can successfully compile and should let you run tests
127+
with your changes.
128+
129+
### Build specific components
130+
131+
Build only the libcore library
132+
133+
`./x.py build src/libcore`
134+
135+
Build the libcore and libproc_macro library only
136+
137+
`./x.py build src/libcore src/libproc_macro`
138+
139+
Build only libcore up to Stage 1
140+
141+
`./x.py build src/libcore --stage 1`
142+
143+
Sometimes you might just want to test if the part you’re working on can
144+
compile. Using these commands you can test that it compiles before doing
145+
a bigger build to make sure it works with the compiler. As shown before
146+
you can also pass flags at the end such as --stage.
147+
148+
113149
### Creating a rustup toolchain
114150

115151
Once you have successfully built rustc, you will have created a bunch
@@ -121,8 +157,8 @@ you will likely need to build at some point; for example, if you want
121157
to run the entire test suite).
122158

123159
```bash
124-
> rustup toolchain link stage1 build/<host-triple>/stage1
125-
> rustup toolchain link stage2 build/<host-triple>/stage2
160+
rustup toolchain link stage1 build/<host-triple>/stage1
161+
rustup toolchain link stage2 build/<host-triple>/stage2
126162
```
127163

128164
Now you can run the rustc you built with. If you run with `-vV`, you
@@ -173,3 +209,12 @@ This allows you to do "jump-to-def" with whatever functions were around when
173209
you last built, which is ridiculously useful.
174210

175211
[etags]: https://github.com/nikomatsakis/rust-etags
212+
213+
### Cleaning out build directories
214+
215+
Sometimes you need to start fresh, but this is normally not the case.
216+
If you need to run this then rustbuild is most likely not acting right and
217+
you should file a bug as to what is going wrong. If you do need to clean
218+
everything up then you only need to run one command!
219+
220+
`./x.py clean`

src/tests/running.md

+23
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,26 @@ This is much faster, but doesn't always work. For example, some tests
7070
include directives that specify specific compiler flags, or which rely
7171
on other crates, and they may not run the same without those options.
7272

73+
### Run specific tests
74+
75+
# Run only the tidy script
76+
```bash
77+
> ./x.py test src/tools/tidy
78+
```
79+
# Run tests on the standard library
80+
```bash
81+
> ./x.py test src/libstd
82+
```
83+
84+
# Run tests on the standard library and run the tidy script
85+
```bash
86+
> ./x.py test src/libstd src/tools/tidy
87+
```
88+
89+
# Run tests on the standard library using a stage 1 compiler
90+
```bash
91+
> ./x.py test src/libstd --stage 1
92+
```
93+
94+
By listing which test suites you want to run you avoid having to run tests for
95+
components you did not change at all.

src/what-is-x-py.md

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# what is x.py?
2+
3+
x.py is the script used to orchestrate the tooling in the rustc repository.
4+
It is the script that can build docs, run tests, and compile rustc.
5+
It is the now preferred way to build rustc and it replaces the old makefiles
6+
from before. Below are the different ways to utilize x.py in order to
7+
effectively deal with the repo for various common tasks.
8+
9+
### Build Flags
10+
11+
There are other flags you can pass to the build portion of x.py that can be
12+
beneficial to cutting down compile times or fitting other things you might
13+
need to change. They are:
14+
15+
```
16+
Options:
17+
-v, --verbose use verbose output (-vv for very verbose)
18+
-i, --incremental use incremental compilation
19+
--config FILE TOML configuration file for build
20+
--build BUILD build target of the stage0 compiler
21+
--host HOST host targets to build
22+
--target TARGET target targets to build
23+
--on-fail CMD command to run on failure
24+
--stage N stage to build
25+
--keep-stage N stage to keep without recompiling
26+
--src DIR path to the root of the rust checkout
27+
-j, --jobs JOBS number of jobs to run in parallel
28+
-h, --help print this help message
29+
```
30+
31+
Note that the options --incremental, --keep-stage 0 and --jobs JOBS can be
32+
used in tandem with --stage to help reduce build times significantly by
33+
reusing already built components, reusing the first bootstrapped stage, and
34+
running compilation in parallel. To test changes you could run something like:
35+
36+
```bash
37+
./x.py build --stage 1 --keep-stage 0 -j 4 -i
38+
```
39+
40+
Please follow the links to build, document, test, benchmark and install
41+
distribution
42+
artifacts for rustc respectively.

0 commit comments

Comments
 (0)