Kobzol / cargo-pgo

Cargo subcommand for optimizing Rust binaries/libraries with PGO and BOLT.
MIT License
573 stars 11 forks source link

Difference between "cargo bench" and "cargo pgo bench" #44

Closed zamazan4ik closed 10 months ago

zamazan4ik commented 10 months ago

Not sure if is it an issue with cargo-pgo or not - I'll just put it here to share with other people.

During the PGO optimization for https://github.com/gorules/zen/ project, I found that cargo bench --workspace works fine (builds all required targets successfully and performs the required benchmarks) but during the cargo pgo bench -- --workspace I get the following linking errors: https://gist.github.com/zamazan4ik/176517dd1d5bb7dc07c92e13016dfd8d

I'm not sure what is the reason for the difference in behavior between these two almost the same commands. Maybe some custom build.rs rules are the root cause of the problem.

Kobzol commented 10 months ago

I tried it locally and it fails because of -Cprofile-generate. If you add it to cargo bench --workspace on that project, it fails with the same linker errors. I'm not sure how to easily display linking commands used by Cargo when the compilation succeeds, to diff what is different vs -Cprofile-generate.

zamazan4ik commented 10 months ago

I tried it locally and it fails because of -Cprofile-generate

Hmm, sounds interesting why it fails due to this. Since cargo-pgo is not the reason here (honestly, I expected it), what will be the right place to report the issue? Rustc upstream repo? As far as I understand, it isn't normal behavior.

Kobzol commented 10 months ago

Yes, this looks like a rustc issue.

zamazan4ik commented 10 months ago

Okay, in this case, I'll create the issue in the upstream.

If you think there is nothing to do with this issue from the cargo-pgo side, I think you can close the issue. Thank you!