[PATCH] Add `headerscheck` run_target to meson
Hi,
While reviewing a patch I noticed that we have a `make -s headerscheck` but
there is no equivalent in meson.
I prepared a small patch that adds `headerscheck` and `cpluspluscheck`
targets.
Best Regards,
Miłosz Bieniek
Attachments:
0001-Add-headerscheck-run_target-to-meson.patchapplication/octet-stream; name=0001-Add-headerscheck-run_target-to-meson.patchDownload
From 2c5029bad0c2a5fdc621de9beb1bbbf4d532b087 Mon Sep 17 00:00:00 2001
From: moozzi <bieniek.milosz0@gmail.com>
Date: Wed, 26 Nov 2025 13:05:44 +0100
Subject: [PATCH] Add `headerscheck` run_target to meson
---
meson.build | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/meson.build b/meson.build
index 6e7ddd74683..8d4839ae64b 100644
--- a/meson.build
+++ b/meson.build
@@ -3900,6 +3900,20 @@ endif
+###############################################################
+# headerscheck
+###############################################################
+
+run_target('headerscheck',
+ command: [meson.project_source_root() / 'src/tools/pginclude/headerscheck']
+)
+
+run_target('cpluspluscheck',
+ command: [meson.project_source_root() / 'src/tools/pginclude/headerscheck', '--cplusplus']
+)
+
+
+
###############################################################
# The End, The End, My Friend
###############################################################
--
2.49.0
On 27.11.25 10:28, Miłosz Bieniek wrote:
While reviewing a patch I noticed that we have a `make -s headerscheck`
but there is no equivalent in meson.
I prepared a small patch that adds `headerscheck` and `cpluspluscheck`
targets.
This would be good to have, but I don't think your patch works. It
seems you need to add the srcdir and builddir command-line arguments to
the invocations.
pt., 28 lis 2025 o 12:53 Peter Eisentraut <peter@eisentraut.org> napisał(a):
On 27.11.25 10:28, Miłosz Bieniek wrote:
While reviewing a patch I noticed that we have a `make -s headerscheck`
but there is no equivalent in meson.
I prepared a small patch that adds `headerscheck` and `cpluspluscheck`
targets.This would be good to have, but I don't think your patch works. It
seems you need to add the srcdir and builddir command-line arguments to
the invocations.
I think you are right. I added srcdir and builddir arguments.
Attachments:
v2-0001-Add-headerscheck-run_target-to-meson.patchapplication/octet-stream; name=v2-0001-Add-headerscheck-run_target-to-meson.patchDownload
From e81db5a0ecd699cd5c676b4c3e6f4cdd14f26b97 Mon Sep 17 00:00:00 2001
From: moozzi <bieniek.milosz0@gmail.com>
Date: Fri, 28 Nov 2025 13:54:13 +0100
Subject: [PATCH v2] Add `headerscheck` run_target to meson
---
meson.build | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/meson.build b/meson.build
index 6e7ddd74683..1f74750c914 100644
--- a/meson.build
+++ b/meson.build
@@ -3900,6 +3900,20 @@ endif
+###############################################################
+# headerscheck
+###############################################################
+
+run_target('headerscheck',
+ command: [meson.project_source_root() / 'src/tools/pginclude/headerscheck', meson.project_source_root(), meson.project_build_root()]
+)
+
+run_target('cpluspluscheck',
+ command: [meson.project_source_root() / 'src/tools/pginclude/headerscheck', '--cplusplus', meson.project_source_root(), meson.project_build_root()]
+)
+
+
+
###############################################################
# The End, The End, My Friend
###############################################################
--
2.49.0
Hi,
Thank you for working on this!
On Fri, 28 Nov 2025 at 17:03, Miłosz Bieniek <bieniek.milosz0@gmail.com> wrote:
pt., 28 lis 2025 o 12:53 Peter Eisentraut <peter@eisentraut.org> napisał(a):
On 27.11.25 10:28, Miłosz Bieniek wrote:
While reviewing a patch I noticed that we have a `make -s headerscheck`
but there is no equivalent in meson.
I prepared a small patch that adds `headerscheck` and `cpluspluscheck`
targets.This would be good to have, but I don't think your patch works. It
seems you need to add the srcdir and builddir command-line arguments to
the invocations.I think you are right. I added srcdir and builddir arguments.
The headerscheck script pulls some information from Makefile.global
after the configure [1] but meson does not generate a full version of
Makefile.global [2]src/meson.build makefile_global = configure_file( input: 'Makefile.global.in', output: 'Makefile.global', configuration: pgxs_cdata, install: true, install_dir: dir_pgxs / 'src', ) configure_files += makefile_global, so it does not have the required information to
check perl and python headers. If you run 'meson compile
headerscheck', you get errors like:
In file included from
/home/nbyavuz/Desktop/projects/postgres/src/pl/plperl/plperl.h:25,
from /tmp/headerscheck.YxsZhn/test.c:2:
/home/nbyavuz/Desktop/projects/postgres/src/pl/plperl/plperl_system.h:85:10:
fatal error: EXTERN.h: No such file or directory
85 | #include <EXTERN.h>
| ^~~~~~~~~~
compilation terminated.
In file included from
/home/nbyavuz/Desktop/projects/postgres/src/pl/plpython/plpython.h:39,
from
/home/nbyavuz/Desktop/projects/postgres/src/pl/plpython/plpy_plpymodule.h:8,
from /tmp/headerscheck.YxsZhn/test.c:2:
/home/nbyavuz/Desktop/projects/postgres/src/pl/plpython/plpython_system.h:50:10:
fatal error: Python.h: No such file or directory
50 | #include <Python.h>
| ^~~~~~~~~~
compilation terminated.
-----
[1.1] src/tools/pginclude/headerscheck
# Needs to be run after configuring and creating all generated headers.
# It's advisable to configure --with-perl --with-python, else you're
# likely to get errors from associated headers.
[1.2] src/tools/pginclude/headerscheck
# 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"`
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"`
perl_includespec=`sed -n 's/^perl_includespec[ ]*=[ ]*//p' "$MGLOB"`
python_includespec=`sed -n 's/^python_includespec[ ]*=[ ]*//p' "$MGLOB"`
[2]: src/meson.build makefile_global = configure_file( input: 'Makefile.global.in', output: 'Makefile.global', configuration: pgxs_cdata, install: true, install_dir: dir_pgxs / 'src', ) configure_files += makefile_global
makefile_global = configure_file(
input: 'Makefile.global.in',
output: 'Makefile.global',
configuration: pgxs_cdata,
install: true,
install_dir: dir_pgxs / 'src',
)
configure_files += makefile_global
--
Regards,
Nazir Bilal Yavuz
Microsoft
Hi,
On Fri, 28 Nov 2025 at 18:05, Nazir Bilal Yavuz <byavuz81@gmail.com> wrote:
On Fri, 28 Nov 2025 at 17:03, Miłosz Bieniek <bieniek.milosz0@gmail.com> wrote:
pt., 28 lis 2025 o 12:53 Peter Eisentraut <peter@eisentraut.org> napisał(a):
On 27.11.25 10:28, Miłosz Bieniek wrote:
While reviewing a patch I noticed that we have a `make -s headerscheck`
but there is no equivalent in meson.
I prepared a small patch that adds `headerscheck` and `cpluspluscheck`
targets.This would be good to have, but I don't think your patch works. It
seems you need to add the srcdir and builddir command-line arguments to
the invocations.I think you are right. I added srcdir and builddir arguments.
The headerscheck script pulls some information from Makefile.global
after the configure [1] but meson does not generate a full version of
Makefile.global [2], so it does not have the required information to
check perl and python headers. If you run 'meson compile
headerscheck', you get errors like:
Sorry, I clicked send early.
Two solutions came to my mind but I am not sure which one is better:
1) We can add missing information to the generated Makefile.global in
the meson.build.
2) We can send required information as arguments to the headerscheck script.
Any thoughts or suggestions?
--
Regards,
Nazir Bilal Yavuz
Microsoft
pt., 28 lis 2025 o 16:17 Nazir Bilal Yavuz <byavuz81@gmail.com> napisał(a):
Hi,
On Fri, 28 Nov 2025 at 18:05, Nazir Bilal Yavuz <byavuz81@gmail.com> wrote:
On Fri, 28 Nov 2025 at 17:03, Miłosz Bieniek <bieniek.milosz0@gmail.com> wrote:
pt., 28 lis 2025 o 12:53 Peter Eisentraut <peter@eisentraut.org> napisał(a):
On 27.11.25 10:28, Miłosz Bieniek wrote:
While reviewing a patch I noticed that we have a `make -s headerscheck`
but there is no equivalent in meson.
I prepared a small patch that adds `headerscheck` and `cpluspluscheck`
targets.This would be good to have, but I don't think your patch works. It
seems you need to add the srcdir and builddir command-line arguments to
the invocations.I think you are right. I added srcdir and builddir arguments.
The headerscheck script pulls some information from Makefile.global
after the configure [1] but meson does not generate a full version of
Makefile.global [2], so it does not have the required information to
check perl and python headers. If you run 'meson compile
headerscheck', you get errors like:Sorry, I clicked send early.
Two solutions came to my mind but I am not sure which one is better:
1) We can add missing information to the generated Makefile.global in
the meson.build.2) We can send required information as arguments to the headerscheck script.
Any thoughts or suggestions?
Thank you for the detailed response.
I initially thought the errors with `#include <Python.h>` and
`#include <EXTREN.h>` were only an issue with my local setup.
If I understand correctly, your first proposal would address this
problem without requiring integration with the headerscheck script,
which in my opinion would be a cleaner solution.
However, I would definitely like to hear what others think as well.
Hi,
On Sat, 29 Nov 2025 at 14:07, Miłosz Bieniek <bieniek.milosz0@gmail.com> wrote:
pt., 28 lis 2025 o 16:17 Nazir Bilal Yavuz <byavuz81@gmail.com> napisał(a):
Hi,
On Fri, 28 Nov 2025 at 18:05, Nazir Bilal Yavuz <byavuz81@gmail.com> wrote:
On Fri, 28 Nov 2025 at 17:03, Miłosz Bieniek <bieniek.milosz0@gmail.com> wrote:
pt., 28 lis 2025 o 12:53 Peter Eisentraut <peter@eisentraut.org> napisał(a):
On 27.11.25 10:28, Miłosz Bieniek wrote:
While reviewing a patch I noticed that we have a `make -s headerscheck`
but there is no equivalent in meson.
I prepared a small patch that adds `headerscheck` and `cpluspluscheck`
targets.This would be good to have, but I don't think your patch works. It
seems you need to add the srcdir and builddir command-line arguments to
the invocations.I think you are right. I added srcdir and builddir arguments.
The headerscheck script pulls some information from Makefile.global
after the configure [1] but meson does not generate a full version of
Makefile.global [2], so it does not have the required information to
check perl and python headers. If you run 'meson compile
headerscheck', you get errors like:Sorry, I clicked send early.
Two solutions came to my mind but I am not sure which one is better:
1) We can add missing information to the generated Makefile.global in
the meson.build.2) We can send required information as arguments to the headerscheck script.
Any thoughts or suggestions?
Thank you for the detailed response.
I initially thought the errors with `#include <Python.h>` and
`#include <EXTREN.h>` were only an issue with my local setup.
If I understand correctly, your first proposal would address this
problem without requiring integration with the headerscheck script,
which in my opinion would be a cleaner solution.
However, I would definitely like to hear what others think as well.
I wanted to experiment with the first proposal and it turns out I need
to edit the headerscheck script.
There are 3 patches attached:
0001 adds python_includespec and perl_includespec variables to the
Makefile.global of the meson build.
0002 adds headerscheck target to meson build like you do but with 2
extra changes. First one is that, I moved the headerscheck script to a
variable and used it in the target commands. Second one is that,
headerscheck script could not find the perl_includespec and
python_includespec variables because of the tabs in the sed command, I
changed them with '[:space:]' and it worked. I am not sure if that is
the correct fix but I just wanted to see if the script will work.
0003 adds icu_flags option to the meson build and sets 'ICU_CFLAGS'
Makefile.global variable to that option. This change is not needed for
the headerscheck script to work but I saw that was missing and just
wanted to show it. If we want to add that, this probably needs its own
thread.
--
Regards,
Nazir Bilal Yavuz
Microsoft
Attachments:
v3-0001-meson-Add-python-perl-_includespec-to-the-Makefil.patchtext/x-patch; charset=US-ASCII; name=v3-0001-meson-Add-python-perl-_includespec-to-the-Makefil.patchDownload
From 44a7e1227fd4a57472b9dffe69f15813e0b2734c Mon Sep 17 00:00:00 2001
From: Nazir Bilal Yavuz <byavuz81@gmail.com>
Date: Sat, 29 Nov 2025 19:25:20 +0300
Subject: [PATCH v3 1/3] meson: Add {python|perl}_includespec to the
Makefile.global
---
src/makefiles/meson.build | 7 +++++--
meson.build | 9 +++++++++
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/src/makefiles/meson.build b/src/makefiles/meson.build
index 0def244c901..3c732a94653 100644
--- a/src/makefiles/meson.build
+++ b/src/makefiles/meson.build
@@ -77,6 +77,9 @@ pgxs_kv = {
'STRIP_STATIC_LIB': ' '.join(strip_static_cmd),
'STRIP_SHARED_LIB': ' '.join(strip_shared_cmd),
+ 'python_includespec': python_includespec,
+ 'perl_includespec': perl_includespec,
+
# these seem to be standard these days
'MKDIR_P': 'mkdir -p',
'LN_S': 'ln -s',
@@ -181,8 +184,8 @@ pgxs_empty = [
'PG_TEST_EXTRA',
'DTRACEFLAGS', # only server has dtrace probes
- 'perl_archlibexp', 'perl_embed_ccflags', 'perl_embed_ldflags', 'perl_includespec', 'perl_privlibexp',
- 'python_additional_libs', 'python_includespec', 'python_libdir', 'python_libspec', 'python_majorversion', 'python_version',
+ 'perl_archlibexp', 'perl_embed_ccflags', 'perl_embed_ldflags', 'perl_privlibexp',
+ 'python_additional_libs', 'python_libdir', 'python_libspec', 'python_majorversion', 'python_version',
# possible that some of these are referenced explicitly in pgxs makefiles?
# For now not worth it.
diff --git a/meson.build b/meson.build
index 6e7ddd74683..0a68ebf1598 100644
--- a/meson.build
+++ b/meson.build
@@ -1176,6 +1176,7 @@ endif
# Library: Perl (for plperl)
###############################################################
+perl_includespec = ''
perlopt = get_option('plperl')
perl_dep = not_found_dep
perlversion = ''
@@ -1202,6 +1203,7 @@ if not perlopt.disabled()
useshrplib = run_command(perl_conf_cmd, 'useshrplib', check: true).stdout()
perl_inc_dir = '@0@/CORE'.format(archlibexp)
+ perl_includespec = '-I@0@'.format(perl_inc_dir)
if perlversion.version_compare('< 5.14')
perl_may_work = false
@@ -1220,6 +1222,7 @@ if not perlopt.disabled()
if not fs.is_file('@0@/perl.h'.format(perl_inc_dir)) and \
fs.is_file('@0@@1@/perl.h'.format(pg_sysroot, perl_inc_dir))
perl_ccflags = ['-iwithsysroot', perl_inc_dir]
+ perl_includespec = '-iwithsysroot @0@/CORE'.format(archlibexp)
endif
# check compiler finds header
@@ -1322,6 +1325,7 @@ endif
# Library: Python (for plpython)
###############################################################
+python_includespec = ''
pyopt = get_option('plpython')
python3_dep = not_found_dep
if not pyopt.disabled()
@@ -1334,6 +1338,11 @@ if not pyopt.disabled()
python3_dep = not_found_dep
endif
endif
+
+ if python3_dep.found()
+ command = [python, '-c', 'import sysconfig; print("-I" + sysconfig.get_config_var("INCLUDEPY"))']
+ python_includespec = run_command(command, check: true).stdout().strip()
+ endif
endif
--
2.51.0
v3-0002-Add-headerscheck-run_target-to-meson.patchtext/x-patch; charset=US-ASCII; name=v3-0002-Add-headerscheck-run_target-to-meson.patchDownload
From e20ac980fd75125b136cb808ca90717e0565125f Mon Sep 17 00:00:00 2001
From: moozzi <bieniek.milosz0@gmail.com>
Date: Fri, 28 Nov 2025 13:54:13 +0100
Subject: [PATCH v3 2/3] Add `headerscheck` run_target to meson
---
meson.build | 15 +++++++++++++++
src/tools/pginclude/headerscheck | 4 ++--
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/meson.build b/meson.build
index 0a68ebf1598..2ca8d750a3f 100644
--- a/meson.build
+++ b/meson.build
@@ -3909,6 +3909,21 @@ endif
+###############################################################
+# headerscheck
+###############################################################
+
+headerscheck = files('src/tools/pginclude/headerscheck')
+run_target('headerscheck',
+ command: [headerscheck, meson.project_source_root(), meson.project_build_root()]
+)
+
+run_target('cpluspluscheck',
+ command: [headerscheck, '--cplusplus', meson.project_source_root(), meson.project_build_root()]
+)
+
+
+
###############################################################
# The End, The End, My Friend
###############################################################
diff --git a/src/tools/pginclude/headerscheck b/src/tools/pginclude/headerscheck
index a52a5580bdc..a96a462a5ef 100755
--- a/src/tools/pginclude/headerscheck
+++ b/src/tools/pginclude/headerscheck
@@ -48,8 +48,8 @@ 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"`
-perl_includespec=`sed -n 's/^perl_includespec[ ]*=[ ]*//p' "$MGLOB"`
-python_includespec=`sed -n 's/^python_includespec[ ]*=[ ]*//p' "$MGLOB"`
+perl_includespec=`sed -n 's/^perl_includespec[[:space:]]*=[[:space:]]*//p' "$MGLOB"`
+python_includespec=`sed -n 's/^python_includespec[[:space:]]*=[[:space:]]*//p' "$MGLOB"`
# needed on Darwin
CPPFLAGS=`echo "$CPPFLAGS" | sed "s|\\\$(PG_SYSROOT)|$PG_SYSROOT|g"`
--
2.51.0
v3-0003-meson-Add-icu_flags-option.patchtext/x-patch; charset=US-ASCII; name=v3-0003-meson-Add-icu_flags-option.patchDownload
From b9001a654dd97ea63572ff52ab43caa60be4fc19 Mon Sep 17 00:00:00 2001
From: Nazir Bilal Yavuz <byavuz81@gmail.com>
Date: Sat, 29 Nov 2025 19:06:28 +0300
Subject: [PATCH v3 3/3] meson: Add icu_flags option
---
src/makefiles/meson.build | 4 ++--
meson_options.txt | 3 +++
src/tools/pginclude/headerscheck | 2 +-
3 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/makefiles/meson.build b/src/makefiles/meson.build
index 3c732a94653..5046e9cb496 100644
--- a/src/makefiles/meson.build
+++ b/src/makefiles/meson.build
@@ -116,6 +116,8 @@ pgxs_kv = {
'BITCODE_CFLAGS': '',
'BITCODE_CXXFLAGS': '',
+ 'ICU_CFLAGS': get_option('icu_cflags'),
+
'BISONFLAGS': ' '.join(bison_flags),
'FLEXFLAGS': ' '.join(flex_flags),
@@ -155,8 +157,6 @@ pgxs_bins = {
}
pgxs_empty = [
- 'ICU_CFLAGS', # needs to be added, included by public server headers
-
# hard to see why we'd need either?
'ZIC',
'TCLSH',
diff --git a/meson_options.txt b/meson_options.txt
index 06bf5627d3c..ca79e117d09 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -70,6 +70,9 @@ option('darwin_sysroot', type: 'string', value: '',
option('rpath', type: 'boolean', value: true,
description: 'Embed shared library search path in executables')
+option('icu_cflags', type: 'string', value: '',
+ description: 'C compiler flags for ICU, overriding pkg-config')
+
# External dependencies
diff --git a/src/tools/pginclude/headerscheck b/src/tools/pginclude/headerscheck
index a96a462a5ef..1a589e4b13c 100755
--- a/src/tools/pginclude/headerscheck
+++ b/src/tools/pginclude/headerscheck
@@ -44,7 +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"`
+ICU_CFLAGS=`sed -n 's/^ICU_CFLAGS[[:space:]]*=[[:space:]]*//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"`
--
2.51.0