Validate user-supplied c_args in meson builds
Hackorum builds and tests every patch posted to the lists, not only commitfest submissions. This is Hackorum's own CI rather than the PostgreSQL project's, and it is still under testing - please report anything that looks wrong.
You can run a PostgreSQL built from this patch straight from Docker, with no checkout and no build:
docker run --rm -p 5432:5432 ghcr.io/hackorum-dev/postgres-patch:t53529psql -h localhost -U postgresBuilt from patchset v1 (message #1), September 22, 2026 at 01:15 AM.
Every patchset is also pushed to a branch of our PostgreSQL fork, so you can check out the same tree CI built. Without a PostgreSQL checkout:
git clone --branch t53529_1 https://github.com/hackorum-dev/postgres.gitIn a checkout you already have, add the fork once:
git remote add hackorum https://github.com/hackorum-dev/postgres.gitthen, for this patchset and every later one:
git fetch hackorum t53529_1 && git checkout t53529_1Patchset v1 (message #1) is on t53529_1
Hi hackers,
While using an invalid c_args by mistake with clang and meson, I observed the
following:
$ CC="clang" meson setup meson_build -Dc_args="-Wbad"
produces:
meson.build:645:4: ERROR: Problem encountered: C compiler does not support C11
This is misleading: my C compiler does support C11 but the C11 check fails
due to the invalid arg, as stated in meson-log.txt:
"
stderr:
error: unknown warning option '-Wbad' [-Werror,-Wunknown-warning-option]
"
OTOH, providing an invalid CFLAG with autoconf and using clang currently produces
warnings like:
"
warning: unknown warning option '-Wbad' [-Wunknown-warning-option]
"
That's perfectly fine and not misleading.
If using gcc instead of clang, then:
1/ with autoconf, we get:
"
checking whether the C compiler works... no
configure: error: in `/home/postgres/postgresql/postgres':
configure: error: C compiler cannot create executables
See `config.log' for more details
"
and in config.log:
"
configure:4028: checking whether the C compiler works
configure:4050: gcc -O0 -Wbad conftest.c >&5
gcc: error: unrecognized command-line option '-Wbad'"
That's not misleading.
2/ with meson, we get:
"
$ CC="gcc" meson setup meson_build -Dc_args="-Wbad"
meson.build:9:0: ERROR: Compiler gcc cannot compile programs.
"
That's not misleading.
So it looks like that GCC treats an invalid CFLAG as an error by itself, while
clang only treats it as a warning (unless -Werror=unknown-warning-option is present).
Also, it looks like that when using clang, meson injects -Werror=unknown-warning-option
into cc.compiles().
This can be confirmed by creating a simple meson.build as:
"
project('test', 'c')
cc = meson.get_compiler('c')
cc.compiles('int main(void){return 0;}', name: 'test probe')
"
and running the compilation with a valid arg:
$ CC=gcc meson setup testbuild -Dc_args="-Wunused-value"
and check:
$ grep -c unknown-warning-option testbuild/meson-logs/meson-log.txt
0
While (with clang):
$ CC=clang meson setup testbuild -Dc_args="-Wunused-value"
$ grep -c unknown-warning-option testbuild/meson-logs/meson-log.txt
1
So, PFA, a patch that adds a cc.has_multi_arguments() check before the C11 test so
that :
CC="clang" meson setup meson_build -Dc_args="-Wbad"
now produces:
"
Compiler for C supports arguments -Wbad: NO
meson.build:625:2: ERROR: Problem encountered: One or more c_args are not supported by clang 21.0.0
"
and does not report wrongly that the C compiler does not support C11 when using
clang with meson (and an invalid c_args).
Regards,
--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com
I actually think this is a bug in Meson. I created a PR[0]https://github.com/mesonbuild/meson/pull/15714 to propose
a fix, but one person's bug is another person's feature. The actual
content of the patch seems fine to me, but I would wait to see the
result of the pull request fist.
[0]: https://github.com/mesonbuild/meson/pull/15714
--
Tristan Partin
PostgreSQL Contributors Team
AWS (https://aws.amazon.com)
On Wed Apr 15, 2026 at 4:36 PM CDT, Tristan Partin wrote:
I actually think this is a bug in Meson. I created a PR[0] to propose
a fix, but one person's bug is another person's feature. The actual
content of the patch seems fine to me, but I would wait to see the
result of the pull request fist.
Closing the loop here. The PR is has been merged, and this will be
fixed in Meson. 1.13.0.
--
Tristan Partin
PostgreSQL Contributors Team
AWS (https://aws.amazon.com)
Hi,
On Mon, Sep 21, 2026 at 10:01:12PM +0000, Tristan Partin wrote:
On Wed Apr 15, 2026 at 4:36 PM CDT, Tristan Partin wrote:
I actually think this is a bug in Meson. I created a PR[0] to propose
a fix, but one person's bug is another person's feature. The actual
content of the patch seems fine to me, but I would wait to see the
result of the pull request fist.Closing the loop here. The PR is has been merged, and this will be
fixed in Meson. 1.13.0.
Great, thanks!
Regards,
--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com