Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Profile Guided Optimization (PGO) #68

Open
errantmind opened this issue Mar 25, 2021 · 3 comments
Open

Support Profile Guided Optimization (PGO) #68

errantmind opened this issue Mar 25, 2021 · 3 comments
Labels
S-needs-investigation Status: needs investigation

Comments

@errantmind
Copy link

errantmind commented Mar 25, 2021

When building with cargo, using -Z build-std, I cannot generate profiles for PGO

The build fails when it gets to the step where it (attempts to) build core :

`rustc --crate-name core --edition=2018 /home/errant/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C linker-plugin-lto -C codegen-units=1 -C metadata=48bb6e05f939071a -C extra-filename=-48bb6e05f939071a --out-dir /home/errant/dev/projects/faf-epoll/target/x86_64-unknown-linux-gnu/release/deps --target x86_64-unknown-linux-gnu -Z force-unstable-if-unmarked -L dependency=/home/errant/dev/projects/faf-epoll/target/x86_64-unknown-linux-gnu/release/deps -L dependency=/home/errant/dev/projects/faf-epoll/target/release/deps --cap-lints allow -Ctarget-cpu=native -Clinker=/usr/bin/clang-12 -Clink-arg=-fuse-ld=lld-12 -Clto=thin -Cembed-bitcode=yes -Copt-level=3 -Ccodegen-units=1 -Cprofile-generate=/home/errant/dev/projects/faf-epoll/prof`
error: `profiler_builtins` crate (required by compiler options) is not compatible with crate attribute `#![no_core]
@errantmind errantmind changed the title Build fails with RUSTFLAG -Cprofile-generate (PGO) Build fails with RUSTFLAG -Cprofile-generate Mar 25, 2021
@12101111
Copy link

This is not possible currently.

profiler_builtins is no_std crate, so it need a core(the prebuilt one).

But rustc don't allow link two core:

// Since libcore defines many fundamental lang items, all tests live in a
// separate crate, libcoretest, to avoid bizarre issues.
//
// Here we explicitly #[cfg]-out this whole crate when testing. If we don't do
// this, both the generated test artifact and the linked libtest (which
// transitively includes libcore) will both define the same set of lang items,
// and this will cause the E0152 "found duplicate lang item" error. See
// discussion in #50466 for details.
//
// This cfg won't affect doc tests.

@12101111
Copy link

Related PR: rust-lang/rust#79958

@errantmind
Copy link
Author

Alright, thanks for the explanation. It would be helpful to have this feature at some point

@ehuss ehuss changed the title (PGO) Build fails with RUSTFLAG -Cprofile-generate Support Profile Guided Optimization (PGO) May 3, 2023
@ehuss ehuss added the S-needs-investigation Status: needs investigation label May 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-needs-investigation Status: needs investigation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants