On 01.04.25 17:57, Tom Lane wrote:
That is, the function exists now in macOS' libc, and so configure's
does-it-link test for HAVE_STRCHRNUL finds it, but <string.h>
will not let you use it unless you monkey around with
export MACOSX_DEPLOYMENT_TARGET=15.4
or similar. I don't think we want to require people to do that,
so we need to fix things so that the code works with or without
a deployment target that satisfies <string.h>. This is pretty
reminiscent of a problem that we faced a couple years ago with
preadv and pwritev, and solved in commit f014b1b9b by depending
on AC_CHECK_DECLS instead of AC_CHECK_FUNCS. I made a patch
(attached) to solve this similarly. Interestingly, this actually
makes the one usage in snprintf.c simpler, since we no longer
need to special-case the situation where GNU <string.h> doesn't
agree with the does-it-link test.
Agreed, this matches my research.
However ... testing this here shows that it fixes the autoconf
build as desired, with or without MACOSX_DEPLOYMENT_TARGET.
But the meson version *does not work*: it will set
HAVE_DECL_STRCHRNUL to 1 with or without MACOSX_DEPLOYMENT_TARGET,
and in the "without" case the build then blows up.
I speculate that the meson test for preadv/pwritev has never worked
for macOS either, and we haven't noticed because nobody has tried to
build with meson on a machine with low enough default deployment
target to not have preadv/pwritev.
Agreed. Attached is a patch that implements the test more along the
lines of how Autoconf does it. This gives correct results for me for
strchrnul() in various configurations.
Btw., I see on the buildfarm that strchrnul() is also available on
FreeBSD, DragonFly BSD, NetBSD, and musl (Alpine Linux). So perhaps
some of the comments ought to be rewritten away from that it's a
glibc-specific extension.
From e12c5d224a195b893f79c470bc4f21de1585c808 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pe...@eisentraut.org>
Date: Tue, 1 Apr 2025 19:00:39 +0200
Subject: [PATCH] WIP: Fix AC_CHECK_DECLS equivalent in meson
---
meson.build | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/meson.build b/meson.build
index 6932a0f00f7..ba7916d1493 100644
--- a/meson.build
+++ b/meson.build
@@ -2594,8 +2594,23 @@ foreach c : decl_checks
args = c.get(2, {})
varname = 'HAVE_DECL_' + func.underscorify().to_upper()
- found = cc.has_header_symbol(header, func,
- args: test_c_args, include_directories: postgres_inc,
+ found = cc.compiles('''
+#include <@0@>
+
+int main()
+{
+#ifndef @1@
+ (void) @1@;
+#endif
+
+return 0;
+}
+'''.format(header, func),
+ name: 'test whether @0@ is declared'.format(func),
+ # need to add cflags_warn to get at least
+ # -Werror=unguarded-availability-new if applicable
+ args: test_c_args + cflags_warn,
+ include_directories: postgres_inc,
kwargs: args)
cdata.set10(varname, found, description:
'''Define to 1 if you have the declaration of `@0@', and to 0 if you
--
2.49.0