Tag Archive for 'gcov'

Generating PHP test coverage and ccache

Today I had a weird error while generating PHP code coverage for PHPT tests. If you’re writing PHP extensions, it’s quite common to use compiler caches like ccache. They cache compile results in a way that speeds up multiple compilation of the same source, something which happens quite a lot if you’re working on coding some C extension. So I have cc, gcc and g++ dynamically linked to the ccache binary, which does the caching after proxying the compile request to the actual compiler. This works great, but when generating GCC code coverage (gcov), things don’t work as expected. When running make lcov, the following happened at the end:

Generating php_lcov.info
Capturing coverage data from lcov_data/
Found gcov version: 4.1.2
Scanning lcov_data/ for .gcda files ...
ERROR: no .gcda files found in lcov_data/!
make: *** [php_lcov.info] Error 255

The .gcda files are the ones which contain the useful coverage data used by lcov, but they just weren’t there! It took a while to figure out that disabling ccache fixed the problem. Actually the problem itself isn’t fixed, so if anyone has any idea why ccache and gcov data don’t like eachother, let me know in the comments! But for now, at least there’s a way around it, just disable ccache :-)