On 06.08.25 21:11, Tom Lane wrote:
Peter Eisentraut <pe...@eisentraut.org> writes:
On 05.08.25 20:09, Tom Lane wrote:
Curiously, no such complaints appear with cpluspluscheck (which is
using g++ 15.1.1). I don't really understand why not ...
-Wmissing-variable-declarations is added by us as of PG18 (commit
66188912566). It's available since gcc 14 and doesn't exist for C++.
Oh! Okay, that explains the lack of messages, but it still seems
like an odd omission.
Yeah, this is pretty much my fault for not checking this for the above
commit.
I've been having a hard time getting headerscheck to work reliably in my
environment, so I ended up relying on CI, which doesn't have new-enough
compilers yet (and/or doesn't run it everywhere; the clang on the
FreeBSD task might have caught it (but we also don't have this
integrated with meson yet)).
Attached are three patches to fix some unrelated problems with
headerscheck in my environment.
The fourth one is to fix the ecpg issue; I think we can ignore it under
the "code fragment" category.
kwlist_d.h doesn't show up in my run, probably because I'm using a
separate build directory, which headerscheck doesn't handle? Another
thing to fix. But I guess it would also fall under the code fragment
category?
But the code fragment exception is also faulty, because we plausibly do
want to check that file for C++ compatibility, just not necessarily as a
standalone file. Not sure how to cover all these bases at once.From f40b5a065d96b3bca7c1e535cee81c89ee202c9e Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pe...@eisentraut.org>
Date: Thu, 7 Aug 2025 15:55:04 +0200
Subject: [PATCH 1/4] headerscheck: Use ICU_CFLAGS
Otherwise, headerscheck will fail if the ICU headers are in a location
not reached by the normal CFLAGS/CPPFLAGS:
../src/include/utils/pg_locale.h:21:10: fatal error: unicode/ucol.h: No such
file or directory
---
src/tools/pginclude/headerscheck | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/tools/pginclude/headerscheck b/src/tools/pginclude/headerscheck
index 9e86d049362..30afa967305 100755
--- a/src/tools/pginclude/headerscheck
+++ b/src/tools/pginclude/headerscheck
@@ -44,6 +44,7 @@ CXXFLAGS=${CXXFLAGS:- -fsyntax-only -Wall}
MGLOB="$builddir/src/Makefile.global"
CPPFLAGS=`sed -n 's/^CPPFLAGS[ ]*=[ ]*//p' "$MGLOB"`
CFLAGS=`sed -n 's/^CFLAGS[ ]*=[ ]*//p' "$MGLOB"`
+ICU_CFLAGS=`sed -n 's/^ICU_CFLAGS[ ]*=[ ]*//p' "$MGLOB"`
CC=`sed -n 's/^CC[ ]*=[ ]*//p' "$MGLOB"`
CXX=`sed -n 's/^CXX[ ]*=[ ]*//p' "$MGLOB"`
PG_SYSROOT=`sed -n 's/^PG_SYSROOT[ ]*=[ ]*//p' "$MGLOB"`
@@ -64,11 +65,11 @@ if $cplusplus; then
-I*|-D*) CXXPPFLAGS="$CXXPPFLAGS $flag";;
esac
done
- COMPILER_FLAGS="$CXXPPFLAGS $CXXFLAGS"
+ COMPILER_FLAGS="$CXXPPFLAGS $CXXFLAGS $ICU_CFLAGS"
else
ext=c
COMPILER=${CC:-gcc}
- COMPILER_FLAGS="$CPPFLAGS $CFLAGS"
+ COMPILER_FLAGS="$CPPFLAGS $CFLAGS $ICU_CFLAGS"
fi
# Create temp directory.
--
2.50.1
From eedfa689ce1a940b1187bcbd29d65437999052d6 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pe...@eisentraut.org>
Date: Thu, 7 Aug 2025 15:57:12 +0200
Subject: [PATCH 2/4] headerscheck: Ignore llvmjit_backport.h
This requires --with-llvm, which is not always active. (So perhaps in
a similar category as sepgsql.h.)
XXX alternative: Only check if --with-llvm is enabled?
---
src/tools/pginclude/headerscheck | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/tools/pginclude/headerscheck b/src/tools/pginclude/headerscheck
index 30afa967305..e984a441edb 100755
--- a/src/tools/pginclude/headerscheck
+++ b/src/tools/pginclude/headerscheck
@@ -172,6 +172,9 @@ do
# SectionMemoryManager.h is C++
test "$f" = src/include/jit/SectionMemoryManager.h && continue
+ # XXX depends on --with-llvm
+ test "$f" = src/include/jit/llvmjit_backport.h && continue
+
# ppport.h is not under our control, so we can't make it standalone.
test "$f" = src/pl/plperl/ppport.h && continue
--
2.50.1
From 7ea0c526f41fcc30951f1a25acaedb65f340eeed Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pe...@eisentraut.org>
Date: Thu, 7 Aug 2025 15:58:34 +0200
Subject: [PATCH 3/4] headerscheck: Ignore Windows-specific header
Ignore src/include/port/win32/sys/resource.h. At least on macOS,
including this results in warnings and errors because of duplication
with system headers:
../src/include/port/win32/sys/resource.h:10:9: warning: 'RUSAGE_CHILDREN'
redefined
../src/include/port/win32/sys/resource.h:16:1: error: redefinition of struct or
union 'struct rusage'
Since we are also not checking similar system-replacement headers for
Windows, it makes sense to exclude this one, too.
---
src/tools/pginclude/headerscheck | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/tools/pginclude/headerscheck b/src/tools/pginclude/headerscheck
index e984a441edb..850bf293ae5 100755
--- a/src/tools/pginclude/headerscheck
+++ b/src/tools/pginclude/headerscheck
@@ -98,7 +98,7 @@ do
# Additional Windows-specific headers.
test "$f" = src/include/port/win32_port.h && continue
test "$f" = src/include/port/win32/netdb.h && continue
- $cplusplus && test "$f" = src/include/port/win32/sys/resource.h &&
continue
+ test "$f" = src/include/port/win32/sys/resource.h && continue
test "$f" = src/include/port/win32/sys/socket.h && continue
test "$f" = src/include/port/win32_msvc/dirent.h && continue
test "$f" = src/include/port/win32_msvc/utime.h && continue
--
2.50.1
From 00e0e2694cdce7d5d0760fb35d3ea15551c94e10 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pe...@eisentraut.org>
Date: Thu, 7 Aug 2025 16:03:17 +0200
Subject: [PATCH 4/4] headerscheck: Ignore ecpg test header
This fails headerscheck because of
-Wmissing-variable-declarations (somewhat recently added by commit
66188912566). Ignore it, since it's just a code fragment, not a real
header file.
---
src/tools/pginclude/headerscheck | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/tools/pginclude/headerscheck b/src/tools/pginclude/headerscheck
index 850bf293ae5..5ca3db9deb0 100755
--- a/src/tools/pginclude/headerscheck
+++ b/src/tools/pginclude/headerscheck
@@ -182,6 +182,8 @@ do
test "$f" = src/interfaces/ecpg/test/regression.h && continue
# printf_hack.h produces "unused function" warnings.
test "$f" = src/interfaces/ecpg/test/printf_hack.h && continue
+ # code fragment
+ test "$f" = src/interfaces/ecpg/test/preproc/strings.h && continue
if $cplusplus; then
# pg_trace.h and utils/probes.h can include sys/sdt.h from
SystemTap,
--
2.50.1