Unable to compile for test coverage on Nixos 24.05 #31087

issue danielabrozzoni opened this issue on October 14, 2024
  1. danielabrozzoni commented at 7:03 PM on October 14, 2024: member

    Is there an existing issue for this?

    • I have searched the existing issues

    Current behaviour

    I'm trying to compile Bitcoin Core for test coverage as explained in doc/developer-notes.md, but the command cmake -P build/Coverage.cmake fails with

    [...]
    Finished .info-file creation
    Deleting all .da files in src and subdirectories
    Done.
    .lcov-wrapped: WARNING: negative counts found in tracefile test_bitcoin_filtered.info
    Combining tracefiles.
    Reading tracefile test_bitcoin_filtered.info
    Writing data to test_bitcoin_filtered.info
    Summary coverage rate:
      lines......: 70.5% (76896 of 109080 lines)
      functions..: 64.7% (21913 of 33862 functions)
      branches...: no data found
    Combining tracefiles.
    Reading tracefile baseline_filtered.info
    Reading tracefile test_bitcoin_filtered.info
    Writing data to test_bitcoin_coverage.info
    Summary coverage rate:
      lines......: 69.6% (76896 of 110489 lines)
      functions..: 64.0% (21913 of 34217 functions)
      branches...: no data found
    Reading data file test_bitcoin_coverage.info
    Found 1038 entries.
    Found common filename prefix "/home/daniela/Developer/bitcoin"
    Writing .css and .png files.
    Generating output.
    genhtml: ERROR: cannot read /home/daniela/Developer/bitcoin/build/src/include/boost/operators.hpp
    Processing file build/src/include/boost/operators.hpp
    CMake Error at build/Coverage.cmake:46 (execute_process):
      execute_process failed command indexes:
    
        1: "Child return code: 2"
    

    The command output is also full of similar warnings:

    geninfo: WARNING: could not open /home/daniela/Developer/bitcoin/build/src/include/boost/smart_ptr/detail/shared_count.hpp
    

    The files ./build/test_bitcoin.coverage/index.html and ./build/total.coverage/index.html are not created

    Expected behaviour

    Compilation succeeds and I'm able to see the ./build/test_bitcoin.coverage/index.html and ./build/total.coverage/index.html files

    Steps to reproduce

    cmake -B build -DCMAKE_BUILD_TYPE=Coverage
    cmake --build build
    cmake -P build/Coverage.cmake
    

    Relevant log output

    <details> <summary> Configure build </summary>

    $ cmake -B build -DCMAKE_BUILD_TYPE=Coverage
    
    Configuring secp256k1 subtree...
    -- Could NOT find Valgrind (missing: Valgrind_INCLUDE_DIR Valgrind_WORKS) 
    
    
    secp256k1 configure summary
    ===========================
    Build artifacts:
    library type ........................ Static
    Optional modules:
    ECDH ................................ OFF
    ECDSA pubkey recovery ............... ON
    extrakeys ........................... ON
    schnorrsig .......................... ON
    ElligatorSwift ...................... ON
    Parameters:
    ecmult window size .................. 15
    ecmult gen table size ............... 86 KiB
    Optional features:
    assembly ............................ x86_64
    external callbacks .................. OFF
    Optional binaries:
    benchmark ........................... OFF
    noverify_tests ...................... ON
    tests ............................... OFF
    exhaustive tests .................... ON
    ctime_tests ......................... OFF
    examples ............................ OFF
    
    Cross compiling ....................... FALSE
    Valgrind .............................. OFF
    Preprocessor defined macros ........... ENABLE_MODULE_ELLSWIFT=1 ENABLE_MODULE_SCHNORRSIG=1 ENABLE_MODULE_EXTRAKEYS=1 ENABLE_MODULE_RECOVERY=1 ECMULT_WINDOW_SIZE=15 COMB_BLOCKS=43 COMB_TEETH=6 USE_ASM_X86_64=1
    C compiler ............................ GNU 13.2.0, /nix/store/r73z9i18vbjcph7k2f3isrysxzx6sqjx-gcc-wrapper-13.2.0/bin/gcc
    CFLAGS ................................ 
    Compile options ....................... -pedantic -Wall -Wcast-align -Wcast-align=strict -Wextra -Wnested-externs -Wno-long-long -Wno-overlength-strings -Wno-unused-function -Wshadow -Wstrict-prototypes -Wundef
    Build type:
    - CMAKE_BUILD_TYPE ................... Coverage
    - CFLAGS ............................. -O2 -g  -O0 -DCOVERAGE=1 --coverage
    - LDFLAGS for executables ............  --coverage
    - LDFLAGS for shared libraries .......  --coverage
    
    
    
    Configure summary
    =================
    Executables:
    bitcoind ............................ ON
    bitcoin-node (multiprocess) ......... OFF
    bitcoin-qt (GUI) .................... OFF
    bitcoin-gui (GUI, multiprocess) ..... OFF
    bitcoin-cli ......................... ON
    bitcoin-tx .......................... ON
    bitcoin-util ........................ ON
    bitcoin-wallet ...................... ON
    bitcoin-chainstate (experimental) ... OFF
    libbitcoinkernel (experimental) ..... OFF
    Optional features:
    wallet support ...................... ON
     - descriptor wallets (SQLite) ...... ON
     - legacy wallets (Berkeley DB) ..... OFF
    external signer ..................... ON
    port mapping using UPnP ............. OFF
    ZeroMQ .............................. OFF
    USDT tracing ........................ OFF
    QR code (GUI) ....................... OFF
    DBus (GUI, Linux only) .............. OFF
    Tests:
    test_bitcoin ........................ ON
    test_bitcoin-qt ..................... OFF
    bench_bitcoin ....................... OFF
    fuzz binary ......................... OFF
    
    Cross compiling ....................... FALSE
    C++ compiler .......................... GNU 13.2.0, /nix/store/r73z9i18vbjcph7k2f3isrysxzx6sqjx-gcc-wrapper-13.2.0/bin/g++
    CMAKE_BUILD_TYPE ...................... Coverage
    Preprocessor defined macros ........... 
    C++ compiler flags .................... -g -Og --coverage -std=c++20 -fPIC -fdebug-prefix-map=/home/daniela/Developer/bitcoin=. -fmacro-prefix-map=/home/daniela/Developer/bitcoin=. -fno-extended-identifiers -fstack-reuse=none -Wall -Wextra -Wformat -Wformat-security -Wvla -Wredundant-decls -Wdate-time -Wduplicated-branches -Wduplicated-cond -Wlogical-op -Woverloaded-virtual -Wsuggest-override -Wimplicit-fallthrough -Wunreachable-code -Wundef -Wno-unused-parameter -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -Wstack-protector -fstack-protector-all -fcf-protection=full -fstack-clash-protection
    Linker flags .......................... -g -Og --coverage -fstack-reuse=none -fstack-protector-all -fcf-protection=full -fstack-clash-protection -Wl,-z,relro -Wl,-z,now -Wl,-z,separate-code -fPIE -pie
    
    NOTE: The summary above may not exactly match the final applied build flags
        if any additional CMAKE_* or environment variables have been modified.
        To see the exact flags applied, build with the --verbose option.
    
    Attempt to harden executables ......... ON
    Treat compiler warnings as errors ..... OFF
    Use ccache for compiling .............. ON
    
    
    -- Configuring done (0.3s)
    -- Generating done (0.1s)
    -- Build files have been written to: /home/daniela/Developer/bitcoin/build
    

    </details>

    <details> <summary> Generate code coverage report (trimmed) </summary>

    Capturing coverage data from src
    Found gcov version: 13.2.0
    Using intermediate gcov format
    Using JSON module JSON::PP
    Scanning src for .gcno files ...
    Found 398 graph files in src
    Processing univalue/CMakeFiles/object.dir/test/object.cpp.gcno
    Processing univalue/CMakeFiles/unitester.dir/test/unitester.cpp.gcno
    Processing univalue/CMakeFiles/univalue.dir/lib/univalue_read.cpp.gcno
    Processing univalue/CMakeFiles/univalue.dir/lib/univalue_write.cpp.gcno
    Processing univalue/CMakeFiles/univalue.dir/lib/univalue_get.cpp.gcno
    Processing univalue/CMakeFiles/univalue.dir/lib/univalue.cpp.gcno
    Processing util/CMakeFiles/bitcoin_util.dir/exception.cpp.gcno
    Processing util/CMakeFiles/bitcoin_util.dir/__/random.cpp.gcno
    Processing util/CMakeFiles/bitcoin_util.dir/__/streams.cpp.gcno
    Processing util/CMakeFiles/bitcoin_util.dir/__/support/lockedpool.cpp.gcno
    Processing util/CMakeFiles/bitcoin_util.dir/__/randomenv.cpp.gcno
    Processing util/CMakeFiles/bitcoin_util.dir/__/sync.cpp.gcno
    /home/daniela/Developer/bitcoin/build/src/util/CMakeFiles/bitcoin_util.dir/__/sync.cpp.gcno:no functions found
    geninfo: WARNING: GCOV did not produce any data for /home/daniela/Developer/bitcoin/build/src/util/CMakeFiles/bitcoin_util.dir/__/sync.cpp.gcno
    [...]
    Processing CMakeFiles/bitcoin_node.dir/txmempool.cpp.gcno
    geninfo: WARNING: could not open /home/daniela/Developer/bitcoin/build/src/include/boost/multi_index/detail/bidir_node_iterator.hpp
    geninfo: WARNING: could not open /home/daniela/Developer/bitcoin/build/src/include/boost/multi_index/detail/hash_index_iterator.hpp
    geninfo: WARNING: could not open /home/daniela/Developer/bitcoin/build/src/include/boost/utility/base_from_member.hpp
    geninfo: WARNING: could not open /home/daniela/Developer/bitcoin/build/src/include/boost/operators.hpp
    geninfo: WARNING: could not open /home/daniela/Developer/bitcoin/build/src/include/boost/tuple/detail/tuple_basic.hpp
    geninfo: WARNING: could not open /home/daniela/Developer/bitcoin/build/src/include/boost/multi_index/detail/bucket_array.hpp
    geninfo: WARNING: could not open /home/daniela/Developer/bitcoin/build/src/include/boost/multi_index/hashed_index.hpp
    geninfo: WARNING: could not open /home/daniela/Developer/bitcoin/build/src/include/boost/multi_index/detail/hash_index_node.hpp
    geninfo: WARNING: could not open /home/daniela/Developer/bitcoin/build/src/include/boost/multi_index/detail/auto_space.hpp
    geninfo: WARNING: could not open /home/daniela/Developer/bitcoin/build/src/include/boost/multi_index/detail/index_base.hpp
    geninfo: WARNING: could not open /home/daniela/Developer/bitcoin/build/src/include/boost/multi_index/detail/ord_index_node.hpp
    geninfo: WARNING: could not open /home/daniela/Developer/bitcoin/build/src/include/boost/multi_index/detail/ord_index_impl.hpp
    geninfo: WARNING: could not open /home/daniela/Developer/bitcoin/build/src/include/boost/multi_index/detail/index_node_base.hpp
    geninfo: WARNING: could not open /home/daniela/Developer/bitcoin/build/src/include/boost/multi_index/detail/header_holder.hpp
    geninfo: WARNING: could not open /home/daniela/Developer/bitcoin/build/src/include/boost/multi_index_container.hpp
    geninfo: WARNING: some exclusion markers may be ignored
    Processing CMakeFiles/bitcoin_node.dir/netgroup.cpp.gcno
    [...]
    Finished .info-file creation
    Deleting all .da files in src and subdirectories
    Done.
    .lcov-wrapped: WARNING: negative counts found in tracefile test_bitcoin_filtered.info
    Combining tracefiles.
    Reading tracefile test_bitcoin_filtered.info
    Writing data to test_bitcoin_filtered.info
    Summary coverage rate:
      lines......: 70.5% (76896 of 109080 lines)
      functions..: 64.7% (21913 of 33862 functions)
      branches...: no data found
    Combining tracefiles.
    Reading tracefile baseline_filtered.info
    Reading tracefile test_bitcoin_filtered.info
    Writing data to test_bitcoin_coverage.info
    Summary coverage rate:
      lines......: 69.6% (76896 of 110489 lines)
      functions..: 64.0% (21913 of 34217 functions)
      branches...: no data found
    Reading data file test_bitcoin_coverage.info
    Found 1038 entries.
    Found common filename prefix "/home/daniela/Developer/bitcoin"
    Writing .css and .png files.
    Generating output.
    genhtml: ERROR: cannot read /home/daniela/Developer/bitcoin/build/src/include/boost/operators.hpp
    Processing file build/src/include/boost/operators.hpp
    CMake Error at build/Coverage.cmake:46 (execute_process):
      execute_process failed command indexes:
    
        1: "Child return code: 2"
    

    </details>

    For full output: coverage.txt (sorry, github doesn't let me paste the full output as it's too long)

    How did you obtain Bitcoin Core

    Compiled from source

    What version of Bitcoin Core are you using?

    master@48cf3da636089873ba7280e0d5b22eb81811d194

    Operating system and version

    NixOS 24.05

    Machine specifications

    No response

  2. hebasto assigned hebasto on Oct 15, 2024
  3. maflcko added the label Build system on Oct 15, 2024
  4. fanquake commented at 3:38 PM on October 22, 2024: member

    Note that this issue isn't Nix specifix, the coverage build type is somewhat broken (see also #31047). The steps to reproduce result in the same/similar failure on non-nix platforms.

  5. fanquake added this to the milestone 29.0 on Nov 13, 2024
  6. hebasto commented at 2:35 PM on November 26, 2024: member

    @danielabrozzoni

    Could you please post the full output of the cmake -B build -DCMAKE_BUILD_TYPE=Coverage command?

  7. danielabrozzoni commented at 10:39 AM on November 27, 2024: member

    @hebasto yes, I had posted it in the issue description under "Relevant log output" -> "> Configure build", but I noticed that on current master (f7144b24be09e7db2173a0b15d73f99a08b98118) the output is slightly different, so here's the current one:

    bitcoin git:master*  
    ❯ cmake -B build -DCMAKE_BUILD_TYPE=Coverage
    
    Configuring secp256k1 subtree...
    -- Could NOT find Valgrind (missing: Valgrind_INCLUDE_DIR Valgrind_WORKS) 
    
    
    secp256k1 configure summary
    ===========================
    Build artifacts:
      library type ........................ Static
    Optional modules:
      ECDH ................................ OFF
      ECDSA pubkey recovery ............... ON
      extrakeys ........................... ON
      schnorrsig .......................... ON
      musig ............................... OFF
      ElligatorSwift ...................... ON
    Parameters:
      ecmult window size .................. 15
      ecmult gen table size ............... 86 KiB
    Optional features:
      assembly ............................ x86_64
      external callbacks .................. OFF
    Optional binaries:
      benchmark ........................... OFF
      noverify_tests ...................... ON
      tests ............................... OFF
      exhaustive tests .................... ON
      ctime_tests ......................... OFF
      examples ............................ OFF
    
    Cross compiling ....................... FALSE
    Valgrind .............................. OFF
    Preprocessor defined macros ........... ENABLE_MODULE_ELLSWIFT=1 ENABLE_MODULE_SCHNORRSIG=1 ENABLE_MODULE_EXTRAKEYS=1 ENABLE_MODULE_RECOVERY=1 ECMULT_WINDOW_SIZE=15 COMB_BLOCKS=43 COMB_TEETH=6 USE_ASM_X86_64=1
    C compiler ............................ GNU 13.2.0, /nix/store/r73z9i18vbjcph7k2f3isrysxzx6sqjx-gcc-wrapper-13.2.0/bin/gcc
    CFLAGS ................................ 
    Compile options ....................... -pedantic -Wall -Wcast-align -Wcast-align=strict -Wextra -Wnested-externs -Wno-long-long -Wno-overlength-strings -Wno-unused-function -Wshadow -Wstrict-prototypes -Wundef
    Build type:
     - CMAKE_BUILD_TYPE ................... Coverage
     - CFLAGS ............................. -O2 -g  -O0 -DCOVERAGE=1 --coverage
     - LDFLAGS for executables ............  --coverage
     - LDFLAGS for shared libraries .......  --coverage
    
    
    
    Configure summary
    =================
    Executables:
      bitcoind ............................ ON
      bitcoin-node (multiprocess) ......... OFF
      bitcoin-qt (GUI) .................... OFF
      bitcoin-gui (GUI, multiprocess) ..... OFF
      bitcoin-cli ......................... ON
      bitcoin-tx .......................... ON
      bitcoin-util ........................ ON
      bitcoin-wallet ...................... ON
      bitcoin-chainstate (experimental) ... OFF
      libbitcoinkernel (experimental) ..... OFF
    Optional features:
      wallet support ...................... ON
       - descriptor wallets (SQLite) ...... ON
       - legacy wallets (Berkeley DB) ..... OFF
      external signer ..................... ON
      ZeroMQ .............................. OFF
      USDT tracing ........................ OFF
      QR code (GUI) ....................... OFF
      DBus (GUI, Linux only) .............. OFF
    Tests:
      test_bitcoin ........................ ON
      test_bitcoin-qt ..................... OFF
      bench_bitcoin ....................... OFF
      fuzz binary ......................... OFF
    
    Cross compiling ....................... FALSE
    C++ compiler .......................... GNU 13.2.0, /nix/store/r73z9i18vbjcph7k2f3isrysxzx6sqjx-gcc-wrapper-13.2.0/bin/g++
    CMAKE_BUILD_TYPE ...................... Coverage
    Preprocessor defined macros ........... 
    C++ compiler flags .................... -g -Og --coverage -std=c++20 -fPIC -fno-extended-identifiers -ffile-prefix-map=/home/daniela/Developer/bitcoin/src=. -fstack-reuse=none -Wall -Wextra -Wformat -Wformat-security -Wvla -Wredundant-decls -Wdate-time -Wduplicated-branches -Wduplicated-cond -Wlogical-op -Woverloaded-virtual -Wsuggest-override -Wimplicit-fallthrough -Wunreachable-code -Wbidi-chars=any -Wundef -Wno-unused-parameter -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -Wstack-protector -fstack-protector-all -fcf-protection=full -fstack-clash-protection
    Linker flags .......................... -g -Og --coverage -fstack-reuse=none -fstack-protector-all -fcf-protection=full -fstack-clash-protection -Wl,-z,relro -Wl,-z,now -Wl,-z,separate-code -fPIE -pie
    
    NOTE: The summary above may not exactly match the final applied build flags
          if any additional CMAKE_* or environment variables have been modified.
          To see the exact flags applied, build with the --verbose option.
    
    Attempt to harden executables ......... ON
    Treat compiler warnings as errors ..... OFF
    Use ccache for compiling .............. ON
    
    
    -- Configuring done (0.4s)
    -- Generating done (0.1s)
    -- Build files have been written to: /home/daniela/Developer/bitcoin/build
    
  8. hebasto commented at 6:32 PM on November 27, 2024: member

    Operating system and version

    NixOS 24.05

    I assume the following packages are being used:

    • gcc-13.2.0
    • lcov-1.16

    The problem is twofold:

    1. To workaround path issues, add -DLCOV_OPTS="--rc geninfo_adjust_src_path=/home/daniela/Developer/bitcoin/build=>/nix/store/zh33l12pk3iij0x5gkjdnargrki3n9gh-boost-1.81.0-dev to the script invocation:
    $ cmake -DJOBS=10 -DLCOV_OPTS="--rc geninfo_adjust_src_path=/home/daniela/Developer/bitcoin/build=>/nix/store/zh33l12pk3iij0x5gkjdnargrki3n9gh-boost-1.81.0-dev" -P build/Coverage.cmake
    

    Adjust this for the actual path to your boost-dev package installation directory (hence I asked about the full configuration output, not just summary).

    1. To filter out system headers, apply the following patch:
    -- a/cmake/script/CoverageInclude.cmake.in
    +++ b/cmake/script/CoverageInclude.cmake.in
    @@ -34,6 +34,7 @@ list(APPEND LCOV_FILTER_COMMAND -p "/usr/local/")
     list(APPEND LCOV_FILTER_COMMAND -p "/usr/include/")
     list(APPEND LCOV_FILTER_COMMAND -p "/usr/lib/")
     list(APPEND LCOV_FILTER_COMMAND -p "/usr/lib64/")
    +list(APPEND LCOV_FILTER_COMMAND -p "/nix/store/")
     list(APPEND LCOV_FILTER_COMMAND -p "src/leveldb/")
     list(APPEND LCOV_FILTER_COMMAND -p "src/crc32c/")
     list(APPEND LCOV_FILTER_COMMAND -p "src/bench/")
    

    This workaround is effective on the master branch @ 144f98db85eb35aaf4f55849f45a18247edf5902 and onwards.

  9. danielabrozzoni commented at 3:29 PM on December 2, 2024: member

    Awesome, now it works! Thank you :)

  10. danielabrozzoni closed this on Dec 2, 2024

  11. bitcoin locked this on Dec 2, 2025

Milestone
29.0


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: 2026-04-27 21:13 UTC

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