Skip to content

Commit ca8f1d7

Browse files
HadrienG2steveklabnik
authored andcommitted
Fix profile directory in crate graph self-profiling example
In the rustc self-profiling blog post, the proposed crate graph-wide self-profiling command is incorrect. ```sh $ RUSTFLAGS="-Zself-profile=./profiles -Zself-profile-events=default,args" cargo build ``` The problem is that the `./profiles` relative directory will be resolved with respect to whatever directory rustc happens to be working in at the time where the RUSTFLAGS are parsed. Which, for dependency crates, will be the source directory of those dependencies, not the source directory of the crate that we are working on. Forcing directory resolution to be relative to the active crate's directory by replacing the rustc-evaluated `.` with a shell-evaluated `$(pwd)` resolves this problem. Kudos to @bjorn3 for figuring this out!
1 parent f9c3749 commit ca8f1d7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

posts/inside-rust/2020-02-25-intro-rustc-self-profile.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ Since this will create a lot of files, we'll tell `rustc` to create a folder to
213213
```sh
214214
$ rm regex-17088.* regex-23649.* # clean up the old trace files since we're done with them
215215
$ cargo clean
216-
$ RUSTFLAGS="-Zself-profile=./profiles -Zself-profile-events=default,args" cargo build
216+
$ RUSTFLAGS="-Zself-profile=$(pwd)/profiles -Zself-profile-events=default,args" cargo build
217217
```
218218

219219
This creates quite a few trace files in the working directory.

0 commit comments

Comments
 (0)