bazelbuild / bazelbuild/bazel

Add MCDC Flag for Coverage When Using lcov

Open
#26,723 2 comments 0 reactions 0 assignees View on GitHub
P3 team-Rules-CPP type: feature request
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 20h
Merged PRs (30d)
72

Description

### Description of the feature request:

Using Bazel 8.3.1 the `bazel coverage --combined_report=lcov //:target` will generate an lcov like `coverage.dat` file that support line, function, and branch coverages if the program is compiled with the --coverage for g++.

GCC/G++ version 14 introduced the `-fcondition-coverage` instrumentation flag and gcov version 14 has a `--conditions` flag. When these are used MCDC coverage is available, but `bazel coverage` does not seem to support this.

The workaround today is to run `bazel build //:target` followed by `bazel run[or test] //:target` and gather all the `.gcno` and `.gcna` files together capture these with lcov-2.3.1.

### Which category does this issue belong to?

C++ Rules

### What underlying problem are you trying to solve with this feature?

Adding MCDC test coverage to C++ code built with bazel. This is often a requirement for safety critical applications (e.g. aerospace and automotive).

### Which operating system are you running Bazel on?

Ubuntu 24.04

### What is the output of `bazel info release`?

release 8.3.1

### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel.

_No response_

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

```text

```

### Have you found anything relevant by searching the web?

Not to resolve this issue. A lot of tinkering to get the MCDC coverage information by collecting the gcda and gcno files manually.

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

I can share the test repo I setup to work on this if needed, but I think this is pretty self-explanatory. My setup is as follows:

Ubuntu - 24.04
gcc/g++/gocv - 14.2.0
lcov - 2.3.1 (made from source)
bazel - 8.3.1

Contributor guide

Open the contributing guide

Research direction

Start with `bazel coverage --combined_report=lcov //:target` and compare its `coverage.dat` output with lcov 2.3.1 using GCC/G++ 14's `-fcondition-coverage` and gcov's `--conditions` flag. Done means Bazel coverage emits MCDC data alongside line, function, and branch coverage for a C++ target.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
build-system, testing-qa
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
43/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.