Skip to content

Commit

Permalink
Use llvm-args instead of RUST_TEST_THREADS
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed May 13, 2023
1 parent 752a20e commit 637b492
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions .github/.cspell/project-dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ doctestbins
easytime
fcoverage
fprofile
instrprof
libdir
libhello
microkernel
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com

## [Unreleased]

- cargo-llvm-cov no longer sets the `RUST_TEST_THREADS` environment variable and uses llvm-args instead for workaround [rust-lang/rust#91092](https://github.com/rust-lang/rust/issues/91092).

## [0.5.19] - 2023-04-28

- Fix handling of `--cargo-profile` option for `cargo llvm-cov nextest`. ([#269](https://github.com/taiki-e/cargo-llvm-cov/pull/269))
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ pacman -S cargo-llvm-cov

- Branch coverage is not supported yet. See [#8] and [rust-lang/rust#79649] for more.
- Support for doc tests is unstable and has known issues. See [#2] and [rust-lang/rust#79417] for more.
- All the tests are run with `RUST_TEST_THREADS=1` to work around [rust-lang/rust#91092]. You can pass `--test-threads` (e.g., `--test-threads=$(nproc)`) to override this behavior. (As for `nextest`, we also set `NEXTEST_TEST_THREADS=1`.)
- `cargo llvm-cov nextest` is run with `NEXTEST_TEST_THREADS=1` to work around [rust-lang/rust#91092]. You can pass `--test-threads` (e.g., `--test-threads=$(nproc)`) to override this behavior.

See also [the code-coverage-related issues reported in rust-lang/rust](https://github.com/rust-lang/rust/labels/A-code-coverage).

Expand Down
4 changes: 2 additions & 2 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,10 +358,10 @@ impl Args {
// build options
Short('r') | Long("release") => parse_flag_passthrough!(release),
Long("profile") if subcommand != Subcommand::Nextest => {
parse_opt_passthrough!(profile)
parse_opt_passthrough!(profile);
}
Long("cargo-profile") if subcommand == Subcommand::Nextest => {
parse_opt_passthrough!(profile)
parse_opt_passthrough!(profile);
}
Long("target") => parse_opt_passthrough!(target),
Long("coverage-target-only") => parse_flag!(coverage_target_only),
Expand Down
6 changes: 4 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,10 @@ fn set_env(cx: &Context, env: &mut dyn EnvTarget, IsNextest(is_nextest): IsNexte
flags.push("codegen-units=1");
}
}
// Workaround for https://github.com/rust-lang/rust/issues/91092
// TODO: skip passing this on newer nightly that includes https://github.com/rust-lang/rust/pull/111469.
flags.push("-C");
flags.push("llvm-args=--instrprof-atomic-counter-update-all");
if !cx.args.cov.no_cfg_coverage {
flags.push("--cfg=coverage");
}
Expand Down Expand Up @@ -283,8 +287,6 @@ fn set_env(cx: &Context, env: &mut dyn EnvTarget, IsNextest(is_nextest): IsNexte
}
env.set("LLVM_PROFILE_FILE", llvm_profile_file.as_str())?;
env.set("CARGO_INCREMENTAL", "0")?;
// Workaround for https://github.com/rust-lang/rust/issues/91092
env.set("RUST_TEST_THREADS", "1")?;
if is_nextest {
// Same as above
env.set("NEXTEST_TEST_THREADS", "1")?;
Expand Down

0 comments on commit 637b492

Please sign in to comment.