Skip to content

build: Add support for llvm-cov - #19688

Merged
maflcko merged 3 commits into
bitcoin:masterfrom
hebasto:200808-lcov
Aug 12, 2020
Merged

maflcko merged 3 commits into
bitcoin:masterfrom
hebasto:200808-lcov

Conversation

@hebasto

@hebasto hebasto commented Aug 8, 2020

Copy link
Copy Markdown
Member

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

hebasto commented Aug 8, 2020

Copy link
Copy Markdown
Member Author

friendly ping @practicalswift @Crypt-iQ @darosior

@fjahr

fjahr commented Aug 9, 2020

Copy link
Copy Markdown
Contributor

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

Crypt-iQ commented Aug 10, 2020 •

Copy link
Copy Markdown
Contributor

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

@vasild vasild left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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.

@maflcko maflcko left a comment

Copy link
Copy Markdown
Member

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

Comment thread Makefile.am

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

Copy link
Copy Markdown
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
Copy Markdown
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

hebasto commented Aug 13, 2020

Copy link
Copy Markdown
Member Author

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

hebasto commented Aug 13, 2020

Copy link
Copy Markdown
Member Author

@Crypt-iQ

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

Fixed in #19709.

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