From 7551267f19ba6ad5a5ea71ef46c4facacc4e2383 Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Mon, 7 May 2018 15:19:36 +0530 Subject: [PATCH] meson: Fix checks for posix_memalign and stpcpy The 'no-builtin' checks were just plain wrong. For accurate detection of functions, use has_function with a header in the prefix. This fixes posix_memalign detection on Android and on MinGW32, MSYS-MinGW-w64, and old versions of MSYS2-MinGW-w64. Using the header in the `prefix:` is generally a good idea because of how macOS does targetting of specific macOS releases at compile time. This also allows cross-files to override the result by setting `has_function_stpcpy = false`, etc in [extra properties] https://bugzilla.gnome.org/show_bug.cgi?id=795876 --- meson.build | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/meson.build b/meson.build index b2fdbae61..edbb5f119 100644 --- a/meson.build +++ b/meson.build @@ -468,33 +468,13 @@ foreach f : functions endif endforeach -if cc.get_id() == 'gcc' or cc.get_id() == 'clang' - no_builtin_args = cc.get_supported_arguments(['-fno-builtin']) -else - no_builtin_args = [] -endif - -# Check that stpcpy() is not a builtin -if cc.links('''#include - int main (int argc, char ** argv) { - char p[10]; - return stpcpy (p, argv[0]) != NULL; - } - ''', - args : no_builtin_args, - name : 'stpcpy() is not a builtin') +# Check that stpcpy() is usable; must use header +if cc.has_function('stpcpy', prefix : '#include ') glib_conf.set('HAVE_STPCPY', 1) endif -# Check that posix_memalign() is not a builtin -if cc.links('''#include - int main (int argc, char ** argv) { - void *p; - return posix_memalign (&p, 16, argc); - } - ''', - args : no_builtin_args, - name : 'posix_memalign() is not a builtin') +# Check that posix_memalign() is usable; must use header +if cc.has_function('posix_memalign', prefix : '#include ') glib_conf.set('HAVE_POSIX_MEMALIGN', 1) endif