From 7f4e6f50de6e8201f656a0cf55aa5c59166cbe54 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sat, 3 Oct 2026 14:44:39 -0400 Subject: [PATCH] Fix lcov duplicate directory specification in non-VPATH builds. In an in-tree build, "make coverage-html" invoked lcov with two "-d ." options, because $(srcdir) is just ".". With lcov 2.0 (and perhaps earlier versions?) that results in scanning every foo.gcda file twice and producing counts twice what they should be. With later lcov versions (at least 2.3), it results in "duplicate file" errors. In VPATH builds we do need two -d options to cover both regular and generated .c files. But in in-tree builds it suffices to specify "-d .", so suppress the second switch. Author: Narek Galstyan Reviewed-by: Tom Lane Discussion: https://postgr.es/m/CAHsn6_xCDQWe8_vVFhtFk27_xTdyVV+Dr0yWzaooBZ6+-VH-5w@mail.gmail.com Backpatch-through: 14 --- 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 ce05cc1429a..6676f2140e3 100644 --- a/src/Makefile.global.in +++ b/src/Makefile.global.in @@ -1051,12 +1051,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