Skip to content

-Z profile fails to produce any .gcno/.gcda files for bench target #72974

New issue

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

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

Already on GitHub? # to your account

Closed
mzabaluev opened this issue Jun 4, 2020 · 5 comments
Closed

-Z profile fails to produce any .gcno/.gcda files for bench target #72974

mzabaluev opened this issue Jun 4, 2020 · 5 comments
Labels
A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) A-diagnostics Area: Messages for errors, warnings, and lints A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools A-lints Area: Lints (warnings about flaws in source code) such as unused_mut.

Comments

@mzabaluev
Copy link
Contributor

mzabaluev commented Jun 4, 2020

I want to generate profiling coverage information for a benchmark in my project. I run this command:

RUSTFLAGS='-Z profile=yes -Z profile-emit=/tmp/myproject-profile -C codegen-units=1' cargo build --benches -Z unstable-options --profile=bench --target=x86_64-unknown-linux-gnu

Neither the build nor running the bench executable creates .gcno/.gcda files with the coverage information. Also tried without profile-emit.

Tried to instrument cargo test for comparison, that results in a build failure:

     Running `rustc --crate-name chunked_bytes --edition=2018 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -Cembed-bitcode=no -C debuginfo=2 -C metadata=acf3ef1e1fe2447e -C extra-filename=-acf3ef1e1fe2447e --out-dir /home/mzabaluev/work/rust/chunked-bytes/target/x86_64-unknown-linux-gnu/debug/deps --target x86_64-unknown-linux-gnu -C incremental=/home/mzabaluev/work/rust/chunked-bytes/target/x86_64-unknown-linux-gnu/debug/incremental -L dependency=/home/mzabaluev/work/rust/chunked-bytes/target/x86_64-unknown-linux-gnu/debug/deps -L dependency=/home/mzabaluev/work/rust/chunked-bytes/target/debug/deps --extern bytes=/home/mzabaluev/work/rust/chunked-bytes/target/x86_64-unknown-linux-gnu/debug/deps/libbytes-fcec2a592652b77a.rmeta -Z profile=yes -Z profile-emit=/tmp/chunked-bytes-profile -C codegen-units=1`
error: can't instrument with gcov profiling when compiling incrementally

The -C incremental=... option cannot be suppressed by disabling incremental in the test profile in .cargo/config.toml.

Edit: the cargo test failure was solved, I used a custom target to which config did not apply. That build does try to produce GCDAs and fails in some build script executable, but I guess it's a subject for a different issue.

Meta

rustc --version --verbose:

rustc 1.45.0-nightly (56daaf669 2020-06-03)
binary: rustc
commit-hash: 56daaf669ebc3d5083db5cded719f780dc31104e
commit-date: 2020-06-03
host: x86_64-unknown-linux-gnu
release: 1.45.0-nightly
LLVM version: 10.0
@mzabaluev mzabaluev added the C-bug Category: This is a bug. label Jun 4, 2020
@mzabaluev
Copy link
Contributor Author

Tracking issue for the feature: #42524

@mzabaluev mzabaluev changed the title -Z profile fails to produce any .gcno/.gcda files for bench target, fails build with cargo test -Z profile fails to produce any .gcno/.gcda files for bench target Jun 4, 2020
@ehuss
Copy link
Contributor

ehuss commented Jun 4, 2020

I think profiling requires debuginfo. Try setting this in Cargo.toml:

[profile.bench]
debug = true

[profile.release]
debug = true

I'm not sure how well it will work with an optimized build, though. You may want to consider using the dev profile instead (and setting incremental=0).

@mzabaluev
Copy link
Contributor Author

The compiler could have put out a warning about the options being incompatible.

@link2xt
Copy link

link2xt commented Aug 6, 2022

An option -Cdebuginfo=2 should be documented in https://doc.rust-lang.org/unstable-book/compiler-flags/profile.html then.

Had to add it here: chatmail/core#3546

@fmease fmease added A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools and removed C-bug Category: This is a bug. needs-triage-legacy labels Jan 25, 2024
tbro added a commit to EspressoSystems/espresso-network that referenced this issue Mar 13, 2024
tbro added a commit to EspressoSystems/espresso-network that referenced this issue Mar 14, 2024
Adds coverage.yaml and ads coverage shell to flake. also adds
code-coverage command to justfile.

NOTE: for rational of `-Cdebuginfo=2` see:
rust-lang/rust#72974

Closes #683
tbro added a commit to EspressoSystems/espresso-network that referenced this issue Mar 14, 2024
Adds coverage.yaml and ads coverage shell to flake. also adds
code-coverage command to justfile.

NOTE: for rational of `-Cdebuginfo=2` see:
rust-lang/rust#72974

Closes #683
tbro added a commit to EspressoSystems/espresso-network that referenced this issue Mar 15, 2024
Add coverage workflow

  *  Adds coverage.yaml 
  *  adds coverage shell to flake. also
  *  adds code-coverage command (for local output to HTML) to justfile.

NOTE: for rational of `-Cdebuginfo=2` see:
rust-lang/rust#72974

Closes #683 

---------

Co-authored-by: tbro <tbro@users.noreply.github.com>
Co-authored-by: sveitser <sveitser@gmail.com>
@workingjubilee
Copy link
Member

We no longer support gcov-based profiling.

@workingjubilee workingjubilee closed this as not planned Won't fix, can't repro, duplicate, stale Nov 9, 2024
@workingjubilee workingjubilee added A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) and removed T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 9, 2024
@fmease fmease added A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. and removed A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. labels Dec 21, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) A-diagnostics Area: Messages for errors, warnings, and lints A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools A-lints Area: Lints (warnings about flaws in source code) such as unused_mut.
Projects
None yet
Development

No branches or pull requests

6 participants