Skip to content

Commit 5fb9877

Browse files
committed
Document the process of wrapping rustc
1 parent dec11c2 commit 5fb9877

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

collector/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,3 +450,17 @@ profilers whose results are not affected by system noise (e.g. `callgrind` or `e
450450

451451
`RUST_LOG=debug` can be specified to enable verbose logging, which is useful
452452
for debugging `collector` itself.
453+
454+
455+
## How `rustc` wrapping works
456+
When a crate is benchmarked or profiled, the real `rustc` is replaced with the `rustc-fake` binary,
457+
which parses commands passed from the `collector` and invokes the actual profiling or benchmarking
458+
tool.
459+
460+
Profiling/benchmarking a crate is performed in two steps:
461+
1) Preparation - here all dependencies are compiled and build scripts are executed.
462+
During this step, `cargo` is invoked with `... -- --skip-this-rustc`, which causes `rustc-fake` to skip
463+
compilation of the final/leaf crate. Cargo only passes arguments after `--` to the final crate,
464+
therefore this does not affect the compilation of dependencies.
465+
2) Profiling/benchmarking - `cargo` is invoked with `--wrap-rustc-with <TOOL>`, which executes the
466+
specified profiling tool by `rustc-fake`.

0 commit comments

Comments
 (0)