aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/dependencies
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2022-02-17 01:02:25 -0500
committerEli Schwartz <eschwartz@archlinux.org>2022-02-17 14:48:27 -0500
commit1ac6fc0595f992621cbb79b7971ba07db1fa8e62 (patch)
treeaaf1dfbd9867ad73a173f49afde336b42ecafe0e /mesonbuild/dependencies
parenta580fac83abd56a7576ea81f7cbb4693dffdcfe0 (diff)
downloadmeson-1ac6fc0595f992621cbb79b7971ba07db1fa8e62.zip
meson-1ac6fc0595f992621cbb79b7971ba07db1fa8e62.tar.gz
meson-1ac6fc0595f992621cbb79b7971ba07db1fa8e62.tar.bz2
intl dependency: include header when checking for libc builtin
This header is required anyway. And the compile test for linking to libc with the gettext symbol, can succeed when we try to use the literal symbol name without includes, but fail later during project build, because actually including libintl.h might redefine the function to match a forked symbol. This happens when GNU libintl is installed as a standalone library on systems that have a less fully-featured gettext implementation. So, by including the header in has_function, we can ensure that we test against the default resolved header. In the event that the symbol which is #define'd by the header is 'libintl_gettext', linking will fail against libc even when a builtin gettext does exist, and we will fall back to the intl dependency that provides -lintl (and which is needed to properly use the default header). Of course, even that probably won't work. has_function(prefix: '...') is useless to check the difference between builtins and external library functions. It has code to detect "builtins" that misfires in some cases (previously seen with iconv_open). Instead compile an open-coded test file that this intl dependency implementation fully controls, that doesn't get up to imaginative edge cases like trying to find `__builtin_gettext`. It's the only way to be sure. Fixes compiling against the intl dependency on e.g. Alpine Linux when the libintl package is installed.
Diffstat (limited to 'mesonbuild/dependencies')
-rw-r--r--mesonbuild/dependencies/misc.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/mesonbuild/dependencies/misc.py b/mesonbuild/dependencies/misc.py
index c769077..9cc549c 100644
--- a/mesonbuild/dependencies/misc.py
+++ b/mesonbuild/dependencies/misc.py
@@ -490,8 +490,9 @@ class IconvSystemDependency(SystemDependency):
class IntlBuiltinDependency(BuiltinDependency):
def __init__(self, name: str, env: 'Environment', kwargs: T.Dict[str, T.Any]):
super().__init__(name, env, kwargs)
+ code = '''#include <libintl.h>\n\nint main() {\n gettext("Hello world");\n}'''
- if self.clib_compiler.has_function('ngettext', '', env)[0]:
+ if self.clib_compiler.links(code, env)[0]:
self.is_found = True