Merge branch 'backport-1439-stpcpy-fix-glib-2-64' into 'glib-2-64'

Backport !1439 “Fix stpcpy() detection“ to glib-2-64

See merge request GNOME/glib!1501
This commit is contained in:
Sebastian Dröge 2020-05-19 15:29:12 +00:00
commit 50ccd7b714

View File

@ -532,13 +532,23 @@ foreach f : functions
endif
endforeach
# Check that stpcpy() is usable; must use header
if cc.has_function('stpcpy', prefix : '#include <string.h>')
# Check that stpcpy() is usable; must use header.
# cc.has_function() in some cases (clang, gcc 10+) assumes that if the
# compiler provides a builtin of the same name that the function exists, while
# it's in fact not provided by any header or library. This is true for
# stpcpy() on Windows using clang and gcc as well as posix_memalign() using
# gcc on Windows. Skip these checks on Windows for now to avoid false
# positives. See https://github.com/mesonbuild/meson/pull/7116,
# https://github.com/mesonbuild/meson/issues/3672 and
# https://github.com/mesonbuild/meson/issues/5628.
# FIXME: Once meson no longer returns success for stpcpy() and
# posix_memalign() on Windows using GCC and clang we can remove this.
if host_system != 'windows' and cc.has_function('stpcpy', prefix : '#include <string.h>')
glib_conf.set('HAVE_STPCPY', 1)
endif
# Check that posix_memalign() is usable; must use header
if cc.has_function('posix_memalign', prefix : '#include <stdlib.h>')
if host_system != 'windows' and cc.has_function('posix_memalign', prefix : '#include <stdlib.h>')
glib_conf.set('HAVE_POSIX_MEMALIGN', 1)
endif