From: Remi Gacogne Date: Thu, 14 Sep 2023 12:59:29 +0000 (+0200) Subject: Update the code coverage m4 to support modern options, hook it up X-Git-Tag: rec-5.0.0-alpha2~20^2~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a985c6a731664e4c95fe4c5a5a0b3792546525fb;p=thirdparty%2Fpdns.git Update the code coverage m4 to support modern options, hook it up --- diff --git a/configure.ac b/configure.ac index 8f6fde4604..348127854d 100644 --- a/configure.ac +++ b/configure.ac @@ -130,6 +130,7 @@ PDNS_ENABLE_UNIT_TESTS PDNS_ENABLE_BACKEND_UNIT_TESTS PDNS_ENABLE_REPRODUCIBLE PDNS_ENABLE_FUZZ_TARGETS +PDNS_ENABLE_COVERAGE PDNS_WITH_SQLITE3 diff --git a/m4/pdns_enable_coverage.m4 b/m4/pdns_enable_coverage.m4 index 17846ffa16..9e06468bc9 100644 --- a/m4/pdns_enable_coverage.m4 +++ b/m4/pdns_enable_coverage.m4 @@ -7,9 +7,24 @@ AC_DEFUN([PDNS_ENABLE_COVERAGE], [ [enable_coverage=no] ) AC_MSG_RESULT([$enable_coverage]) - AS_IF([test "x$enable_coverage" != "xno"], [ + + AS_IF([test "x$enable_coverage" = "xclang"], [ + dnl let's see if the clang++ specific format is supported, + dnl as it has a much lower overhead and is more accurate, + dnl see https://clang.llvm.org/docs/SourceBasedCodeCoverage.html + gl_COMPILER_OPTION_IF([-fprofile-instr-generate -fcoverage-mapping], [ + CFLAGS="$CFLAGS -DCOVERAGE -DCLANG_COVERAGE -fprofile-instr-generate -fcoverage-mapping" + CXXFLAGS="$CXXFLAGS -DCOVERAGE -DCLANG_COVERAGE -fprofile-instr-generate -fcoverage-mapping" + ], [ + AC_MSG_ERROR([$CXX does not support gathering coverage data in the clang format]) + ]) + ]) + + AS_IF([test "x$enable_coverage" = "xyes"], [ gl_COMPILER_OPTION_IF([-fprofile-arcs -ftest-coverage], [ - CXXFLAGS="$CXXFLAGS -U_FORTIFY_SOURCE -g -O0 -fprofile-arcs -ftest-coverage" + CFLAGS="$CFLAGS -DCOVERAGE --coverage" + CXXFLAGS="$CXXFLAGS -DCOVERAGE --coverage" + LDFLAGS="$LDFLAGS --coverage" ], [ AC_MSG_ERROR([$CXX does not support gathering coverage data]) ]) diff --git a/pdns/dnsdistdist/configure.ac b/pdns/dnsdistdist/configure.ac index feeeba3a12..e30075c25c 100644 --- a/pdns/dnsdistdist/configure.ac +++ b/pdns/dnsdistdist/configure.ac @@ -131,6 +131,7 @@ PDNS_INIT_AUTO_VARS PDNS_ENABLE_SANITIZERS PDNS_ENABLE_LTO +PDNS_ENABLE_COVERAGE PDNS_CHECK_PYTHON_VENV diff --git a/pdns/dnsdistdist/m4/pdns_enable_coverage.m4 b/pdns/dnsdistdist/m4/pdns_enable_coverage.m4 new file mode 120000 index 0000000000..9af5272b6a --- /dev/null +++ b/pdns/dnsdistdist/m4/pdns_enable_coverage.m4 @@ -0,0 +1 @@ +../../../m4/pdns_enable_coverage.m4 \ No newline at end of file diff --git a/pdns/recursordist/configure.ac b/pdns/recursordist/configure.ac index 231f3ae7a2..f1f1a504c6 100644 --- a/pdns/recursordist/configure.ac +++ b/pdns/recursordist/configure.ac @@ -66,6 +66,7 @@ AS_IF([test -n "$pdns_context_library"], [AC_MSG_RESULT([$pdns_context_library]) PDNS_ENABLE_UNIT_TESTS PDNS_ENABLE_REPRODUCIBLE +PDNS_ENABLE_COVERAGE PDNS_WITH_LUA([mandatory]) AS_IF([test "x$LUAPC" = "xluajit"], [ diff --git a/pdns/recursordist/m4/pdns_enable_coverage.m4 b/pdns/recursordist/m4/pdns_enable_coverage.m4 new file mode 120000 index 0000000000..9af5272b6a --- /dev/null +++ b/pdns/recursordist/m4/pdns_enable_coverage.m4 @@ -0,0 +1 @@ +../../../m4/pdns_enable_coverage.m4 \ No newline at end of file