Skip to content
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

bazel coverage does not work when use with gcc 8.3.0 (when use gcc 4.9.2, it works) #7719

Closed
cztchoice opened this issue Mar 14, 2019 · 8 comments
Labels
coverage P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) team-Rules-CPP Issues for C++ rules type: bug

Comments

@cztchoice
Copy link

cztchoice commented Mar 14, 2019

Description of the problem / feature request:

bazel coverage does not work when use with gcc 8.3.0 (when use gcc 4.9.2, it works)

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

demo: https://github.com/cztchoice/bazel_coverage_demo

git clone https://github.com/cztchoice/bazel_coverage_demo
bazel coverage --combined_report=lcov --coverage_report_generator="@bazel_tools//tools/test/CoverageOutputGenerator/java/com/google/devtools/coverageoutputgenerator:Main"  -- //...

does not generate single .dat file as expected, when compile with gcc 8.3.0

What operating system are you running Bazel on?

What's the output of bazel info release?

CentOS Linux release 7.5.1804 (Core) release 0.21.0

Mac: Build label: 0.23.2-homebrew, has this issue, too
mac gcc version

gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 10.0.0 (clang-1000.11.45.5)
Target: x86_64-apple-darwin18.2.0

What's the output of git remote get-url origin ; git rev-parse master ; git rev-parse HEAD ?

Replace this line with your answer.

Have you found anything relevant by searching the web?

no

Any other information, logs, or outputs that you want to share?

demo: https://github.com/cztchoice/bazel_coverage_demo

root@f2d092ea4ed5 bazel_coverage_demo]# bazel coverage --build_tests_only --test_lang_filters=-py --host_java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8  --instrument_test_targets --coverage_report_generator="@bazel_tools//tools/test/CoverageOutputGenerator/java/com/google/devtools/coverageoutputgenerator:Main" --combined_report=lcov -- //...
INFO: Invocation ID: 6bd84bb4-cb59-477d-9631-c3bb8532a27d
INFO: Using default value for --instrumentation_filter: "//demo/common[/:]".
INFO: Override the above default with --instrumentation_filter
INFO: Analysed target //demo/common:stamp_test (20 packages loaded, 480 targets configured).
INFO: Found 1 test target...
INFO: LCOV coverage report is located at /root/.cache/bazel/_bazel_root/e384d73212b3145fdf4b0efa1c75bb31/execroot/bazel_coverage_demo/bazel-out/_coverage/_coverage_report.dat
 and execpath is bazel-out/_coverage/_coverage_report.dat
INFO: From CoverageReport _coverage/_coverage_report.dat:
Mar 14, 2019 6:44:50 AM com.google.devtools.coverageoutputgenerator.Main getTracefiles
INFO: Found 1 tracefiles.
Mar 14, 2019 6:44:50 AM com.google.devtools.coverageoutputgenerator.Main parseFiles
SEVERE: Parsing file bazel-out/k8-fastbuild/testlogs/demo/common/stamp_test/coverage.dat
Mar 14, 2019 6:44:50 AM com.google.devtools.coverageoutputgenerator.Main getGcovInfoFiles
INFO: No gcov info file found.
Mar 14, 2019 6:44:50 AM com.google.devtools.coverageoutputgenerator.Main getProfdataFileOrNull
INFO: No .profdata file found.
Mar 14, 2019 6:44:50 AM com.google.devtools.coverageoutputgenerator.Main main
WARNING: There was no coverage found.
ERROR: output '_coverage/_coverage_report.dat' was not created
ERROR: not all outputs were created or valid
Target //demo/common:stamp_test up-to-date:
  bazel-bin/demo/common/stamp_test
INFO: Elapsed time: 3.406s, Critical Path: 1.34s
INFO: 2 processes: 2 processwrapper-sandbox.
FAILED: Build did NOT complete successfully
//demo/common:stamp_test                                                 PASSED in 0.3s

Executed 1 out of 1 test: 1 test passes.
There were tests whose specified size is too big. Use the --test_verbose_timeout_warnings command line option to see which ones these are.
All tests passed but there were other errors during the build.
FAILED: Build did NOT complete successfully
[root@f2d092ea4ed5 bazel_coverage_demo]# vim /root/.cache/bazel/_bazel_root/e384d73212b3145fdf4b0efa1c75bb31/execroot/bazel_coverage_demo/bazel-out/_coverage/_coverage_report.dat

expect result(use bazel 0.21 with gcc (GCC) 4.9.2 20150212 (Red Hat 4.9.2-6))

[root@a09de4e0806a bazel_coverage_demo]# bazel coverage  --build_tests_only --test_lang_filters=-py --host_java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8  -
-instrument_test_targets --coverage_report_generator="@bazel_tools//tools/test/CoverageOutputGenerator/java/com/google/devtools/coverageoutputgenerator:Main" --combine
d_report=lcov -- //...
INFO: Invocation ID: adf5991d-bd66-4f73-bc73-d178f58b83de
INFO: Using default value for --instrumentation_filter: "//demo/common[/:]".
INFO: Override the above default with --instrumentation_filter
INFO: Analysed target //demo/common:stamp_test (11 packages loaded, 458 targets configured).
INFO: Found 1 test target...
INFO: LCOV coverage report is located at /root/.cache/bazel/_bazel_root/e384d73212b3145fdf4b0efa1c75bb31/execroot/bazel_coverage_demo/bazel-out/_coverage/_coverage_rep
ort.dat
 and execpath is bazel-out/_coverage/_coverage_report.dat
INFO: From CoverageReport _coverage/_coverage_report.dat:
Mar 14, 2019 6:53:59 AM com.google.devtools.coverageoutputgenerator.Main getTracefiles
INFO: Found 1 tracefiles.
Mar 14, 2019 6:53:59 AM com.google.devtools.coverageoutputgenerator.Main parseFiles
SEVERE: Parsing file bazel-out/k8-fastbuild/testlogs/demo/common/stamp_test/coverage.dat
Mar 14, 2019 6:53:59 AM com.google.devtools.coverageoutputgenerator.Main getGcovInfoFiles
INFO: No gcov info file found.
Mar 14, 2019 6:53:59 AM com.google.devtools.coverageoutputgenerator.Main getProfdataFileOrNull
INFO: No .profdata file found.
Target //demo/common:stamp_test up-to-date:
  bazel-bin/demo/common/stamp_test
INFO: Elapsed time: 47.850s, Critical Path: 3.28s
INFO: 17 processes: 16 processwrapper-sandbox, 1 worker.
INFO: Build completed successfully, 31 total actions
//demo/common:stamp_test                                                 PASSED in 0.4s
  /root/.cache/bazel/_bazel_root/e384d73212b3145fdf4b0efa1c75bb31/execroot/bazel_coverage_demo/bazel-out/k8-fastbuild/testlogs/demo/common/stamp_test/coverage.dat

Executed 1 out of 1 test: 1 test passes.
INFO: Build completed successfully, 31 total actions
@aiuto aiuto added team-Rules-CPP Issues for C++ rules untriaged labels Mar 18, 2019
@scentini scentini added the P2 We'll consider working on this in future. (Assignee optional) label Mar 22, 2019
@yami
Copy link

yami commented Mar 26, 2019

I encountered the same issue. Is there any possible work around?

@iirina
Copy link
Contributor

iirina commented Mar 26, 2019

@cztchoice @yami have you tried running coverage using --incompatible_cc_coverage? This will be the default in the near future.

@cztchoice
Copy link
Author

I hava tried old experimental_cc_coverage, does not work, too.

My workaround is make a soft link to subdir n WORKSPACE folder to make lcov happy. (in collect_cc_coverage.sh)

I also find a bug in LcovParser.java

where

      if (taken.equals(TAKEN)) {
        executionCount = Integer.parseInt(taken);
        wasExecuted = true;
      }

should be to show branch coverage

      if (!taken.equals(TAKEN)) {
        executionCount = Integer.parseInt(taken);
        wasExecuted = true;
      }

@baiwfg2
Copy link

baiwfg2 commented Sep 16, 2019

@cztchoice Hi. What does make a soft link to subdir n WORKSPACE folder to make lcov happy mean ? Could you elaborate on that ?

@EFanZh
Copy link

EFanZh commented Sep 20, 2019

I noticed two problems: #9406 (comment). I think that is the reason why coverage does not work.

@oquenchil oquenchil added P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) and removed P2 We'll consider working on this in future. (Assignee optional) labels Nov 19, 2020
@oquenchil
Copy link
Contributor

Please re-open if this is still an issue.

@iminders
Copy link

MacOS Monterey
bazel:5.2.0
GCC: Apple clang version 14.0.0

Still empty _coverage_report.dat

@bhushan-helloFresh
Copy link

bhushan-helloFresh commented Jul 4, 2023

@iminders Were you able to find a solution to this problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
coverage P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) team-Rules-CPP Issues for C++ rules type: bug
Projects
None yet
Development

No branches or pull requests

10 participants