Open
Description
git clone https://github.com/matthiaskrgr/cargo-cache
cd cargo-cache
RUSTFLAGS="-Cprofile-generate=target/pgodata" cargo build --release
./target/release/cargo-cache
./target/release/cargo-cache
./target/release/cargo-cache q hello
./target/release/cargo-cache r
./target/release/cargo-cache --top-cache-items 10
llvm-profdata merge -o target/merged.profdata ./target/pgodata/
file target/merged.profdata
# target/merged.profdata: LLVM indexed profile data, version 5
RUSTFLAGS="-Cprofile-use=target/merged.profdata" cargo build --release -j 1
Compiling serde v1.0.98
error: File `target/merged.profdata` passed to `-C profile-use` does not exist.
error: aborting due to previous error
error: Could not compile `serde`.
To learn more, run the command again with --verbose.
The file is definitely there, but for some reason it is not found??
rustc 1.38.0-nightly (c43d03a19 2019-08-14)
Metadata
Metadata
Assignees
Labels
Area: Profile-guided optimizations (PGO)Area: Messages for errors, warnings, and lintsArea: Compiler frontend (errors, parsing and HIR)Category: An issue proposing an enhancement or a PR with one.Relevant to the cargo team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
jonas-schievink commentedon Aug 15, 2019
Does it work when specifying an absolute path? Maybe Cargo runs rustc in an unexpected working dir.
matthiaskrgr commentedon Aug 15, 2019
Oh that works, weird...
matthiaskrgr commentedon Aug 15, 2019
I would suggest the following:
if the path is absolute and works, use it.
If the path is relative but exists, print an error but suggest using its absolute path/form.
Otherwise throw an error as before.
jonas-schievink commentedon Aug 15, 2019
Nit: The error message should also be changed to start with a lowercase letter (so "file" instead of "File")
matthiaskrgr commentedon Aug 15, 2019
It is also strange that
-Cprofile-generate
works with relative paths but-Cprofile-use
does not..Maybe that should be consistent somehow...
jonas-schievink commentedon Aug 15, 2019
I believe
-Cprofile-generate
will just write the relative dir into the binary, so wherever you run the binary it will write to that path (ie. rustc never needs to do any IO with that path). If you run rustc by hand relative paths should work fine with-Cprofile-use
though.Oh and the rustc book mentions this:
nazar-pc commentedon May 7, 2023
I get an error with absolute path instead of some reason:
The file certainly exists 😕
caizixian commentedon Sep 1, 2023
Possibly related #115344