taiki-e / cargo-llvm-cov

Cargo subcommand to easily use LLVM source-based code coverage (-C instrument-coverage).
Apache License 2.0
933 stars 57 forks source link

Improve clarity in docs around use of no_coverage and toolchain on Windows #254

Open fgimian opened 1 year ago

fgimian commented 1 year ago

Hey there, thanks so much for your incredible work on this tool.

Just noticed two things as a new user of this tool on Windows:

And as two follow-ups to these points:

Thanks heaps Fotis

taiki-e commented 1 year ago
  • Is it possible to get this tool working on the GNU toolchain for Windows?

It might work with the proper linker and linker args (e.g., https://github.com/rust-lang/rust/issues/79555#issuecomment-934198838), but I have not tested it.

  • Is there a way to specify no_coverage on stable Rust? The tool itself works perfectly on stable Rust but the no_coverage attribute is simply ignored and not taken into account

The reason it is ignored on stable is that the code generated by coverage-helper uses the cfg_attr(coverage_nightly, ..) attribute and cargo-llvm-cov sets coverage_nightly cfg only on nightly. However, you can manually set it.

RUSTC_BOOTSTRAP=1 RUSTFLAGS='--cfg coverage_nightly' cargo llvm-cov 

RUSTC_BOOTSTRAP is something like a hack that disables stability checks, so we do not officially recommend using it.

fgimian commented 1 year ago
  • Is it possible to get this tool working on the GNU toolchain for Windows?

It might work with the proper linker and linker args (e.g., rust-lang/rust#79555 (comment)), but I have not tested it.

  • Is there a way to specify no_coverage on stable Rust? The tool itself works perfectly on stable Rust but the no_coverage attribute is simply ignored and not taken into account

The reason it is ignored on stable is that the code generated by coverage-helper uses the cfg_attr(coverage_nightly, ..) attribute and cargo-llvm-cov sets coverage_nightly cfg only on nightly. However, you can manually set it.

RUSTC_BOOTSTRAP=1 RUSTFLAGS='--cfg coverage_nightly' cargo llvm-cov 

RUSTC_BOOTSTRAP is something like a hack that disables stability checks, so we do not officially recommend using it.

Awesome stuff, thank you so much for the reply! 😄

taiki-e commented 1 year ago

(upstream issue about bug with windows-gnu toolchain: https://github.com/rust-lang/rust/issues/111098)