Skip to content

Commit 038a04e

Browse files
author
MarcoFalke
committed
Merge #19688: build: Add support for llvm-cov
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 #12602 ACKs for top commit: Crypt-iQ: Tested ACK 75f9659 vasild: ACK 75f9659 Tree-SHA512: 4bc31b38fa62d70c21f890f17f0340e64d0509cea3c29ff6ac101e90ae65d2032640abf100a380c31557bea4c3f54301c2acc2b88a00cbc5261d54c01358ce4e
2 parents 13c4635 + 75f9659 commit 038a04e

File tree

3 files changed

+35
-7
lines changed

3 files changed

+35
-7
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ releases
119119
/*.info
120120
test_bitcoin.coverage/
121121
total.coverage/
122+
fuzz.coverage/
122123
coverage_percent.txt
124+
/cov_tool_wrapper.sh
123125

124126
#build tests
125127
linux-coverage-build

Makefile.am

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ OSX_PACKAGING = $(OSX_DEPLOY_SCRIPT) $(OSX_FANCY_PLIST) $(OSX_INSTALLER_ICONS) \
6565
$(top_srcdir)/contrib/macdeploy/detached-sig-apply.sh \
6666
$(top_srcdir)/contrib/macdeploy/detached-sig-create.sh
6767

68-
COVERAGE_INFO = baseline.info \
68+
COVERAGE_INFO = $(COV_TOOL_WRAPPER) baseline.info \
6969
test_bitcoin_filtered.info total_coverage.info \
7070
baseline_filtered.info functional_test.info functional_test_filtered.info \
71-
test_bitcoin_coverage.info test_bitcoin.info fuzz.info fuzz_coverage.info
71+
test_bitcoin_coverage.info test_bitcoin.info fuzz.info fuzz_filtered.info fuzz_coverage.info
7272

7373
dist-hook:
7474
-$(GIT) archive --format=tar HEAD -- src/clientversion.cpp | $(AMTAR) -C $(top_distdir) -xf -
@@ -192,7 +192,11 @@ LCOV_FILTER_PATTERN = \
192192
-p "src/secp256k1" \
193193
-p "depends"
194194

195-
baseline.info:
195+
$(COV_TOOL_WRAPPER):
196+
@echo 'exec $(COV_TOOL) "$$@"' > $(COV_TOOL_WRAPPER)
197+
@chmod +x $(COV_TOOL_WRAPPER)
198+
199+
baseline.info: $(COV_TOOL_WRAPPER)
196200
$(LCOV) -c -i -d $(abs_builddir)/src -o $@
197201

198202
baseline_filtered.info: baseline.info

configure.ac

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ AC_PATH_TOOL(AR, ar)
105105
AC_PATH_TOOL(RANLIB, ranlib)
106106
AC_PATH_TOOL(STRIP, strip)
107107
AC_PATH_TOOL(GCOV, gcov)
108+
AC_PATH_TOOL(LLVM_COV, llvm-cov)
108109
AC_PATH_PROG(LCOV, lcov)
109110
dnl Python 3.5 is specified in .python-version and should be used if available, see doc/dependencies.md
110111
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
680681
if test x$LCOV = x; then
681682
AC_MSG_ERROR("lcov testing requested but lcov not found")
682683
fi
683-
if test x$GCOV = x; then
684-
AC_MSG_ERROR("lcov testing requested but gcov not found")
685-
fi
686684
if test x$PYTHON = x; then
687685
AC_MSG_ERROR("lcov testing requested but python not found")
688686
fi
689687
if test x$GENHTML = x; then
690688
AC_MSG_ERROR("lcov testing requested but genhtml not found")
691689
fi
692-
LCOV="$LCOV --gcov-tool=$GCOV"
690+
691+
AC_MSG_CHECKING([whether compiler is Clang])
692+
AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
693+
#if defined(__clang__) && defined(__llvm__)
694+
// Compiler is Clang
695+
#else
696+
# error Compiler is not Clang
697+
#endif
698+
]])],[
699+
AC_MSG_RESULT([yes])
700+
if test x$LLVM_COV = x; then
701+
AC_MSG_ERROR([lcov testing requested but llvm-cov not found])
702+
fi
703+
COV_TOOL="$LLVM_COV gcov"
704+
],[
705+
AC_MSG_RESULT([no])
706+
if test x$GCOV = x; then
707+
AC_MSG_ERROR([lcov testing requested but gcov not found])
708+
fi
709+
COV_TOOL="$GCOV"
710+
])
711+
AC_SUBST(COV_TOOL)
712+
AC_SUBST(COV_TOOL_WRAPPER, "cov_tool_wrapper.sh")
713+
LCOV="$LCOV --gcov-tool $(pwd)/$COV_TOOL_WRAPPER"
714+
693715
AX_CHECK_LINK_FLAG([[--coverage]], [LDFLAGS="$LDFLAGS --coverage"],
694716
[AC_MSG_ERROR("lcov testing requested but --coverage linker flag does not work")])
695717
AX_CHECK_COMPILE_FLAG([--coverage],[CXXFLAGS="$CXXFLAGS --coverage"],

0 commit comments

Comments
 (0)