diff options
author | MarcoFalke <falke.marco@gmail.com> | 2020-08-12 22:20:16 +0200 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2020-08-12 22:21:04 +0200 |
commit | 038a04eb80a5d3c731ffdbc7d855aced50270eed (patch) | |
tree | 2573204661efc54938957691cbe9497f985a9d0c | |
parent | 13c4635a3ecfbc6759301fb3c94bd5293c49388c (diff) | |
parent | 75f9659d7a497ae1f86d905029f83c0193ecfeb2 (diff) |
Merge #19688: build: Add support for llvm-cov
75f9659d7a497ae1f86d905029f83c0193ecfeb2 build: Add missed fuzz.coverage/ directory to .gitignore (Hennadii Stepanov)
8ebc0505e98f68cb51e9d6e2b47bf54eab530693 build: Add missed fuzz_filtered.info to COVERAGE_INFO (Hennadii Stepanov)
c71bdf93d7bb2b7aa368a49538edb9c3df2c74f8 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 #12602
ACKs for top commit:
Crypt-iQ:
Tested ACK 75f9659d7a497ae1f86d905029f83c0193ecfeb2
vasild:
ACK 75f9659d7
Tree-SHA512: 4bc31b38fa62d70c21f890f17f0340e64d0509cea3c29ff6ac101e90ae65d2032640abf100a380c31557bea4c3f54301c2acc2b88a00cbc5261d54c01358ce4e
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | Makefile.am | 10 | ||||
-rw-r--r-- | configure.ac | 30 |
3 files changed, 35 insertions, 7 deletions
diff --git a/.gitignore b/.gitignore index 3e5d284aa3..1173edfaa7 100644 --- a/.gitignore +++ b/.gitignore @@ -119,7 +119,9 @@ releases /*.info test_bitcoin.coverage/ total.coverage/ +fuzz.coverage/ coverage_percent.txt +/cov_tool_wrapper.sh #build tests linux-coverage-build diff --git a/Makefile.am b/Makefile.am index 75a164f49e..1d6358b1d5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -65,10 +65,10 @@ OSX_PACKAGING = $(OSX_DEPLOY_SCRIPT) $(OSX_FANCY_PLIST) $(OSX_INSTALLER_ICONS) \ $(top_srcdir)/contrib/macdeploy/detached-sig-apply.sh \ $(top_srcdir)/contrib/macdeploy/detached-sig-create.sh -COVERAGE_INFO = baseline.info \ +COVERAGE_INFO = $(COV_TOOL_WRAPPER) baseline.info \ test_bitcoin_filtered.info total_coverage.info \ baseline_filtered.info functional_test.info functional_test_filtered.info \ - test_bitcoin_coverage.info test_bitcoin.info fuzz.info fuzz_coverage.info + test_bitcoin_coverage.info test_bitcoin.info fuzz.info fuzz_filtered.info fuzz_coverage.info dist-hook: -$(GIT) archive --format=tar HEAD -- src/clientversion.cpp | $(AMTAR) -C $(top_distdir) -xf - @@ -192,7 +192,11 @@ LCOV_FILTER_PATTERN = \ -p "src/secp256k1" \ -p "depends" -baseline.info: +$(COV_TOOL_WRAPPER): + @echo 'exec $(COV_TOOL) "$$@"' > $(COV_TOOL_WRAPPER) + @chmod +x $(COV_TOOL_WRAPPER) + +baseline.info: $(COV_TOOL_WRAPPER) $(LCOV) -c -i -d $(abs_builddir)/src -o $@ baseline_filtered.info: baseline.info diff --git a/configure.ac b/configure.ac index 2381c5dd08..2acd702600 100644 --- a/configure.ac +++ b/configure.ac @@ -105,6 +105,7 @@ AC_PATH_TOOL(AR, ar) AC_PATH_TOOL(RANLIB, ranlib) AC_PATH_TOOL(STRIP, strip) AC_PATH_TOOL(GCOV, gcov) +AC_PATH_TOOL(LLVM_COV, llvm-cov) AC_PATH_PROG(LCOV, lcov) dnl Python 3.5 is specified in .python-version and should be used if available, see doc/dependencies.md AC_PATH_PROGS([PYTHON], [python3.5 python3.6 python3.7 python3.8 python3 python]) @@ -680,16 +681,37 @@ if test x$use_lcov = xyes; then if test x$LCOV = x; then AC_MSG_ERROR("lcov testing requested but lcov not found") fi - if test x$GCOV = x; then - AC_MSG_ERROR("lcov testing requested but gcov not found") - fi if test x$PYTHON = x; then AC_MSG_ERROR("lcov testing requested but python not found") fi if test x$GENHTML = x; then AC_MSG_ERROR("lcov testing requested but genhtml not found") fi - LCOV="$LCOV --gcov-tool=$GCOV" + + AC_MSG_CHECKING([whether compiler is Clang]) + AC_PREPROC_IFELSE([AC_LANG_SOURCE([[ + #if defined(__clang__) && defined(__llvm__) + // Compiler is Clang + #else + # error Compiler is not Clang + #endif + ]])],[ + AC_MSG_RESULT([yes]) + if test x$LLVM_COV = x; then + AC_MSG_ERROR([lcov testing requested but llvm-cov not found]) + fi + COV_TOOL="$LLVM_COV gcov" + ],[ + AC_MSG_RESULT([no]) + if test x$GCOV = x; then + AC_MSG_ERROR([lcov testing requested but gcov not found]) + fi + COV_TOOL="$GCOV" + ]) + AC_SUBST(COV_TOOL) + AC_SUBST(COV_TOOL_WRAPPER, "cov_tool_wrapper.sh") + LCOV="$LCOV --gcov-tool $(pwd)/$COV_TOOL_WRAPPER" + AX_CHECK_LINK_FLAG([[--coverage]], [LDFLAGS="$LDFLAGS --coverage"], [AC_MSG_ERROR("lcov testing requested but --coverage linker flag does not work")]) AX_CHECK_COMPILE_FLAG([--coverage],[CXXFLAGS="$CXXFLAGS --coverage"], |