Skip to content

Conversation

hebasto
Copy link
Member

@hebasto hebasto commented Aug 8, 2020

With this PR it is possible to use lcov with clang:

$ ./autogen.sh
$ ./configure --enable-lcov --enable-fuzz --with-sanitizers=fuzzer CC=clang CXX=clang++
$ make
$ make cov_fuzz

NOTE: Unfortunately, on my system (clang version 10.0.0-4ubuntu1) due to unknown for me reasons make cov never finishes, trying to Processing src/test/test_bitcoin-util_tests.gcda forever (stopped waiting).

Closes #12602

@hebasto
Copy link
Member Author

hebasto commented Aug 8, 2020

friendly ping @practicalswift @Crypt-iQ @darosior

@fjahr
Copy link
Contributor

fjahr commented Aug 9, 2020

NOTE: Unfortunately, on my system (clang version 10.0.0-4ubuntu1) due to unknown for me reasons make cov never finishes, trying to Processing src/test/test_bitcoin-util_tests.gcda forever (stopped waiting).

I have observed the same issue with 10.0.0_3 on macOS.

@fanquake fanquake changed the title build, test: Add support for llvm-cov build: Add support for llvm-cov Aug 10, 2020
@Crypt-iQ
Copy link
Contributor

Crypt-iQ commented Aug 10, 2020

Tested ACK 75f9659

make cov still hanging after ~11+ hours on test_bitcoin-util_tests.gcda
make cov_fuzz output: https://crypt-iq.github.io/fuzz.coverage/

Running clang-10 and ubuntu

Copy link
Contributor

@vasild vasild left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 75f9659

Btw, LLVM provides alternative tools to lcov and genhtml. Maybe remove the dependency on those if --enable-lcov is used and the compiler is Clang (then COV_TOOL_WRAPPER would not be needed) and rename that ./configure option to --enable-coverage.

@Crypt-iQ
Copy link
Contributor

Might be a bit unrelated, but I had to move qa-assets from /root to /root/bitcoin for make cov_fuzz to work. Would be nice to be able to specify a directory, but probably out of scope for this PR.

Copy link
Member

@maflcko maflcko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept ACK.

Seems good to merge with two tested ACKs

@@ -192,7 +192,11 @@ LCOV_FILTER_PATTERN = \
-p "src/secp256k1" \
-p "depends"

baseline.info:
$(COV_TOOL_WRAPPER):
@echo 'exec $(COV_TOOL) "$$@"' > $(COV_TOOL_WRAPPER)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could add a comment that this is needed because of a potential dash in the filename of COV_TOOL? (At least I think that was the reason a wrapper is required)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that the wrapper is needed because we run lcov --gcov-tool /path/to/gcov and our gcov is llvm-cov gcov, so lcov --gcov-tool "llvm-cov gcov" other arguments would not work.

It is also possible to generate the coverage without using gcov/lcov:

... compile with clang++ -fprofile-instr-generate -fcoverage-mapping ...
export LLVM_PROFILE_FILE="/tmp/coverage/%m-%p.profraw"
... run unit + functional tests ...
llvm-profdata merge /tmp/coverage/*.profraw -o all.profdata

# Generate lcov-like html report:
llvm-cov export -instr-profile=all.profdata -format=lcov src/test/test_bitcoin -object=src/bitcoind > coverage_lcov.info
genhtml --output-directory /tmp/coverage/html --legend --branch-coverage coverage_lcov.info

# Or generate llvm html report (better templates visualization!):
llvm-cov show -instr-profile=all.profdata -format=html --output-dir=/tmp/coverage/html src/test/test_bitcoin -object=src/bitcoind

@maflcko maflcko merged commit 038a04e into bitcoin:master Aug 12, 2020
@hebasto hebasto deleted the 200808-lcov branch August 13, 2020 07:56
@hebasto
Copy link
Member Author

hebasto commented Aug 13, 2020

make cov still hanging after ~11+ hours on test_bitcoin-util_tests.gcda

I've narrowed this problem down to

BOOST_AUTO_TEST_CASE(util_ReadConfigStream)

@hebasto
Copy link
Member Author

hebasto commented Aug 13, 2020

@Crypt-iQ

make cov still hanging after ~11+ hours on test_bitcoin-util_tests.gcda

Fixed in #19709.

sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Aug 14, 2020
75f9659 build: Add missed fuzz.coverage/ directory to .gitignore (Hennadii Stepanov)
8ebc050 build: Add missed fuzz_filtered.info to COVERAGE_INFO (Hennadii Stepanov)
c71bdf9 build, test: Add support for llvm-cov (Hennadii Stepanov)

Pull request description:

  With this PR it is possible to use `lcov` with clang:
  ```
  $ ./autogen.sh
  $ ./configure --enable-lcov --enable-fuzz --with-sanitizers=fuzzer CC=clang CXX=clang++
  $ make
  $ make cov_fuzz
  ```

  ---

  NOTE: Unfortunately, on my system (`clang version 10.0.0-4ubuntu1`) due to unknown for me reasons `make cov` never finishes, trying to `Processing src/test/test_bitcoin-util_tests.gcda` forever (stopped waiting).

  Closes bitcoin#12602

ACKs for top commit:
  Crypt-iQ:
    Tested ACK 75f9659
  vasild:
    ACK 75f9659

Tree-SHA512: 4bc31b38fa62d70c21f890f17f0340e64d0509cea3c29ff6ac101e90ae65d2032640abf100a380c31557bea4c3f54301c2acc2b88a00cbc5261d54c01358ce4e
maflcko pushed a commit that referenced this pull request Aug 14, 2020
35cd2da test: Fix 'make cov' with clang (Hennadii Stepanov)

Pull request description:

  This is a follow up of #19688.

  With this PR it is possible to do the following:
  ```
  $ ./autogen.sh
  $ ./configure --enable-lcov CC=clang CXX=clang++
  $ make
  $ make cov
  ```

  Currently, on master (8a85377), `make cov` fails to `Processing src/test/test_bitcoin-util_tests.gcda`.

ACKs for top commit:
  vasild:
    ACK 35cd2da
  Crypt-iQ:
    ACK 35cd2da

Tree-SHA512: aaf56118e2644064e9738a8279889c617db5805c5c804c904469b24c496bd609f9c5fc2aebcf1a422f8a5ed2eb38bd6e76b484680310b55c36d922b73a4c33cf
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Feb 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

lcov usage fails with clang
6 participants