code_coverage icon indicating copy to clipboard operation
code_coverage copied to clipboard

clang support?

Open suurjaak opened this issue 4 years ago • 4 comments

Is this package expected to work with clang? When following the instructions, the result of a coverage run is:

/usr/bin/lcov -c -i -d . -o my_package_coverage_report.base
Capturing coverage data from .
Found gcov version: 9.3.0
Using intermediate gcov format
Scanning . for .gcno files ...
Found 9 graph files in .
Processing test_mytest.dir/test/test_mytest.cpp.gcno
/home/user/dev/build/my_package/CMakeFiles/test_mytest.dir/test/test_mytest.cpp.gcno:version '402*', prefer 'A93*'
geninfo: ERROR: GCOV failed for /home/user/dev/build/my_package/CMakeFiles/test_mytest.dir/test/test_mytest.cpp.gcno!
make[3]: *** [CMakeFiles/my_package_coverage_report_cleanup_cpp.dir/build.make:59: CMakeFiles/my_package_coverage_report_cleanup_cpp] Error 255

And when I do gcov /home/user/dev/build/my_package/CMakeFiles/test_mytest.dir/test/test_mytest.cpp.gcno manually, I get

/home/user/dev/build/my_package/CMakeFiles/test_mytest.dir/test/test_mytest.cpp.gcno:version '402*', prefer 'A93*'
Segmentation fault (core dumped)

But when I do llvm-cov gcov /home/user/dev/build/my_package/CMakeFiles/test_mytest.dir/test/test_mytest.cpp.gcno, it does display some coverage info.

Or is this just a local workspace configuration problem?

suurjaak avatar Apr 27 '21 18:04 suurjaak

Was this resolved? I am also encountering the same issue.

ebadeauxSCWX avatar Sep 27 '21 15:09 ebadeauxSCWX

No, the author has not reacted in any way.

I made myself a small patch for this package, which forces lcov to use llvm-cov: patch.txt.

And a script to put somewhere in path as llvm-gcov.sh:

#!/bin/bash
exec llvm-cov gcov "$@"

suurjaak avatar Sep 27 '21 17:09 suurjaak

No, the author has not reacted in any way.

I don't personally have any insight into llvm or clang issues. If a PR can be created (that doesn't break existing workflows), happy to review, merge and re-release.

mikeferguson avatar Sep 27 '21 18:09 mikeferguson

Made a pull request for this (https://github.com/mikeferguson/code_coverage/pull/33).

Went with requiring a specific option only when using Clang coverage tools:

APPEND_COVERAGE_COMPILER_FLAGS(COMPILER clang)

suurjaak avatar Sep 29 '21 19:09 suurjaak