lcov usage fails with clang #12602

issue jamesob openend this issue on March 5, 2018
  1. jamesob commented at 3:32 pm on March 5, 2018: member

    When attempting to generate coverage information with make cov after configuring and building with clang, lcov/gcov (for the versions I’m using) are unable to parse the generated gcda files:

    0/home/james/tmp/bitcoin/src/libbitcoin_server_a-miner.gcno:version '402*', prefer 'A72*'
    1geninfo: ERROR: GCOV failed for /home/james/tmp/bitcoin/src/libbitcoin_server_a-miner.gcda!
    2Makefile:1269: recipe for target 'test_bitcoin.info' failed
    

    We may need to special-case the effects of --enable-lcov when building with clang to use flags and commands mentioned here.

    Configure output

     0Options used to compile and link:
     1  with wallet   = yes
     2  with gui / qt = yes
     3    qt version  = 5
     4    with qr     = auto
     5  with zmq      = yes
     6  with test     = yes
     7  with bench    = yes
     8  with upnp     = auto
     9  use asm       = yes
    10  debug enabled = no
    11  werror        = no
    12
    13  target os     = linux
    14  build os      =
    15
    16  CC            = /usr/bin/clang-4.0
    17  CFLAGS        = -g -O2
    18  CPPFLAGS      = -I/home/james/tmp/bitcoin/db4/include/ -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS
    19  CXX           = /usr/bin/clang++-4.0 -std=c++11
    20  CXXFLAGS      = -std=c++11 -std=c++11  --coverage -Og
    21  LDFLAGS       = -L/home/james/tmp/bitcoin/db4/lib/ --coverage
    22  ARFLAGS       = cr
    

    Versions

     0 $ clang++-4.0 --version
     1
     2clang version 4.0.1-6 (tags/RELEASE_401/final)
     3Target: x86_64-pc-linux-gnu
     4Thread model: posix
     5InstalledDir: /usr/bin
     6
     7 $ lcov --version
     8
     9lcov: LCOV version 1.13
    10
    11 $ gcov --version
    12
    13gcov (Ubuntu 7.2.0-8ubuntu3.2) 7.2.0
    14Copyright (C) 2017 Free Software Foundation, Inc.
    15This is free software; see the source for copying conditions.
    16There is NO warranty; not even for MERCHANTABILITY or
    17FITNESS FOR A PARTICULAR PURPOSE.
    

    make cov failure

     0$ make cov
     1...
     2/usr/bin/lcov --gcov-tool=/usr/bin/gcov -c  -d /home/james/tmp/bitcoin/src -t test_bitcoin -o test_bitcoin.info
     3Capturing coverage data from /home/james/tmp/bitcoin/src
     4Found gcov version: 7.2.0
     5Scanning /home/james/tmp/bitcoin/src for .gcda files ...
     6Found 290 data files in /home/james/tmp/bitcoin/src
     7Processing src/libbitcoin_server_a-miner.gcda
     8/home/james/tmp/bitcoin/src/libbitcoin_server_a-miner.gcno:version '402*', prefer 'A72*'
     9geninfo: ERROR: GCOV failed for /home/james/tmp/bitcoin/src/libbitcoin_server_a-miner.gcda!
    10Makefile:1269: recipe for target 'test_bitcoin.info' failed
    11make: *** [test_bitcoin.info] Error 29
    12rm test_bitcoin.info baseline_filtered.info baseline.info
    
  2. fanquake added the label Build system on Mar 5, 2018
  3. MarcoFalke commented at 0:45 am on March 12, 2018: member
    I always assumed that gcov only works with gcc.
  4. jamesob commented at 10:21 pm on March 26, 2018: member
    Might preferable to warn during configuration if --enable-coverage is combined with non-gcc usage. I’ll try for a PR soonish.
  5. MarcoFalke commented at 2:20 am on February 27, 2019: member
    I’d rather add support for llvm-cov in addition to --enable-lcov
  6. MarcoFalke commented at 0:05 am on December 7, 2019: member

    You can use llvm-cov with clang with the following diff applied:

     0diff --git a/configure.ac b/configure.ac
     1index 2c648b0b5c..c502543a1a 100644
     2--- a/configure.ac
     3+++ b/configure.ac
     4@@ -87,7 +87,7 @@ dnl Check/return PATH for base programs.
     5 AC_PATH_TOOL(AR, ar)
     6 AC_PATH_TOOL(RANLIB, ranlib)
     7 AC_PATH_TOOL(STRIP, strip)
     8-AC_PATH_TOOL(GCOV, gcov)
     9+AC_PATH_TOOL(GCOV, llvm-cov_gcov)
    10 AC_PATH_PROG(LCOV, lcov)
    11 dnl Python 3.5 is specified in .python-version and should be used if available, see doc/dependencies.md
    12 AC_PATH_PROGS([PYTHON], [python3.5 python3.6 python3.7 python3.8 python3 python])
    

    Then create an executable file

    0$ cat ~/bin/llvm-cov_gcov 
    1#!/usr/bin/env bash
    2exec llvm-cov gcov "$@"
    3$ which llvm-cov_gcov
    4~/bin/llvm-cov_gcov
    
  7. laanwj referenced this in commit bdc2644b72 on Mar 27, 2020
  8. sidhujag referenced this in commit 2c27c78eae on Mar 28, 2020
  9. MarcoFalke referenced this in commit e349eeeb2c on Aug 8, 2020
  10. sidhujag referenced this in commit 59cd04bdf5 on Aug 8, 2020
  11. MarcoFalke closed this on Aug 12, 2020

  12. sidhujag referenced this in commit fa44ec8d07 on Aug 14, 2020
  13. PastaPastaPasta referenced this in commit 7c488f73f9 on Sep 17, 2021
  14. PastaPastaPasta referenced this in commit db62c6f314 on Sep 19, 2021
  15. thelazier referenced this in commit 586492d15a on Sep 25, 2021
  16. DrahtBot locked this on Feb 15, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-11-17 15:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me