Skip to content

Commit 64b46a9

Browse files
jyn514tshepang
authored andcommitted
Update the build instructions for the standard library
Since rust-lang#95503, `library/std` means "build just std and its dependencies"; to get the old behavior that built `proc_macro` and `test`, you need `x build library`. - Update `library/std` to `library` - Remove the `-i` suggestions; `incremental = true` is already the default for most profiles, in which case `-i` does nothing. If you don't have incremental enabled, I still think suggesting `-i` is bad idea, because it's easy to forget once, at which point you'll end up rebuilding the whole compiler / standard library. - Remove a few repetitive sections and don't discuss incremental in such detail Incremental works well enough that it should "just work" for most people; I don't think it needs multiple paragraphs of explanation so early in the guide. - Clarify that `test library/std` *only* tests libstd in a few places
1 parent 997282c commit 64b46a9

10 files changed

+30
-43
lines changed

src/doc/rustc-dev-guide/src/building/bootstrapping.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ However, it takes a very long time to build
5555
because one must first build the new compiler with an older compiler
5656
and then use that to build the new compiler with itself.
5757
For development, you usually only want the `stage1` compiler,
58-
which you can build with `./x.py build library/std`.
58+
which you can build with `./x.py build library`.
5959
See [Building the Compiler](./how-to-build-and-run.html#building-the-compiler).
6060

6161
### Stage 3
@@ -169,15 +169,15 @@ Build artifacts include, but are not limited to:
169169

170170
#### Examples of what *not* to do
171171

172-
- `./x.py test --stage 0 src/test/ui` is not meaningful: it runs tests on the
172+
- `./x.py test --stage 0 src/test/ui` is not useful: it runs tests on the
173173
_beta_ compiler and doesn't build `rustc` from source. Use `test src/test/ui`
174174
instead, which builds stage 1 from source.
175175
- `./x.py test --stage 0 compiler/rustc` builds the compiler but runs no tests:
176176
it's running `cargo test -p rustc`, but cargo doesn't understand Rust's
177177
tests. You shouldn't need to use this, use `test` instead (without arguments).
178178
- `./x.py build --stage 0 compiler/rustc` builds the compiler, but does not build
179179
libstd or even libcore. Most of the time, you'll want `./x.py build
180-
library/std` instead, which allows compiling programs without needing to define
180+
library` instead, which allows compiling programs without needing to define
181181
lang items.
182182

183183
### Building vs. running

src/doc/rustc-dev-guide/src/building/compiler-documenting.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ and then it documents the files.
3030
```bash
3131
./x.py doc src/doc/book
3232
./x.py doc src/doc/nomicon
33-
./x.py doc src/doc/book library/std
33+
./x.py doc src/doc/book library
3434
```
3535

3636
Much like individual tests or building certain components you can build only

src/doc/rustc-dev-guide/src/building/how-to-build-and-run.md

+9-25
Original file line numberDiff line numberDiff line change
@@ -138,34 +138,23 @@ Once you've created a `config.toml`, you are now ready to run
138138
probably the best "go to" command for building a local rust:
139139

140140
```bash
141-
./x.py build -i library/std
141+
./x.py build library
142142
```
143143

144-
This may *look* like it only builds `std`, but that is not the case.
144+
This may *look* like it only builds the standard library, but that is not the case.
145145
What this command does is the following:
146146

147-
- Build `std` using the stage0 compiler (using incremental)
148-
- Build `rustc` using the stage0 compiler (using incremental)
147+
- Build `std` using the stage0 compiler
148+
- Build `rustc` using the stage0 compiler
149149
- This produces the stage1 compiler
150-
- Build `std` using the stage1 compiler (cannot use incremental)
150+
- Build `std` using the stage1 compiler
151151

152152
This final product (stage1 compiler + libs built using that compiler)
153153
is what you need to build other Rust programs (unless you use `#![no_std]` or
154154
`#![no_core]`).
155155

156-
The command includes the `-i` switch which enables incremental compilation.
157-
This will be used to speed up the first two steps of the process:
158-
in particular, if you make a small change, we ought to be able to use your old
159-
results to make producing the stage1 **compiler** faster.
160-
161-
Unfortunately, incremental cannot be used to speed up making the
162-
stage1 libraries. This is because incremental only works when you run
163-
the *same compiler* twice in a row. In this case, we are building a
164-
*new stage1 compiler* every time. Therefore, the old incremental
165-
results may not apply. **As a result, you will probably find that
166-
building the stage1 `std` is a bottleneck for you** -- but fear not,
167-
there is a (hacky) workaround. See [the section on "recommended
168-
workflows"](./suggested.md) below.
156+
You will probably find that building the stage1 `std` is a bottleneck for you** -- but fear not,
157+
there is a (hacky) workaround. See [the section on "recommended workflows"](./suggested.md) below.
169158

170159
Note that this whole command just gives you a subset of the full `rustc`
171160
build. The **full** `rustc` build (what you get with `./x.py build
@@ -185,14 +174,9 @@ the compiler unless you are planning to use a recently added nightly feature.
185174
Instead, you can just build using the bootstrap compiler.
186175

187176
```bash
188-
./x.py build --stage 0 library/std
177+
./x.py build --stage 0 library
189178
```
190179

191-
Sometimes you might just want to test if the part you’re working on can
192-
compile. Using these commands you can test that it compiles before doing
193-
a bigger build to make sure it works with the compiler. As shown before
194-
you can also pass flags at the end such as `--stage`.
195-
196180
## Creating a rustup toolchain
197181

198182
Once you have successfully built `rustc`, you will have created a bunch
@@ -251,7 +235,7 @@ in other sections:
251235
`rustdoc` (which doesn't take too long)
252236
- Running tests (see the [section on running tests](../tests/running.html) for
253237
more details):
254-
- `./x.py test library/std` – runs the `#[test]` tests from `std`
238+
- `./x.py test library/std` – runs the unit tests and integration tests from `std`
255239
- `./x.py test src/test/ui` – runs the `ui` test suite
256240
- `./x.py test src/test/ui/const-generics` - runs all the tests in
257241
the `const-generics/` subdirectory of the `ui` test suite

src/doc/rustc-dev-guide/src/building/suggested.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,13 @@ don't work (but that is easily detected and fixed).
144144

145145
The sequence of commands you want is as follows:
146146

147-
- Initial build: `./x.py build -i library/std`
147+
- Initial build: `./x.py build library`
148148
- As [documented previously], this will build a functional
149149
stage1 compiler as part of running all stage0 commands (which include
150150
building a `std` compatible with the stage1 compiler) as well as the
151151
first few steps of the "stage 1 actions" up to "stage1 (sysroot stage1)
152152
builds std".
153-
- Subsequent builds: `./x.py build -i library/std --keep-stage 1`
153+
- Subsequent builds: `./x.py build library --keep-stage 1`
154154
- Note that we added the `--keep-stage 1` flag here
155155

156156
[documented previously]: ./how-to-build-and-run.md#building-the-compiler
@@ -172,8 +172,8 @@ rebuild. That ought to fix the problem.
172172

173173
You can also use `--keep-stage 1` when running tests. Something like this:
174174

175-
- Initial test run: `./x.py test -i src/test/ui`
176-
- Subsequent test run: `./x.py test -i src/test/ui --keep-stage 1`
175+
- Initial test run: `./x.py test src/test/ui`
176+
- Subsequent test run: `./x.py test src/test/ui --keep-stage 1`
177177

178178
## Fine-tuning optimizations
179179

src/doc/rustc-dev-guide/src/contributing.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ You can find documentation style guidelines in [RFC 1574][rfc1574].
408408
In many cases, you don't need a full `./x.py doc --stage 2`, which will build
409409
the entire stage 2 compiler and compile the various books published on
410410
[doc.rust-lang.org][docs]. When updating documentation for the standard library,
411-
first try `./x.py doc library/std`. If that fails, or if you need to
411+
first try `./x.py doc library`. If that fails, or if you need to
412412
see the output from the latest version of `rustdoc`, add `--stage 1`.
413413
Results should appear in `build/$TARGET/doc`.
414414

src/doc/rustc-dev-guide/src/profiling/wpa_profiling.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ we'll need to build a stage 1 compiler and then a stage 2 compiler ourselves.
4747
To do this, make sure you have set `debuginfo-level = 1` in your `config.toml` file. This tells
4848
rustc to generate debug information which includes stack frames when bootstrapping.
4949

50-
Now you can build the stage 1 compiler: `python x.py build --stage 1 -i library/std` or however
50+
Now you can build the stage 1 compiler: `python x.py build --stage 1 -i library` or however
5151
else you want to build the stage 1 compiler.
5252

5353
Now that the stage 1 compiler is built, we can record the stage 2 build. Go back to WPR, click the
54-
"start" button and build the stage 2 compiler (e.g., `python x build --stage=2 -i library/std `).
54+
"start" button and build the stage 2 compiler (e.g., `python x build --stage=2 -i library`).
5555
When this process finishes, stop the recording.
5656

5757
Click the Save button and once that process is complete, click the "Open in WPA" button which

src/doc/rustc-dev-guide/src/rustdoc-internals.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ server. To test these features locally, you can run a local HTTP server, like
224224
this:
225225

226226
```bash
227-
$ ./x.py doc library/std
227+
$ ./x.py doc library
228228
# The documentation has been generated into `build/[YOUR ARCH]/doc`.
229229
$ python3 -m http.server -d build/[YOUR ARCH]/doc
230230
```

src/doc/rustc-dev-guide/src/rustdoc.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ does is call the `main()` that's in this crate's `lib.rs`, though.)
5050
custom toolchain called `stage2` to your rustup environment. After
5151
running that, `cargo +stage2 doc` in any directory will build with
5252
your locally-compiled rustdoc.
53-
* Use `./x.py doc library/std` to use this rustdoc to generate the
53+
* Use `./x.py doc library` to use this rustdoc to generate the
5454
standard library docs.
55-
* The completed docs will be available in `build/$TARGET/doc/std`.
55+
* The completed docs will be available in `build/$TARGET/doc` (under `core`, `alloc`, and `std`).
5656
* If you want to copy those docs to a webserver, copy all of
5757
`build/$TARGET/doc`, since that's where the CSS, JS, fonts, and landing
5858
page are.

src/doc/rustc-dev-guide/src/tests/intro.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ Examples:
3535

3636
| Command | Description |
3737
|---------|-------------|
38-
| `./x.py test library/std` | Runs tests on `std` |
39-
| `./x.py test library/core` | Runs tests on `core` |
38+
| `./x.py test library/std` | Runs tests on `std` only |
39+
| `./x.py test library/core` | Runs tests on `core` only |
4040
| `./x.py test compiler/rustc_data_structures` | Runs tests on `rustc_data_structures` |
4141

4242
The standard library relies very heavily on documentation tests to cover its functionality.

src/doc/rustc-dev-guide/src/tests/running.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ Likewise, you can test a single file by passing its path:
7474
./x.py test --stage 0 library/std
7575
```
7676

77+
Note that this only runs tests on `std`; if you want to test `core` or other crates,
78+
you have to specify those explicitly.
79+
7780
### Run the tidy script and tests on the standard library
7881

7982
```bash
@@ -83,7 +86,7 @@ Likewise, you can test a single file by passing its path:
8386
### Run tests on the standard library using a stage 1 compiler
8487

8588
```bash
86-
./x.py test library/std
89+
./x.py test --stage 1 library/std
8790
```
8891

8992
By listing which test suites you want to run you avoid having to run
@@ -98,7 +101,7 @@ there are some limitations.
98101
```bash
99102
./x.py test --stage 2
100103
```
101-
You almost never need to do this.
104+
You almost never need to do this; CI will run these tests for you.
102105

103106
## Run unit tests on the compiler/library
104107

0 commit comments

Comments
 (0)