Andrew Geissler | c182c62 | 2020-05-15 14:13:32 -0500 | [diff] [blame^] | 1 | From d4b1fd9cdb7ae07fa6be941ac95f97ece175fe55 Mon Sep 17 00:00:00 2001 |
| 2 | From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <martin@martin.st> |
| 3 | Date: Tue, 31 Mar 2020 23:54:17 +0300 |
| 4 | Subject: [PATCH] meson: Don't misdetect stpcpy on windows platforms on clang |
| 5 | |
| 6 | See https://github.com/mesonbuild/meson/issues/3672 and |
| 7 | https://github.com/mesonbuild/meson/issues/5628 for explanations |
| 8 | of cases where meson misdetects functions due to clang builtins (that |
| 9 | always are available, regardless of whether the platform actually |
| 10 | provides them). |
| 11 | |
| 12 | The same also happens on GCC 10, which added support for __has_builtin. |
| 13 | |
| 14 | Upstream-Status: Backport [https://github.com/GNOME/glib/commit/1b94bfbd72dbbfb696fa68f3742f40998096b438] |
| 15 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 16 | --- |
| 17 | meson.build | 16 +++++++++++++--- |
| 18 | 1 file changed, 13 insertions(+), 3 deletions(-) |
| 19 | |
| 20 | diff --git a/meson.build b/meson.build |
| 21 | index 72ca194..bbdac1c 100644 |
| 22 | --- a/meson.build |
| 23 | +++ b/meson.build |
| 24 | @@ -533,13 +533,23 @@ foreach f : functions |
| 25 | endif |
| 26 | endforeach |
| 27 | |
| 28 | -# Check that stpcpy() is usable; must use header |
| 29 | -if cc.has_function('stpcpy', prefix : '#include <string.h>') |
| 30 | +# Check that stpcpy() is usable; must use header. |
| 31 | +# cc.has_function() in some cases (clang, gcc 10+) assumes that if the |
| 32 | +# compiler provides a builtin of the same name that the function exists, while |
| 33 | +# it's in fact not provided by any header or library. This is true for |
| 34 | +# stpcpy() on Windows using clang and gcc as well as posix_memalign() using |
| 35 | +# gcc on Windows. Skip these checks on Windows for now to avoid false |
| 36 | +# positives. See https://github.com/mesonbuild/meson/pull/7116, |
| 37 | +# https://github.com/mesonbuild/meson/issues/3672 and |
| 38 | +# https://github.com/mesonbuild/meson/issues/5628. |
| 39 | +# FIXME: Once meson no longer returns success for stpcpy() and |
| 40 | +# posix_memalign() on Windows using GCC and clang we can remove this. |
| 41 | +if host_system != 'windows' and cc.has_function('stpcpy', prefix : '#include <string.h>') |
| 42 | glib_conf.set('HAVE_STPCPY', 1) |
| 43 | endif |
| 44 | |
| 45 | # Check that posix_memalign() is usable; must use header |
| 46 | -if cc.has_function('posix_memalign', prefix : '#include <stdlib.h>') |
| 47 | +if host_system != 'windows' and cc.has_function('posix_memalign', prefix : '#include <stdlib.h>') |
| 48 | glib_conf.set('HAVE_POSIX_MEMALIGN', 1) |
| 49 | endif |
| 50 | |
| 51 | -- |
| 52 | 2.26.2 |
| 53 | |