taiki-e / cargo-llvm-cov

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

Error when specifying LLVM tools that are incompatible with LLVM version of rustc (Homebrew LLVM 17.0.6 vs rustc 1.78.0-beta -- LLVM 18.1.2) #362

Closed chenrui333 closed 5 months ago

chenrui333 commented 6 months ago

👋 trying to build the latest release, but run into some build issue. The error log is as below:

error build log ``` warning: /private/tmp/cargo-llvm-cov-test-20240405-7325-d19qwd/hello_world/target/llvm-cov-target/hello_world-7432-18405259991488819850_0.profraw: raw profile version mismatch: Profile uses raw profile format version = 9; expected version = 8 PLEASE update this tool to version in the raw profile, or regenerate raw profile with expected version. error: no profile can be merged error: failed to merge profile data: process didn't exit successfully: `/opt/homebrew/opt/llvm/bin/llvm-profdata merge -sparse -f /private/tmp/cargo-llvm-cov-test-20240405-7325-d19qwd/hello_world/target/llvm-cov-target/hello_world-profraw-list -o /private/tmp/cargo-llvm-cov-test-20240405-7325-d19qwd/hello_world/target/llvm-cov-target/hello_world.profdata` (exit status: 1)v ```

full build log, https://github.com/Homebrew/homebrew-core/actions/runs/8569786799/job/23486580652 relates to Homebrew/homebrew-core#168103

taiki-e commented 6 months ago

The behavior changes included in this release only change a case that previously resulted in an error (https://github.com/taiki-e/cargo-llvm-cov/pull/360), so I guess the problem is most likely a mismatch between the LLVM version of LLVM tools and the LLVM version of rustc.

IIUC, CI using rustc beta (LLVM 18.1.2) and Homebrew LLVM 17.0.6. (When 0.6.8 was tested they were probably both LLVM 17.)

Considering that it appears that CI uses rustup to install rustc, a reasonable solution to this would be to remove llvm-tools-related environment variables and use llvm-tools-preview, which is distributed via rustup. Alternatively, using stable rustc instead of beta for testing would also work. The latter does not address the underlying problem, though.


By the way, the title of this issue is "build failure", but it appears that it is the test that is actually failing.

taiki-e commented 6 months ago

(Unrelated to this issue, but it appears that homebrew-core uses the crate generated by cargo new --bin to test. Since the crate generated that way does not contain any test, I think it would be better to use the crate generated by cargo new --lib.)

chenrui333 commented 5 months ago

IIUC, CI using rustc beta (LLVM 18.1.2) and Homebrew LLVM 17.0.6. (When 0.6.8 was tested they were probably both LLVM 17.)

I was thinking the same. Thanks for confirming it.

By the way, the title of this issue is "build failure", but it appears that it is the test that is actually failing.

oh, that is mainly it is because I think it is build related as it is a version bump (which caused the test failure)

chenrui333 commented 5 months ago

(Unrelated to this issue, but it appears that homebrew-core uses the crate generated by cargo new --bin to test. Since the crate generated that way does not contain any test, I think it would be better to use the crate generated by cargo new --lib.)

that makes sense to me, do you want to take on a PR to do the update :)

taiki-e commented 5 months ago

Filed https://github.com/Homebrew/homebrew-core/pull/168319 to fix.

taiki-e commented 5 months ago

The problem on the Homebrew side has been fixed in https://github.com/Homebrew/homebrew-core/pull/168319 & cargo-llvm-cov documentation has also been updated and a note on compatibility when setting LLVM_* env vars has been duplicated in an easy-to-find place (https://github.com/taiki-e/cargo-llvm-cov/commit/fa229e3787c33746249ae860984df4671676c4c1).