From: Karel Zak Date: Wed, 24 Jun 2026 09:56:34 +0000 (+0200) Subject: meson: add compile test for scandirat() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4db85b27d330e7f8dd664dd826bcccf32f8e711d;p=thirdparty%2Futil-linux.git meson: add compile test for scandirat() The link-only has_function() check is not sufficient on macOS where scandirat() may exist in the SDK but is gated behind availability annotations (e.g. macOS 26.4+). When the deployment target is older, clang emits -Wunguarded-availability-new which -Werror turns into a build failure. Add a compile+link verification after the bulk function check to detect this and disable HAVE_SCANDIRAT when the function is not actually usable. Signed-off-by: Karel Zak --- diff --git a/meson.build b/meson.build index 0595aead9..2768cb879 100644 --- a/meson.build +++ b/meson.build @@ -732,6 +732,17 @@ foreach func: funcs conf.set('HAVE_' + func.to_upper(), have ? 1 : false) endforeach +# scandirat() may exist in the SDK but be gated behind availability +# annotations (e.g. macOS); verify it is actually usable at compile time. +if conf.get('HAVE_SCANDIRAT') in [1] + if not cc.links(''' + #include + int main(void) { return scandirat(0, ".", (void*)0, (void*)0, (void*)0); } + ''', args : ['-D_GNU_SOURCE', '-Werror'], name : 'scandirat (compile test)') + conf.set('HAVE_SCANDIRAT', false) + endif +endif + have_mempcpy = cc.has_function('mempcpy', prefix: '#include ', args: '-D_GNU_SOURCE') conf.set('HAVE_MEMPCPY', have_mempcpy ? 1 : false)