rust-lang / rust-lang/rust

-Cprofile-use cannot find file depending on RUSTFLAGS order

Open
#128,476 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-PGO C-bug T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

I tried this code:

RUSTFLAGS="-Cprofile-use=$ABS_PATH -Cllvm-args=-pgo-warn-missing-function -Ctarget-cpu=native -Ztune-cpu=native -Clink-arg=-fuse-ld=lld -Zthreads=4 -Ccodegen-units=1 -Cpanic=abort -Clto=fat"
cargo build --release --target=<target>

and I get

  process didn't exit successfully: `<path>\bin\rustc.exe - --crate-name 
___ --print=file-names -Cprofile-use=<abs_path>
-Cllvm-args=-pgo-warn-missing-function -Ctarget-cpu=native -Ztune-cpu=native -Clink-arg=-fuse-ld=lld -Zthreads=4 -Ccodegen-units=1 
-Cpanic=abort -Clto=fat --target <target> --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib 
--crate-type staticlib --crate-type proc-macro --print=sysroot --print=split-debuginfo --print=crate-name --print=cfg` (exit code: 1)
<snip>
  --- stderr
  error: file `<abs_path>` passed to `-C profile-use` does not exist

If I instead change the order of RUSTFLAGS, putting the PGO stuff at the end:

RUSTFLAGS="-Ctarget-cpu=native -Ztune-cpu=native -Clink-arg=-fuse-ld=lld -Zthreads=4 -Ccodegen-units=1 -Cpanic=abort -Clto=fat -Cprofile-use=<abs_path> -Cllvm-args=-pgo-warn-missing-function"

compilation succeeds

I have verified that the file exists. Both the path I provided and the path reported by the error. I even verified with Path::new(abs_path).exists()

I apologize that I couldn't find a more minimal example.

Meta

rustc --version --verbose:

rustc 1.82.0-nightly (f8060d282 2024-07-30)
binary: rustc
commit-hash: f8060d282d42770fadd73905e3eefb85660d3278
commit-date: 2024-07-30
host: x86_64-pc-windows-msvc
release: 1.82.0-nightly
LLVM version: 18.1.7

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the report on Windows with rustc 1.82.0-nightly and the shown RUSTFLAGS, using cargo build --release --target=. Compare the failing and successful flag orders and verify the profile-use path handling; done when both orders accept the existing profile file or the behavior is documented with a focused regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.