headerscheck: Get CXXFLAGS from Makefile.global

headerscheck in C++ mode (cpluspluscheck) previously hardcoded
CXXFLAGS and documented that you might need to override them manually
from the environment.  Now that we have better C++ support in the
build system, we can just get CXXFLAGS from Makefile.global, like we
do for other variables.

Furthermore, this is necessary in some configurations to make
cpluspluscheck work under meson, because under meson, some -I options
end up in CXXFLAGS where under make they would be in CPPFLAGS.
Therefore, getting the correct CXXFLAGS is required in those cases.

Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/CAMSWrt-PoQt4sHryWrB1ViuGBJF_PpbjoSGrWR2Ry47bHNLDqg%40mail.gmail.com
This commit is contained in:
Peter Eisentraut 2026-03-23 07:18:11 +01:00
parent d6628a5ea0
commit 0f17d1dbfa
2 changed files with 1 additions and 7 deletions

View file

@ -95,10 +95,6 @@ related headers not being found.
When using meson, run "meson compile -C build cpluspluscheck" or
"ninja -C build cpluspluscheck".
If you are using a non-g++-compatible C++ compiler, you may need to
override the script's CXXFLAGS setting by setting a suitable environment
value.
A limitation of the current script is that it doesn't know exactly which
headers are for frontend or backend; when in doubt it uses postgres.h as
prerequisite, even if postgres_fe.h or c.h would be more appropriate.

View file

@ -37,13 +37,11 @@ fi
me=`basename $0`
# These switches are g++ specific, you may override if necessary.
CXXFLAGS=${CXXFLAGS:- -fsyntax-only -Wall}
# Pull some info from configure's results.
MGLOB="$builddir/src/Makefile.global"
CPPFLAGS=`sed -n 's/^CPPFLAGS[ ]*=[ ]*//p' "$MGLOB"`
CFLAGS=`sed -n 's/^CFLAGS[ ]*=[ ]*//p' "$MGLOB"`
CXXFLAGS=`sed -n 's/^CXXFLAGS[ ]*=[ ]*//p' "$MGLOB"`
ICU_CFLAGS=`sed -n 's/^ICU_CFLAGS[ ]*=[ ]*//p' "$MGLOB"`
LLVM_CPPFLAGS=`sed -n 's/^LLVM_CPPFLAGS[ ]*=[ ]*//p' "$MGLOB"`
CC=`sed -n 's/^CC[ ]*=[ ]*//p' "$MGLOB"`