Unable to compile for test coverage on Nixos 24.05 #31087

issue danielabrozzoni openend this issue on October 14, 2024
  1. danielabrozzoni commented at 7:03 pm on October 14, 2024: contributor

    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

     0[...]
     1Finished .info-file creation
     2Deleting all .da files in src and subdirectories
     3Done.
     4.lcov-wrapped: WARNING: negative counts found in tracefile test_bitcoin_filtered.info
     5Combining tracefiles.
     6Reading tracefile test_bitcoin_filtered.info
     7Writing data to test_bitcoin_filtered.info
     8Summary coverage rate:
     9  lines......: 70.5% (76896 of 109080 lines)
    10  functions..: 64.7% (21913 of 33862 functions)
    11  branches...: no data found
    12Combining tracefiles.
    13Reading tracefile baseline_filtered.info
    14Reading tracefile test_bitcoin_filtered.info
    15Writing data to test_bitcoin_coverage.info
    16Summary coverage rate:
    17  lines......: 69.6% (76896 of 110489 lines)
    18  functions..: 64.0% (21913 of 34217 functions)
    19  branches...: no data found
    20Reading data file test_bitcoin_coverage.info
    21Found 1038 entries.
    22Found common filename prefix "/home/daniela/Developer/bitcoin"
    23Writing .css and .png files.
    24Generating output.
    25genhtml: ERROR: cannot read /home/daniela/Developer/bitcoin/build/src/include/boost/operators.hpp
    26Processing file build/src/include/boost/operators.hpp
    27CMake Error at build/Coverage.cmake:46 (execute_process):
    28  execute_process failed command indexes:
    29
    30    1: "Child return code: 2"
    

    The command output is also full of similar warnings:

    0geninfo: 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

    0cmake -B build -DCMAKE_BUILD_TYPE=Coverage
    1cmake --build build
    2cmake -P build/Coverage.cmake
    

    Relevant log output

     0$ cmake -B build -DCMAKE_BUILD_TYPE=Coverage
     1
     2Configuring secp256k1 subtree...
     3-- Could NOT find Valgrind (missing: Valgrind_INCLUDE_DIR Valgrind_WORKS) 
     4
     5
     6secp256k1 configure summary
     7===========================
     8Build artifacts:
     9library type ........................ Static
    10Optional modules:
    11ECDH ................................ OFF
    12ECDSA pubkey recovery ............... ON
    13extrakeys ........................... ON
    14schnorrsig .......................... ON
    15ElligatorSwift ...................... ON
    16Parameters:
    17ecmult window size .................. 15
    18ecmult gen table size ............... 86 KiB
    19Optional features:
    20assembly ............................ x86_64
    21external callbacks .................. OFF
    22Optional binaries:
    23benchmark ........................... OFF
    24noverify_tests ...................... ON
    25tests ............................... OFF
    26exhaustive tests .................... ON
    27ctime_tests ......................... OFF
    28examples ............................ OFF
    29
    30Cross compiling ....................... FALSE
    31Valgrind .............................. OFF
    32Preprocessor 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
    33C compiler ............................ GNU 13.2.0, /nix/store/r73z9i18vbjcph7k2f3isrysxzx6sqjx-gcc-wrapper-13.2.0/bin/gcc
    34CFLAGS ................................ 
    35Compile options ....................... -pedantic -Wall -Wcast-align -Wcast-align=strict -Wextra -Wnested-externs -Wno-long-long -Wno-overlength-strings -Wno-unused-function -Wshadow -Wstrict-prototypes -Wundef
    36Build type:
    37- CMAKE_BUILD_TYPE ................... Coverage
    38- CFLAGS ............................. -O2 -g  -O0 -DCOVERAGE=1 --coverage
    39- LDFLAGS for executables ............  --coverage
    40- LDFLAGS for shared libraries .......  --coverage
    41
    42
    43
    44Configure summary
    45=================
    46Executables:
    47bitcoind ............................ ON
    48bitcoin-node (multiprocess) ......... OFF
    49bitcoin-qt (GUI) .................... OFF
    50bitcoin-gui (GUI, multiprocess) ..... OFF
    51bitcoin-cli ......................... ON
    52bitcoin-tx .......................... ON
    53bitcoin-util ........................ ON
    54bitcoin-wallet ...................... ON
    55bitcoin-chainstate (experimental) ... OFF
    56libbitcoinkernel (experimental) ..... OFF
    57Optional features:
    58wallet support ...................... ON
    59 - descriptor wallets (SQLite) ...... ON
    60 - legacy wallets (Berkeley DB) ..... OFF
    61external signer ..................... ON
    62port mapping using UPnP ............. OFF
    63ZeroMQ .............................. OFF
    64USDT tracing ........................ OFF
    65QR code (GUI) ....................... OFF
    66DBus (GUI, Linux only) .............. OFF
    67Tests:
    68test_bitcoin ........................ ON
    69test_bitcoin-qt ..................... OFF
    70bench_bitcoin ....................... OFF
    71fuzz binary ......................... OFF
    72
    73Cross compiling ....................... FALSE
    74C++ compiler .......................... GNU 13.2.0, /nix/store/r73z9i18vbjcph7k2f3isrysxzx6sqjx-gcc-wrapper-13.2.0/bin/g++
    75CMAKE_BUILD_TYPE ...................... Coverage
    76Preprocessor defined macros ........... 
    77C++ 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
    78Linker 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
    79
    80NOTE: The summary above may not exactly match the final applied build flags
    81    if any additional CMAKE_* or environment variables have been modified.
    82    To see the exact flags applied, build with the --verbose option.
    83
    84Attempt to harden executables ......... ON
    85Treat compiler warnings as errors ..... OFF
    86Use ccache for compiling .............. ON
    87
    88
    89-- Configuring done (0.3s)
    90-- Generating done (0.1s)
    91-- Build files have been written to: /home/daniela/Developer/bitcoin/build
    
     0Capturing coverage data from src
     1Found gcov version: 13.2.0
     2Using intermediate gcov format
     3Using JSON module JSON::PP
     4Scanning src for .gcno files ...
     5Found 398 graph files in src
     6Processing univalue/CMakeFiles/object.dir/test/object.cpp.gcno
     7Processing univalue/CMakeFiles/unitester.dir/test/unitester.cpp.gcno
     8Processing univalue/CMakeFiles/univalue.dir/lib/univalue_read.cpp.gcno
     9Processing univalue/CMakeFiles/univalue.dir/lib/univalue_write.cpp.gcno
    10Processing univalue/CMakeFiles/univalue.dir/lib/univalue_get.cpp.gcno
    11Processing univalue/CMakeFiles/univalue.dir/lib/univalue.cpp.gcno
    12Processing util/CMakeFiles/bitcoin_util.dir/exception.cpp.gcno
    13Processing util/CMakeFiles/bitcoin_util.dir/__/random.cpp.gcno
    14Processing util/CMakeFiles/bitcoin_util.dir/__/streams.cpp.gcno
    15Processing util/CMakeFiles/bitcoin_util.dir/__/support/lockedpool.cpp.gcno
    16Processing util/CMakeFiles/bitcoin_util.dir/__/randomenv.cpp.gcno
    17Processing util/CMakeFiles/bitcoin_util.dir/__/sync.cpp.gcno
    18/home/daniela/Developer/bitcoin/build/src/util/CMakeFiles/bitcoin_util.dir/__/sync.cpp.gcno:no functions found
    19geninfo: WARNING: GCOV did not produce any data for /home/daniela/Developer/bitcoin/build/src/util/CMakeFiles/bitcoin_util.dir/__/sync.cpp.gcno
    20[...]
    21Processing CMakeFiles/bitcoin_node.dir/txmempool.cpp.gcno
    22geninfo: WARNING: could not open /home/daniela/Developer/bitcoin/build/src/include/boost/multi_index/detail/bidir_node_iterator.hpp
    23geninfo: WARNING: could not open /home/daniela/Developer/bitcoin/build/src/include/boost/multi_index/detail/hash_index_iterator.hpp
    24geninfo: WARNING: could not open /home/daniela/Developer/bitcoin/build/src/include/boost/utility/base_from_member.hpp
    25geninfo: WARNING: could not open /home/daniela/Developer/bitcoin/build/src/include/boost/operators.hpp
    26geninfo: WARNING: could not open /home/daniela/Developer/bitcoin/build/src/include/boost/tuple/detail/tuple_basic.hpp
    27geninfo: WARNING: could not open /home/daniela/Developer/bitcoin/build/src/include/boost/multi_index/detail/bucket_array.hpp
    28geninfo: WARNING: could not open /home/daniela/Developer/bitcoin/build/src/include/boost/multi_index/hashed_index.hpp
    29geninfo: WARNING: could not open /home/daniela/Developer/bitcoin/build/src/include/boost/multi_index/detail/hash_index_node.hpp
    30geninfo: WARNING: could not open /home/daniela/Developer/bitcoin/build/src/include/boost/multi_index/detail/auto_space.hpp
    31geninfo: WARNING: could not open /home/daniela/Developer/bitcoin/build/src/include/boost/multi_index/detail/index_base.hpp
    32geninfo: WARNING: could not open /home/daniela/Developer/bitcoin/build/src/include/boost/multi_index/detail/ord_index_node.hpp
    33geninfo: WARNING: could not open /home/daniela/Developer/bitcoin/build/src/include/boost/multi_index/detail/ord_index_impl.hpp
    34geninfo: WARNING: could not open /home/daniela/Developer/bitcoin/build/src/include/boost/multi_index/detail/index_node_base.hpp
    35geninfo: WARNING: could not open /home/daniela/Developer/bitcoin/build/src/include/boost/multi_index/detail/header_holder.hpp
    36geninfo: WARNING: could not open /home/daniela/Developer/bitcoin/build/src/include/boost/multi_index_container.hpp
    37geninfo: WARNING: some exclusion markers may be ignored
    38Processing CMakeFiles/bitcoin_node.dir/netgroup.cpp.gcno
    39[...]
    40Finished .info-file creation
    41Deleting all .da files in src and subdirectories
    42Done.
    43.lcov-wrapped: WARNING: negative counts found in tracefile test_bitcoin_filtered.info
    44Combining tracefiles.
    45Reading tracefile test_bitcoin_filtered.info
    46Writing data to test_bitcoin_filtered.info
    47Summary coverage rate:
    48  lines......: 70.5% (76896 of 109080 lines)
    49  functions..: 64.7% (21913 of 33862 functions)
    50  branches...: no data found
    51Combining tracefiles.
    52Reading tracefile baseline_filtered.info
    53Reading tracefile test_bitcoin_filtered.info
    54Writing data to test_bitcoin_coverage.info
    55Summary coverage rate:
    56  lines......: 69.6% (76896 of 110489 lines)
    57  functions..: 64.0% (21913 of 34217 functions)
    58  branches...: no data found
    59Reading data file test_bitcoin_coverage.info
    60Found 1038 entries.
    61Found common filename prefix "/home/daniela/Developer/bitcoin"
    62Writing .css and .png files.
    63Generating output.
    64genhtml: ERROR: cannot read /home/daniela/Developer/bitcoin/build/src/include/boost/operators.hpp
    65Processing file build/src/include/boost/operators.hpp
    66CMake Error at build/Coverage.cmake:46 (execute_process):
    67  execute_process failed command indexes:
    68
    69    1: "Child return code: 2"
    

    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: contributor

    @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:

     0bitcoin git:master*  
     1 cmake -B build -DCMAKE_BUILD_TYPE=Coverage
     2
     3Configuring secp256k1 subtree...
     4-- Could NOT find Valgrind (missing: Valgrind_INCLUDE_DIR Valgrind_WORKS) 
     5
     6
     7secp256k1 configure summary
     8===========================
     9Build artifacts:
    10  library type ........................ Static
    11Optional modules:
    12  ECDH ................................ OFF
    13  ECDSA pubkey recovery ............... ON
    14  extrakeys ........................... ON
    15  schnorrsig .......................... ON
    16  musig ............................... OFF
    17  ElligatorSwift ...................... ON
    18Parameters:
    19  ecmult window size .................. 15
    20  ecmult gen table size ............... 86 KiB
    21Optional features:
    22  assembly ............................ x86_64
    23  external callbacks .................. OFF
    24Optional binaries:
    25  benchmark ........................... OFF
    26  noverify_tests ...................... ON
    27  tests ............................... OFF
    28  exhaustive tests .................... ON
    29  ctime_tests ......................... OFF
    30  examples ............................ OFF
    31
    32Cross compiling ....................... FALSE
    33Valgrind .............................. OFF
    34Preprocessor 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
    35C compiler ............................ GNU 13.2.0, /nix/store/r73z9i18vbjcph7k2f3isrysxzx6sqjx-gcc-wrapper-13.2.0/bin/gcc
    36CFLAGS ................................ 
    37Compile options ....................... -pedantic -Wall -Wcast-align -Wcast-align=strict -Wextra -Wnested-externs -Wno-long-long -Wno-overlength-strings -Wno-unused-function -Wshadow -Wstrict-prototypes -Wundef
    38Build type:
    39 - CMAKE_BUILD_TYPE ................... Coverage
    40 - CFLAGS ............................. -O2 -g  -O0 -DCOVERAGE=1 --coverage
    41 - LDFLAGS for executables ............  --coverage
    42 - LDFLAGS for shared libraries .......  --coverage
    43
    44
    45
    46Configure summary
    47=================
    48Executables:
    49  bitcoind ............................ ON
    50  bitcoin-node (multiprocess) ......... OFF
    51  bitcoin-qt (GUI) .................... OFF
    52  bitcoin-gui (GUI, multiprocess) ..... OFF
    53  bitcoin-cli ......................... ON
    54  bitcoin-tx .......................... ON
    55  bitcoin-util ........................ ON
    56  bitcoin-wallet ...................... ON
    57  bitcoin-chainstate (experimental) ... OFF
    58  libbitcoinkernel (experimental) ..... OFF
    59Optional features:
    60  wallet support ...................... ON
    61   - descriptor wallets (SQLite) ...... ON
    62   - legacy wallets (Berkeley DB) ..... OFF
    63  external signer ..................... ON
    64  ZeroMQ .............................. OFF
    65  USDT tracing ........................ OFF
    66  QR code (GUI) ....................... OFF
    67  DBus (GUI, Linux only) .............. OFF
    68Tests:
    69  test_bitcoin ........................ ON
    70  test_bitcoin-qt ..................... OFF
    71  bench_bitcoin ....................... OFF
    72  fuzz binary ......................... OFF
    73
    74Cross compiling ....................... FALSE
    75C++ compiler .......................... GNU 13.2.0, /nix/store/r73z9i18vbjcph7k2f3isrysxzx6sqjx-gcc-wrapper-13.2.0/bin/g++
    76CMAKE_BUILD_TYPE ...................... Coverage
    77Preprocessor defined macros ........... 
    78C++ 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
    79Linker 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
    80
    81NOTE: The summary above may not exactly match the final applied build flags
    82      if any additional CMAKE_* or environment variables have been modified.
    83      To see the exact flags applied, build with the --verbose option.
    84
    85Attempt to harden executables ......... ON
    86Treat compiler warnings as errors ..... OFF
    87Use ccache for compiling .............. ON
    88
    89
    90-- Configuring done (0.4s)
    91-- Generating done (0.1s)
    92-- 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:
    0$ 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:
    0-- a/cmake/script/CoverageInclude.cmake.in
    1+++ b/cmake/script/CoverageInclude.cmake.in
    2@@ -34,6 +34,7 @@ list(APPEND LCOV_FILTER_COMMAND -p "/usr/local/")
    3 list(APPEND LCOV_FILTER_COMMAND -p "/usr/include/")
    4 list(APPEND LCOV_FILTER_COMMAND -p "/usr/lib/")
    5 list(APPEND LCOV_FILTER_COMMAND -p "/usr/lib64/")
    6+list(APPEND LCOV_FILTER_COMMAND -p "/nix/store/")
    7 list(APPEND LCOV_FILTER_COMMAND -p "src/leveldb/")
    8 list(APPEND LCOV_FILTER_COMMAND -p "src/crc32c/")
    9 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: contributor
    Awesome, now it works! Thank you :)
  10. danielabrozzoni closed this on Dec 2, 2024


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-12-21 15:12 UTC

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