public inbox for [email protected]  
help / color / mirror / Atom feed
From: Narek Galstyan <[email protected]>
To: [email protected]
Cc: [email protected] <[email protected]>
Cc: [email protected]
Subject: Coverage with make coverage-html is broken on latest Debian using lcov v2
Date: Tue, 21 Apr 2026 10:36:11 -0400
Message-ID: <CAHsn6_xCDQWe8_vVFhtFk27_xTdyVV+Dr0yWzaooBZ6+-VH-5w@mail.gmail.com> (raw)

Hi all,

On Debian 13 (trixie), `make coverage-html` command triggers an lcov
failure.
There have been past reports of this failure in pgsql-hackers here
<https://www.postgresql.org/message-id/202602261231.mlk2icrqrwpw%40alvherre.pgsql;
.

APT package repositories on Debian 13  default to lcov v2 (2.3.1-1) which
is stricter about a few warnings and triggers an error. This commit
<https://github.com/linux-test-project/lcov/commit/5f659f63801ef7f94c50a0eb5cffa1ea70f73651>in
lcov details some of the changes for lcov v2, including the stricter error
handling (see bullet b)).

After applying the attached patches to the current master branch, `make
coverage-html` starts working with lcov v2.

---

More details:

Without applying any of the patches, with --enable-coverage and in-tree
build (no vpath), make check && make coverage-html results in the following
error:

```
/usr/bin/lcov --gcov-tool /usr/bin/gcov -q --no-external -c -i -d . -d . -o
lcov_base.info
lcov: ERROR: (usage) duplicate file ./src/backend/access/table/tableam.gcno
in both . and .
        (use "lcov --ignore-errors usage ..." to bypass this error)
Message summary:
  1 error message:
    usage: 1
make: *** [src/Makefile.global:1064: lcov_base.info] Error 1
```


After applying the first patch, I get this error:

```

genhtml: ERROR: (corrupt) unable to read trace file 'lcov_base.info':
genhtml: ERROR: (inconsistent) "lcov_base.info":507880: duplicate function
'blockreftable_create' starts on line
"/home/admin/postgres/src/include/lib/simplehash.h":450 but previous
definition started on 447 while merging lcov_base.info while loading
lcov_base.info.
        (use "genhtml --ignore-errors inconsistent ..." to bypass this
error)
        (use "genhtml --ignore-errors corrupt ..." to bypass this error)
make: *** [src/Makefile.global:1055: coverage-html-stamp] Error 1

```


With the other 2 patches also applied, make check && make coverage-html
starts producing proper reports.
I tested `make coverage-html` on Debian 13 with lcov v1 and everything
worked there as well.

Narek
--


Attachments:

  [application/octet-stream] 0003-Regenerate-configure-after-make-coverage-html-fixes-.patch (956B, 3-0003-Regenerate-configure-after-make-coverage-html-fixes-.patch)
  download | inline diff:
From 3223ed56602ae13f0ca6c6fbf2eea8eebc611379 Mon Sep 17 00:00:00 2001
From: Narek Galstyan <[email protected]>
Date: Sun, 19 Apr 2026 22:11:25 -0400
Subject: [PATCH 3/3] Regenerate configure after make coverage-html fixes for
 lcov v2

---
 configure | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/configure b/configure
index f66c1054a7a..c0d24bc13ff 100755
--- a/configure
+++ b/configure
@@ -777,6 +777,7 @@ enable_tap_tests
 enable_dtrace
 DTRACEFLAGS
 DTRACE
+LCOV_EXTRA_FLAGS
 enable_coverage
 GENHTML
 LCOV
@@ -3474,6 +3475,11 @@ fi
 if test -z "$LCOV"; then
   as_fn_error $? "lcov not found" "$LINENO" 5
 fi
+lcov_version=$($LCOV --version 2>/dev/null | sed 's/^.* //')
+lcov_major_version=$(echo "$lcov_version" | sed 's/\..*//')
+if test "$lcov_major_version" -ge 2 2>/dev/null; then
+  LCOV_EXTRA_FLAGS="--ignore-errors inconsistent,range"
+fi
 if test -z "$GENHTML"; then
   for ac_prog in genhtml
 do
-- 
2.50.1 (Apple Git-155)



  [application/octet-stream] 0002-Add-minimal-lcov-ignore-errors-flags-to-avoid-make-c.patch (2.3K, 4-0002-Add-minimal-lcov-ignore-errors-flags-to-avoid-make-c.patch)
  download | inline diff:
From 47c778d3b8d09f9ec84f0336db6eafda175e63b3 Mon Sep 17 00:00:00 2001
From: Narek Galstyan <[email protected]>
Date: Sun, 19 Apr 2026 22:11:23 -0400
Subject: [PATCH 2/3] Add minimal lcov --ignore-errors flags to avoid `make
 coverage-html` failure on lcov v2

Without this change, lcov v2 fails with:

genhtml: ERROR: (corrupt) unable to read trace file 'lcov_base.info':
genhtml: ERROR: (inconsistent) "lcov_base.info":507880: duplicate
function 'blockreftable_create' starts on line
"/home/admin/postgres/src/include/lib/simplehash.h":450 but previous
definition started on 447 while merging lcov_base.info while loading
lcov_base.info.
        (use "genhtml --ignore-errors inconsistent ..." to bypass this
error)
        (use "genhtml --ignore-errors corrupt ..." to bypass this error)
make: *** [src/Makefile.global:1055: coverage-html-stamp] Error 1
---
 configure.ac           | 6 ++++++
 src/Makefile.global.in | 4 ++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 8d176bd3468..12006b0b4b6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -207,11 +207,17 @@ PGAC_PATH_PROGS(LCOV, lcov)
 if test -z "$LCOV"; then
   AC_MSG_ERROR([lcov not found])
 fi
+lcov_version=$($LCOV --version 2>/dev/null | sed 's/^.* //')
+lcov_major_version=$(echo "$lcov_version" | sed 's/\..*//')
+if test "$lcov_major_version" -ge 2 2>/dev/null; then
+  LCOV_EXTRA_FLAGS="--ignore-errors inconsistent,range"
+fi
 PGAC_PATH_PROGS(GENHTML, genhtml)
 if test -z "$GENHTML"; then
   AC_MSG_ERROR([genhtml not found])
 fi])
 AC_SUBST(enable_coverage)
+AC_SUBST(LCOV_EXTRA_FLAGS)
 
 #
 # DTrace
diff --git a/src/Makefile.global.in b/src/Makefile.global.in
index dbd5f9d3c40..e0766325d60 100644
--- a/src/Makefile.global.in
+++ b/src/Makefile.global.in
@@ -1047,7 +1047,7 @@ coverage: $(local_gcda_files:.gcda=.c.gcov)
 .PHONY: coverage-html
 coverage-html: coverage-html-stamp
 
-GENHTML_FLAGS = -q --legend
+GENHTML_FLAGS = -q --legend @LCOV_EXTRA_FLAGS@
 GENHTML_TITLE = PostgreSQL $(VERSION)
 
 coverage-html-stamp: lcov_base.info lcov_test.info
@@ -1056,7 +1056,7 @@ coverage-html-stamp: lcov_base.info lcov_test.info
 	touch $@
 
 LCOV += --gcov-tool $(GCOV)
-LCOVFLAGS = -q --no-external
+LCOVFLAGS = -q --no-external @LCOV_EXTRA_FLAGS@
 
 all_gcno_files = $(shell find . -name '*.gcno' -print)
 
-- 
2.50.1 (Apple Git-155)



  [application/octet-stream] 0001-Fix-lcov-duplicate-directory-error-for-non-vpath-bui.patch (1.7K, 5-0001-Fix-lcov-duplicate-directory-error-for-non-vpath-bui.patch)
  download | inline diff:
From 957a51a4dad2c82e0ced61ac5813f87ab6752dd7 Mon Sep 17 00:00:00 2001
From: Narek Galstyan <[email protected]>
Date: Sun, 19 Apr 2026 22:07:03 -0400
Subject: [PATCH 1/3] Fix lcov duplicate directory error for non-vpath builds

Fixes `make coverage-html` target on lcov v2 (default on latest Debian).

Commit c3d9a66024a9 added -d $(srcdir) to the lcov commands to support
vpath builds, but did so unconditionally. For non-vpath (in-tree)
builds, $(srcdir) is ".", resulting in "-d . -d ." which causes lcov to
fail with a duplicate file error.
lcov: ERROR: (usage) duplicate file ./src/pl/plpgsql/src/pl_gram.gcno i
both . and .
    (use "lcov --ignore-errors usage ..." to bypass this error)
Message summary:
  1 error message:
    usage: 1
The fix used the same pattern used in commit 5f340cb30ce2 for the
genhtml --prefix option: only add -d $(srcdir) when vpath_build is yes.
---
 src/Makefile.global.in | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/Makefile.global.in b/src/Makefile.global.in
index cef1ad7f87d..dbd5f9d3c40 100644
--- a/src/Makefile.global.in
+++ b/src/Makefile.global.in
@@ -1061,12 +1061,12 @@ LCOVFLAGS = -q --no-external
 all_gcno_files = $(shell find . -name '*.gcno' -print)
 
 lcov_base.info: $(all_gcno_files)
-	$(LCOV) $(LCOVFLAGS) -c -i -d . -d $(srcdir) -o $@
+	$(LCOV) $(LCOVFLAGS) -c -i -d . $(if $(filter yes,$(vpath_build)),-d $(srcdir)) -o $@
 
 all_gcda_files = $(shell find . -name '*.gcda' -print)
 
 lcov_test.info: $(all_gcda_files)
-	$(LCOV) $(LCOVFLAGS) -c -d . -d $(srcdir) -o $@
+	$(LCOV) $(LCOVFLAGS) -c -d . $(if $(filter yes,$(vpath_build)),-d $(srcdir)) -o $@
 
 
 # hook for clean-up
-- 
2.50.1 (Apple Git-155)



reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: Coverage with make coverage-html is broken on latest Debian using lcov v2
  In-Reply-To: <CAHsn6_xCDQWe8_vVFhtFk27_xTdyVV+Dr0yWzaooBZ6+-VH-5w@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox