Skip to content

-Cprofile-use cannot find file depending on RUSTFLAGS order #128476

@TheIronBorn

Description

@TheIronBorn

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-PGOArea: Profile-guided optimizations (PGO)C-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions