Skip to content

Commit d3a6460

Browse files
committed
rustc-dev-guide: document BOOTSTRAP_TRACING and bootstrap tracing setup
1 parent cd39bb3 commit d3a6460

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

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

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
- [Prologue](./building/bootstrapping/intro.md)
7676
- [What Bootstrapping does](./building/bootstrapping/what-bootstrapping-does.md)
7777
- [How Bootstrap does it](./building/bootstrapping/how-bootstrap-does-it.md)
78+
- [Debugging bootstrap](./building/bootstrapping/debugging-bootstrap.md)
7879

7980
# High-level Compiler Architecture
8081

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Debugging bootstrap
2+
3+
> FIXME: this page could be expanded
4+
5+
## `tracing` in bootstrap
6+
7+
To minimize bootstrap build times, `tracing` in bootstrap is gated behind the `tracing` cargo feature, which in turn is activated by `bootstrap.py` (via `x.py`) if `BOOTSTRAP_TRACING` env var is set.
8+
9+
### Using `tracing` in bootstrap
10+
11+
Due to the conditional compilation via the `tracing` cargo feature, this means that `tracing` usages in bootstrap need to be also gated behind the `tracing` feature:
12+
13+
- `tracing` macros (like `trace!`) and anything from `tracing`, `tracing_subscriber` and `tracing-tree` will need to be gated by `#[cfg(feature = "tracing")]`.
14+
- `tracing`'s `#[instrument(..)]` macro will need to be gated like `#![cfg_attr(feature = "tracing", instrument(..))]`.
15+
16+
### Enabling `tracing` bootstrap feature in rust-analyzer
17+
18+
You can adjust your `settings.json`'s `rust-analyzer.check.overrideCommand` and `rust-analyzer.cargo.buildScripts.overrideCommand` if you want to also enable `logging` cargo feature by default in your editor. This is mostly useful if you want proper r-a completions and such when working on bootstrap itself.
19+
20+
```json
21+
"rust-analyzer.check.overrideCommand": [
22+
"BOOTSTRAP_TRACING=1", // <- BOOTSTRAP_TRACING=1 won't enable tracing filter, but it will activate bootstrap's `tracing` feature
23+
"python3",
24+
"x.py",
25+
"check",
26+
"--json-output",
27+
"--build-dir=build-rust-analyzer"
28+
],
29+
```
30+
31+
```json
32+
"rust-analyzer.cargo.buildScripts.overrideCommand": [
33+
"BOOTSTRAP_TRACING=1", // <- note this
34+
"python3",
35+
"x.py",
36+
"check",
37+
"--json-output",
38+
"--build-dir=build-rust-analyzer"
39+
],
40+
```

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

+2
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,7 @@ In this section, we give a high-level overview of
1717
[what Bootstrap does](./what-bootstrapping-does.md), followed by a high-level
1818
introduction to [how Bootstrap does it](./how-bootstrap-does-it.md).
1919

20+
See also [debugging bootstrap](./debugging-bootstrap.md).
21+
2022
[boot]: https://en.wikipedia.org/wiki/Bootstrapping_(compilers)
2123
[ocaml-compiler]: https://github.com/rust-lang/rust/tree/ef75860a0a72f79f97216f8aaa5b388d98da6480/src/boot

0 commit comments

Comments
 (0)