Sponsored Content
Skip to content

chore: Fix gcov lib coverage build failure on macOS - #6350

Merged
bthomee merged 4 commits into
developfrom
pratik/6349-fix-codecoveragecmake-unconditionally-links-gcov-breaks-macosapple-clang
Feb 12, 2026
Merged

chore: Fix gcov lib coverage build failure on macOS#6350
bthomee merged 4 commits into
developfrom
pratik/6349-fix-codecoveragecmake-unconditionally-links-gcov-breaks-macosapple-clang

Conversation

@pratikmankawde

@pratikmankawde pratikmankawde commented Feb 11, 2026

Copy link
Copy Markdown
Contributor

High Level Overview of Change

Coverage builds on MacOS were failing on linking. This PR fixes the linking option.

This CI run shows that the build succeeds. MacOS image doesn't have coverage tools to generate reports hence the CI job fails.
https://github.com/XRPLF/rippled/actions/runs/21911026127/job/63264800263?pr=6350

Context of Change

For coverage builds, we try to link against the gcov library (specific to the environment). But Apple doesn't have this library. So, we don't need to explicitly force this linking. CodeCoverage.cmake:472-473

I removed the gcov suffix from both lines. The --coverage flag already:
On GCC: Automatically links against libgcov.a
On Clang/Apple Clang: Automatically links against the LLVM profile runtime

Why It Now Works on All Three Compilers
The file already had correct detection logic (lines 177-193):

Apple Clang: Uses xcrun -f llvm-cov → sets GCOV_TOOL="llvm-cov gcov"
Regular Clang: Finds llvm-cov → sets GCOV_TOOL="llvm-cov gcov"
GCC: Finds gcov → sets GCOV_TOOL="gcov"
The GCOV_TOOL is then passed to gcovr at line 416, so the correct tool is used for processing coverage data.

The fix ensures the linker flags are correct for all three compiler types.

Fixes #6349.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (non-breaking change that only restructures code)
  • Performance (increase or change in throughput and/or latency)
  • Tests (you added tests for code that already exists, or your new feature included in this PR)
  • Documentation update
  • Chore (no impact to binary, e.g. .gitignore, formatting, dropping support for older tooling)
  • Release

Signed-off-by: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com>
@pratikmankawde pratikmankawde added the DraftRunCI Normally CI does not run on draft PRs. This opts in. label Feb 11, 2026
@pratikmankawde
pratikmankawde marked this pull request as draft February 11, 2026 14:54
@codecov

codecov Bot commented Feb 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.9%. Comparing base (9f17d10) to head (0150c87).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           develop   #6350   +/-   ##
=======================================
  Coverage     79.9%   79.9%           
=======================================
  Files          840     840           
  Lines        65508   65508           
  Branches      7254    7252    -2     
=======================================
  Hits         52346   52346           
  Misses       13162   13162           

see 2 files with indirect coverage changes

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Signed-off-by: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com>
Signed-off-by: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com>
@pratikmankawde
pratikmankawde marked this pull request as ready for review February 11, 2026 17:14
@pratikmankawde pratikmankawde changed the title fixed coverage setup om macos, building cov on mac as well. Coverage builds on MacOS were failing with linker issue with gov lib Feb 11, 2026

@mathbunnyru mathbunnyru left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great change and description 👍

And probably the longest branch name I've seen in a while 😂

@pratikmankawde pratikmankawde added Ready to merge *PR author* thinks it's ready to merge. Has passed code review. Perf sign-off may still be required. and removed DraftRunCI Normally CI does not run on draft PRs. This opts in. labels Feb 12, 2026
@bthomee bthomee changed the title Coverage builds on MacOS were failing with linker issue with gov lib chore: Fix gcov lib coverage build failure on macOS Feb 12, 2026
@bthomee
bthomee merged commit 11e8d1f into develop Feb 12, 2026
3 checks passed
@bthomee
bthomee deleted the pratik/6349-fix-codecoveragecmake-unconditionally-links-gcov-breaks-macosapple-clang branch February 12, 2026 11:11
@mvadari mvadari added this to the 3.2.0 milestone May 20, 2026
beartec-jpg pushed a commit to beartec-jpg/FalconLedger that referenced this pull request Jun 1, 2026
For coverage builds, we try to link against the `gcov` library (specific to the environment). But as macOS doesn't have this library and thus doesn't have the coverage tools to generate reports, the coverage builds on that platform were failing on linking.

We actually don't need to explicitly force this linking, as the `CodeCoverage` file already has correct detection logic (currently on lines 177-193), which is invoked when the `--coverage` flag is provided:
* AppleClang: Uses `xcrun -f llvm-cov` to set `GCOV_TOOL="llvm-cov gcov"`.
* Clang: Finds `llvm-cov` to set `GCOV_TOOL="llvm-cov gcov"`.
* GCC: Finds `gcov` to set `GCOV_TOOL="gcov"`.
The `GCOV_TOOL` is then passed to `gcovr` on line 416, so the correct tool is used for processing coverage data.

This change therefore removes the `gcov` suffix from lines 473 and 475 in the `CodeCoverage.cmake` file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready to merge *PR author* thinks it's ready to merge. Has passed code review. Perf sign-off may still be required.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: CodeCoverage.cmake unconditionally links gcov, breaks macOS/Apple Clang

4 participants