grcov for Multi-Format Rust Coverage Reports
Rust tool to collect and aggregate code coverage data for multiple source files
At a glance
- What is it?
- grcov aggregates Rust, C, C++, JavaScript, Go, Java, and Kotlin coverage data into local or CI-ready reports. It suits instrumented projects that need several outputs from one collection tool.
- Who is it for?
- grcov fits Rust and polyglot projects that already produce LLVM, GCC, lcov, Go `out`, or JaCoCo artifacts and need several report formats. It is not a coverage instrumentation library, and the README does not document rollback.
- Can I use it commercially?
- Yes, with conditions. MPL-2.0 is a weak copyleft licence: you can use it inside commercial and closed-source software, but if you distribute changes to its own files, you must publish those changes under the same licence.
- Is it still maintained?
- Yes. The repository last received commits 4 days ago.
- What is it written in?
- Mainly Rust, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on October 23, 2026, and from our analysis. They are not legal advice.
Editorial analysis
Why Mozilla Built grcov for Firefox Coverage
grcov addresses the reporting side of code coverage. A compiler or test run can produce raw coverage artifacts, but those artifacts are often split across files and do not necessarily form a report that a person or coverage service can consume directly. grcov collects and aggregates coverage information for multiple source files, then renders it in a selected output format.
The project was initiated by Mozilla to gather Firefox coverage results, which explains its support for both language-specific instrumentation and delivery formats. The README documents `.profraw` and `.gcda` files generated by LLVM, Clang, or GCC. It also accepts lcov files for JavaScript coverage, `out` files for Go, and JaCoCo files for Java and Kotlin.
This makes grcov relevant to engineers working across languages within one repository, particularly when tests are already instrumented but each toolchain emits a different artifact. It is not a replacement for a coverage library or test runner. The user still has to build the code with instrumentation, execute the relevant tests, locate the resulting artifacts, and match their source paths to the checkout being analyzed.
How grcov Connects Artifacts to Source Files
The command takes one or more input paths. grcov inspects the coverage data found there, resolves the covered code to source files, and combines those records before rendering output. Rust builds have an extra dependency on compiled binary metadata because the coverage artifact can contain symbol and address information that must be associated with the executable. The `-b, --binary-path <PATH>` option identifies that binary, while `-s, --source-dir <DIRECTORY>` establishes the root of the source tree.
Coverage data can also travel between build machines. When absolute paths do not match the current checkout, `-p, --prefix-dir <PATH>` removes a prefix from recorded paths. There is also `--path-mapping <PATH>` for explicit path mapping. If a report refers to a source file that is unavailable locally, `--ignore-not-existing` excludes that file. The README does not explain the exact precedence between every path-normalization option, so these settings should be selected deliberately rather than stacked without checking the resulting paths.
The format selection is explicit through `--output-types`, or `-t` for short form. Supported outputs include HTML, Coveralls, lcov INFO, recursive JSON, ActiveData-ETL, file lists, Markdown, Cobertura, and pretty-printed Cobertura. With multiple output types, `--output-path`, or `-o`, must name a directory. With one output type, it can identify the output file. This separation supports both a browsable local report and machine-oriented CI output.
Installing grcov and Preparing a Rust Coverage Build
The README offers release downloads and a Cargo installation path for users who already have Rust installed. The latter installs the published `grcov` package from crates.io.
cargo install grcovFor the documented Rust source-coverage workflow, first install the `llvm-tools` component through `rustup`:
rustup component add llvm-toolsCoverage must then be enabled while Rust builds the project. The README sets `RUSTFLAGS` to request instrumentation:
export RUSTFLAGS="-Cinstrument-coverage"With that environment variable in place, the normal Cargo build is the next documented operation:
cargo buildThe README then explains that every test run should receive separate profile information by defining `LLVM_PROFILE_FILE`, with `%p` replaced by the process ID and `%m` by the binary signature. The excerpt in the README ends while describing that environment variable, so the full assignment and subsequent report-generation command are not documented there. Inventing either would risk creating collisions or selecting the wrong coverage directory.
This omission defines the boundary for a first verified use. Installation and build stages are documented, but a complete reproducible tutorial cannot be reconstructed from that incomplete example. The remaining configuration should be copied from the current README's Rust example before running tests and invoking grcov.
Generating Reports for Local Review and CI Services
Once coverage artifacts exist, grcov is driven by input paths and output options. HTML is intended for human review, Markdown is described as easy to read, and lcov, JSON, Cobertura, and Coveralls serve different consumers. `--precision <NUMBER>` controls decimal precision and defaults to `2`.
Coveralls output requires a repository token passed with `--token <TOKEN>`. Additional metadata can identify the commit with `--commit-sha <COMMIT HASH>`, the branch with `--vcs-branch <VCS BRANCH>`, and a pull request with `--service-pull-request <SERVICE PULL REQUEST>`. The branch option defaults to `master`. These fields matter for services that associate a report with a particular revision, so uploading a coverage file without matching commit metadata can weaken the usefulness of the result.
For an HTML artifact, `-o` should refer to a file because it is a single output type. Multiple requested formats require a folder. A `--output-config-file <PATH>` can supply renderer configuration when a format needs it. The README also documents hosting HTML reports and using coverage badges, but it does not give a complete hosting configuration there. A specific host, directory permission, or URL pattern therefore cannot be inferred.
Filtering Coverage Without Hiding Path Mismatches
grcov can remove files from the final report with `--ignore <PATH>` and restrict it with `--keep-only <PATH>`. Both accept globs, which supports policies such as excluding generated code or focusing on a package. For broader report views, `--filter <FILTER>` accepts `covered` or `uncovered`. This is useful when a developer wants a list or report containing only one category, although it changes the denominator represented by the output and should not be treated as a neutral presentation option.
Branch coverage requires `--branch`. Source regions can be removed through `--excl-line <regex>`, `--excl-start <regex>`, and `--excl-stop <regex>`. Separate branch exclusion controls exist as `--excl-br-line <regex>`, `--excl-br-start <regex>`, and `--excl-br-stop <regex>`. Region markers are more precise than excluding entire files, but incorrect patterns can hide valid coverage.
LLVM-only input can use `--llvm`, which the command reference says speeds up parsing when coverage information comes exclusively from an LLVM build. `--no-demangle` disables symbol demangling. `--threads <NUMBER>` exposes a thread count, and `--parallel` changes the build type used for Coveralls formats. These switches address different stages, not a single universal performance setting. The README supplies no workload-specific thread guidance or memory limits.
Windows Paths, Build Symbols, and Report Boundaries
Path correctness is grcov's most consequential constraint. Coverage records generated on another machine may contain directory names that differ from the local checkout. `--prefix-dir` handles a removable prefix, `--path-mapping` supplies a mapping, and `--ignore-not-existing` drops unresolved files. The last option keeps report generation moving, but it can conceal a faulty build environment. A successful command does not prove that every recorded source file was resolved.
Compiled-code coverage can also depend on the matching executable. The command interface requires `-b` when the input needs a compiled binary. A binary from another build, architecture, or commit can produce incorrect symbol interpretation. The README includes a section titled "Enabling symlinks on Windows," confirming that source or report layout can require operating-system setup, although its commands are not reproduced here.
grcov also has different symbol-demangling features in `Cargo.toml`. The default features include `deflate-zlib-rs` and `demangle-no-swift`. A `demangle-with-swift` feature adds Swift demangling, while `deflate-zlib` changes the zlib implementation and `tc` enables tcmalloc. This configuration surface matters for binary compatibility and artifact handling. The README does not state that ordinary Rust source coverage needs these alternatives, so changing Cargo features should follow a concrete format or symbol requirement.
grcov Compared with Direct Toolchain Reporting
The practical alternative is to keep each toolchain's native reporting path and send its result directly to the selected CI service. LLVM tooling can work with Rust-oriented coverage workflows, while GCC-oriented C and C++ builds can use GCC's own ecosystem. Java and Kotlin projects already produce JaCoCo, and Go projects emit `out` files. In a single-language repository with one established service integration, adding grcov may duplicate reporting behavior that the build already handles.
grcov has a different role when one aggregation point must accept LLVM, GCC, lcov, Go `out`, and JaCoCo inputs. It also lets the same set of coverage records produce HTML, Markdown, lcov INFO, recursive JSON, Cobertura, ActiveData-ETL, or Coveralls output. Direct toolchain and service integrations avoid this translation layer, but the README does not enumerate their individual configuration steps, so the comparison remains architectural.
The project is most useful as a reporting adapter, not as instrumentation infrastructure. If the requirement is merely to collect one well-supported format for one language, a direct service integration may be simpler. If the requirement is cross-format aggregation and multiple outputs from one command, grcov addresses a specific reporting need.
Maintenance, Releases, and the MPL-2.0 Boundary
The repository is not archived, and the last push was on 2026-10-13. Recent tagged releases include v0.10.8 on 2026-09-11, v0.10.7 on 2026-03-03, and v0.10.6 on 2026-03-03. The repository's `Cargo.toml` identifies the current package version as `0.10.8` and lists Rust 2018 as its edition.
The package is licensed under MPL-2.0, and the repository entry `LICENSE-MPL-2.0` contains that license. The documented installation sources are GitHub releases and crates.io, so a project can control when it changes versions rather than always tracking the default branch. Upgrade cost still includes checking artifact compatibility, output changes, renamed or deprecated command-line options, and Cargo feature differences that affect symbols or compression.
The command-line reference includes deprecated Clap features at the dependency level, but the README does not document a grcov migration or rollback procedure. It links to minimum requirements, build, and test sections, although the displayed content does not explain them. Before replacing an existing coverage job, check the current release's CLI and artifact compatibility against the toolchains and report sinks used by that job.
Editorial conclusion
grcov fits Rust and polyglot projects that already produce LLVM, GCC, lcov, Go `out`, or JaCoCo artifacts and need several report formats. It is not a coverage instrumentation library, and the README does not document rollback. Before adoption, verify artifact compatibility, confirm that `-b` and `-s` identify the correct binary and source tree, and check that the CI sink accepts the generated format.
Frequently asked questions
Which coverage formats can grcov read?
grcov processes `.profraw` and `.gcda` files from LLVM, Clang, or GCC, plus lcov files, Go `out` files, and JaCoCo files for Java and Kotlin.
How do I install grcov on a system with Rust?
The README says to run `cargo install grcov`. It also provides GitHub releases as an alternative source for downloading the tool.
Which output formats does grcov generate?
The documented options include HTML, Coveralls, lcov INFO, recursive JSON, ActiveData-ETL, file lists, Markdown, Cobertura, and pretty-printed Cobertura.
What information is required for Rust source coverage?
The documented workflow installs `llvm-tools`, sets `RUSTFLAGS` to enable instrumentation, and builds the project. It also calls for separate profile information per test process through `LLVM_PROFILE_FILE`.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/mozilla-grcov)Was this useful?