Skip to content

Commit 9d227e8

Browse files
kwvgPastaPastaPasta
authored andcommitted
merge bitcoin#19688: Add support for llvm-cov
1 parent 6e4c9b5 commit 9d227e8

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
@@ -120,7 +120,9 @@ releases
120120
/*.info
121121
test_dash.coverage/
122122
total.coverage/
123+
fuzz.coverage/
123124
coverage_percent.txt
125+
/cov_tool_wrapper.sh
124126

125127
#build tests
126128
linux-coverage-build

Makefile.am

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ WINDOWS_PACKAGING = $(top_srcdir)/share/pixmaps/dash.ico \
6161
OSX_PACKAGING = $(OSX_DEPLOY_SCRIPT) $(OSX_INSTALLER_ICONS) \
6262
$(top_srcdir)/contrib/macdeploy/detached-sig-create.sh
6363

64-
COVERAGE_INFO = baseline.info \
64+
COVERAGE_INFO = $(COV_TOOL_WRAPPER) baseline.info \
6565
test_dash_filtered.info total_coverage.info \
6666
baseline_filtered.info functional_test.info functional_test_filtered.info \
67-
test_dash_coverage.info test_dash.info fuzz.info fuzz_coverage.info
67+
test_dash_coverage.info test_dash.info fuzz.info fuzz_filtered.info fuzz_coverage.info
6868

6969
dist-hook:
7070
-$(GIT) archive --format=tar HEAD -- src/clientversion.cpp | $(AMTAR) -C $(top_distdir) -xf -
@@ -171,7 +171,11 @@ LCOV_FILTER_PATTERN = \
171171
-p "src/secp256k1" \
172172
-p "depends"
173173

174-
baseline.info:
174+
$(COV_TOOL_WRAPPER):
175+
@echo 'exec $(COV_TOOL) "$$@"' > $(COV_TOOL_WRAPPER)
176+
@chmod +x $(COV_TOOL_WRAPPER)
177+
178+
baseline.info: $(COV_TOOL_WRAPPER)
175179
$(LCOV) -c -i -d $(abs_builddir)/src -o $@
176180

177181
baseline_filtered.info: baseline.info

configure.ac

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ AC_PATH_TOOL(AR, ar)
9898
AC_PATH_TOOL(RANLIB, ranlib)
9999
AC_PATH_TOOL(STRIP, strip)
100100
AC_PATH_TOOL(GCOV, gcov)
101+
AC_PATH_TOOL(LLVM_COV, llvm-cov)
101102
AC_PATH_PROG(LCOV, lcov)
102103
dnl Python 3.8 is specified in .python-version and should be used if available, see doc/dependencies.md
103104
AC_PATH_PROGS([PYTHON], [python3.8 python3.9 python3.10 python3.11 python3.12 python3 python])
@@ -810,16 +811,37 @@ if test x$use_lcov = xyes; then
810811
if test x$LCOV = x; then
811812
AC_MSG_ERROR("lcov testing requested but lcov not found")
812813
fi
813-
if test x$GCOV = x; then
814-
AC_MSG_ERROR("lcov testing requested but gcov not found")
815-
fi
816814
if test x$PYTHON = x; then
817815
AC_MSG_ERROR("lcov testing requested but python not found")
818816
fi
819817
if test x$GENHTML = x; then
820818
AC_MSG_ERROR("lcov testing requested but genhtml not found")
821819
fi
822-
LCOV="$LCOV --gcov-tool=$GCOV"
820+
821+
AC_MSG_CHECKING([whether compiler is Clang])
822+
AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
823+
#if defined(__clang__) && defined(__llvm__)
824+
// Compiler is Clang
825+
#else
826+
# error Compiler is not Clang
827+
#endif
828+
]])],[
829+
AC_MSG_RESULT([yes])
830+
if test x$LLVM_COV = x; then
831+
AC_MSG_ERROR([lcov testing requested but llvm-cov not found])
832+
fi
833+
COV_TOOL="$LLVM_COV gcov"
834+
],[
835+
AC_MSG_RESULT([no])
836+
if test x$GCOV = x; then
837+
AC_MSG_ERROR([lcov testing requested but gcov not found])
838+
fi
839+
COV_TOOL="$GCOV"
840+
])
841+
AC_SUBST(COV_TOOL)
842+
AC_SUBST(COV_TOOL_WRAPPER, "cov_tool_wrapper.sh")
843+
LCOV="$LCOV --gcov-tool $(pwd)/$COV_TOOL_WRAPPER"
844+
823845
AX_CHECK_LINK_FLAG([[--coverage]], [LDFLAGS="$LDFLAGS --coverage"],
824846
[AC_MSG_ERROR("lcov testing requested but --coverage linker flag does not work")])
825847
AX_CHECK_COMPILE_FLAG([--coverage],[CXXFLAGS="$CXXFLAGS --coverage"],

0 commit comments

Comments
 (0)