-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Coverage on macOS doesn't work with BAZEL_USE_CPP_ONLY_TOOLCHAIN #14970
Comments
This works around bazelbuild/bazel#14970.
@c-mita Can you triage? |
There's a |
That doesn't seem to have any effect in my case. It looks like this variable is only used to modify compilation flags ( bazel/tools/cpp/unix_cc_configure.bzl Line 265 in 34ce6a2
|
Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 90 days unless any other activity occurs or one of the following labels is added: "not stale", "awaiting-bazeler". Please reach out to the triage team ( |
I'm quite sure this is still happening. In fact, with Bazel 7 (after bazelbuild/apple_support#113), the C++-only toolchain is enabled by default, so coverage support on macOS is now broken by default (when not using |
After experimenting a bit, I managed to at least create something that looks like a valid coverage.dat file on macOS with Bazel 7:
Here, /tmp/llvm-cov is a script like this:
The system llvm-cov appears to always write absolute filenames, and the merger tool will filter them out because they are not listed literally in the instrumented files. Maybe the |
Passing |
bazel/tools/cpp/unix_cc_configure.bzl Lines 254 to 262 in d5577e6
I don't see how bazel is supposed to be discovering llvm-cov and llvm-profdata, seems like there might need to be a fix there. |
ack, thanks
Maybe I'm missing something, but wouldn't that just be |
Yea it could be, but right now the tools are wired through some environment variables |
Yes, that works, thanks! So to summarize, to make llvm-cov coverage work on macOS, the following .bazelrc lines serve as a workaround:
|
Looks like in the meantime more hacks have become necessary. Specifically:
The |
Description of the problem / feature request:
When using the non-Xcode C++ toolchain (BAZEL_USE_CPP_ONLY_TOOLCHAIN=1), coverage generation doesn't seem to work at all.
Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
BUILD file:
lib.h:
lib.cc:
test.cc:
Then, run
No coverage instrumentation is generated, and the output contains an error message from gcov:
Apparently collect_cc_coverage.sh attempts to call
gcov merge -output
, which doesn't work - this should use llvm-cov instead or something else.What operating system are you running Bazel on?
macOS 12.2.1
What's the output of
bazel info release
?release 5.0.0-homebrew
What's the output of
git remote get-url origin ; git rev-parse master ; git rev-parse HEAD
?Nothing (not in a Git repository)
Have you found anything relevant by searching the web?
#10457 is somewhat related (albeit a bit pessimistic; coverage on macOS does work in general), but doesn't seem to touch on this specific bug.
Any other information, logs, or outputs that you want to share?
test.log
The text was updated successfully, but these errors were encountered: