Skip to content

Commit 6b3a5fb

Browse files
committed
Rewrite the section on passing flags to subcommands
- Move the reference for directories and actions to the very end; it's the most rare to need to know - Add `RUSTDOCFLAGS*`, `CARGOFLAGS*`, `-vvv`, and `--test-args` - Remove the incorrect `--on-fail` command
1 parent c3232c4 commit 6b3a5fb

File tree

1 file changed

+39
-26
lines changed

1 file changed

+39
-26
lines changed

src/building/bootstrapping.md

+39-26
Original file line numberDiff line numberDiff line change
@@ -370,9 +370,46 @@ You can find more discussion about sysroots in:
370370

371371
[rustdoc PR]: https://github.com/rust-lang/rust/pull/76728
372372

373-
### Directories and artifacts generated by `x.py`
373+
## Passing flags to commands invoked by `bootstrap`
374374

375-
The following tables indicate the outputs of various stage actions:
375+
`x.py` allows you to pass stage-specific flags to `rustc` and `cargo` when bootstrapping.
376+
The `RUSTFLAGS_BOOTSTRAP` environment variable is passed as RUSTFLAGS to the bootstrap stage
377+
(stage0), and `RUSTFLAGS_NOT_BOOTSTRAP` is passed when building artifacts for later stages.
378+
`RUSTFLAGS` will work, but also affects the build of `bootstrap` itself, so it will be rare to want
379+
to use it.
380+
Finally, `MAGIC_EXTRA_RUSTFLAGS` bypasses the `cargo` cache to pass flags to rustc without
381+
recompiling all dependencies.
382+
383+
`RUSTDOCFLAGS`, `RUSTDOCFLAGS_BOOTSTRAP`, and `RUSTDOCFLAGS_NOT_BOOTSTRAP` are anologous to
384+
`RUSTFLAGS`, but for rustdoc.
385+
386+
`CARGOFLAGS` will pass arguments to cargo itself (e.g. `--timings`). `CARGOFLAGS_BOOTSTRAP` and
387+
`CARGOFLAGS_NOT_BOOTSTRAP` work anologously to `RUSTFLAGS_BOOTSTRAP`.
388+
389+
`--test-args` will pass arguments through to the test runner. For `src/test/ui`, this is
390+
compiletest; for unit tests and doctests this is the `libtest` runner. Most test runner accept
391+
`--help`, which you can use to find out the options accepted by the runner.
392+
393+
## Environment Variables
394+
395+
During bootstrapping, there are a bunch of compiler-internal environment
396+
variables that are used. If you are trying to run an intermediate version of
397+
`rustc`, sometimes you may need to set some of these environment variables
398+
manually. Otherwise, you get an error like the following:
399+
400+
```text
401+
thread 'main' panicked at 'RUSTC_STAGE was not set: NotPresent', library/core/src/result.rs:1165:5
402+
```
403+
404+
If `./stageN/bin/rustc` gives an error about environment variables, that
405+
usually means something is quite wrong -- or you're trying to compile e.g.
406+
`rustc` or `std` or something that depends on environment variables. In
407+
the unlikely case that you actually need to invoke rustc in such a situation,
408+
you can tell the bootstrap shim to print all env variables by adding `-vvv` to your `x.py` command.
409+
410+
### Directories and artifacts generated by `bootstrap`
411+
412+
This is an incomplete reference for the outputs generated by bootstrap:
376413

377414
| Stage 0 Action | Output |
378415
|-----------------------------------------------------------|----------------------------------------------|
@@ -411,27 +448,3 @@ The following tables indicate the outputs of various stage actions:
411448
| copy `rustdoc` | `build/HOST/stage2/bin` |
412449

413450
`--stage=2` stops here.
414-
415-
## Passing stage-specific flags to `rustc`
416-
417-
`x.py` allows you to pass stage-specific flags to `rustc` when bootstrapping.
418-
The `RUSTFLAGS_BOOTSTRAP` environment variable is passed as RUSTFLAGS to the bootstrap stage
419-
(stage0), and `RUSTFLAGS_NOT_BOOTSTRAP` is passed when building artifacts for later stages.
420-
421-
## Environment Variables
422-
423-
During bootstrapping, there are a bunch of compiler-internal environment
424-
variables that are used. If you are trying to run an intermediate version of
425-
`rustc`, sometimes you may need to set some of these environment variables
426-
manually. Otherwise, you get an error like the following:
427-
428-
```text
429-
thread 'main' panicked at 'RUSTC_STAGE was not set: NotPresent', library/core/src/result.rs:1165:5
430-
```
431-
432-
If `./stageN/bin/rustc` gives an error about environment variables, that
433-
usually means something is quite wrong -- or you're trying to compile e.g.
434-
`rustc` or `std` or something that depends on environment variables. In
435-
the unlikely case that you actually need to invoke rustc in such a situation,
436-
you can find the environment variable values by adding the following flag to
437-
your `x.py` command: `--on-fail=print-env`.

0 commit comments

Comments
 (0)