Merge branch 'meson-dependency-lookups' into 'main'

meson: simplify iconv/intl lookups using Meson's builtin dependency lookup

See merge request GNOME/glib!2734
This commit is contained in:
Philip Withnall 2022-06-17 10:36:29 +00:00
commit 4a8120ec22
5 changed files with 47 additions and 66 deletions

View File

@ -386,11 +386,10 @@ freebsd-12-x86_64:
- bash .gitlab-ci/show-execution-environment.sh
script:
# We cannot use -Wl,--no-undefined because GLib uses 'environ' variable.
# FreeBSD iconv doesn't handle transliteration, so we use (external) GNU libiconv here.
# FreeBSD supports xattr, but its API is different from Linux xattr.
# FIXME: extattr(2) support: https://gitlab.gnome.org/GNOME/glib/issues/1404
# localstatedir is needed for access to /var/lib/dbus/machine-id
- meson ${MESON_COMMON_OPTIONS} --localstatedir=/var -Db_lundef=false -Diconv=external -Dxattr=false _build
- meson ${MESON_COMMON_OPTIONS} --localstatedir=/var -Db_lundef=false -Dxattr=false _build
- ninja -C _build
- bash -x ./.gitlab-ci/run-tests.sh
artifacts:
@ -417,7 +416,7 @@ freebsd-13-x86_64:
before_script:
- bash .gitlab-ci/show-execution-environment.sh
script:
- meson ${MESON_COMMON_OPTIONS} --localstatedir=/var -Db_lundef=false -Diconv=external -Dxattr=false _build
- meson ${MESON_COMMON_OPTIONS} --localstatedir=/var -Db_lundef=false -Dxattr=false _build
- ninja -C _build
- bash -x ./.gitlab-ci/run-tests.sh
artifacts:

7
NEWS
View File

@ -1,3 +1,10 @@
Overview of changes in GLib 2.73.1
==================================
* Remove the `-Diconv` configure option, as GLib now uses Mesons built-in logic for
finding which iconv implementation to use (work by Eli Schwartz) (!2734)
Overview of changes in GLib 2.73.0
==================================

View File

@ -29,7 +29,7 @@
On FreeBSD:
<literallayout>
<userinput>env CPPFLAGS="-I/usr/local/include" LDFLAGS="-L/usr/local/lib -Wl,--disable-new-dtags" meson -Dxattr=false -Dinstalled_tests=true -Diconv=external -Db_lundef=false _build</userinput>
<userinput>env CPPFLAGS="-I/usr/local/include" LDFLAGS="-L/usr/local/lib -Wl,--disable-new-dtags" meson -Dxattr=false -Dinstalled_tests=true -Db_lundef=false _build</userinput>
<userinput>ninja -C _build</userinput>
</literallayout>
</para>
@ -98,16 +98,12 @@
</para>
<para>
If your system has an <function>iconv()</function> implementation but
you want to use libiconv instead, you can pass the
<option>-Diconv=gnu</option> option to <command>meson</command>. This
forces libiconv to be used.
</para>
<para>
Note that if you have libiconv installed in your default include
search path (for instance, in <filename>/usr/local/</filename>), but
don't enable it, you will get an error while compiling GLib because
the <filename>iconv.h</filename> that libiconv installs hides the
system iconv.
you want to use libiconv instead, make sure it is installed to the
default compiler header/library search path (for instance, in
<filename>/usr/local/</filename>). The <filename>iconv.h</filename>
that libiconv installs hides the system iconv. Meson then detects
this, recognizes that the system iconv is unusable and the external
one is mandatory, and automatically forces it to be used.
</para>
<para>
If you are using the native iconv implementation on Solaris

View File

@ -1976,28 +1976,12 @@ glibconfig_conf.set10('G_HAVE_GROWING_STACK', growing_stack)
# We should never use the MinGW C library's iconv because it may not be
# available in the actual runtime environment. On Windows, we always use
# the built-in implementation
iconv_opt = get_option('iconv')
if host_system == 'windows'
libiconv = []
# We have a #include "win_iconv.c" in gconvert.c on Windows, so we don't need
# any external library for it
if iconv_opt != 'auto'
warning('-Diconv was set to @0@, which was ignored')
endif
libiconv = []
else
found_iconv = false
if ['auto', 'libc'].contains(iconv_opt) and cc.has_function('iconv_open')
libiconv = []
found_iconv = true
endif
if not found_iconv and ['auto', 'external'].contains(iconv_opt) and cc.has_header_symbol('iconv.h', 'iconv_open')
libiconv = [cc.find_library('iconv')]
found_iconv = true
endif
if not found_iconv
error('iconv implementation "@0@" not found'.format(iconv_opt))
endif
libiconv = dependency('iconv')
endif
pcre = dependency('libpcre', version: '>= 8.31', required : false) # Should check for Unicode support, too. FIXME
@ -2046,42 +2030,37 @@ libz_dep = dependency('zlib')
# FIXME: glib-gettext.m4 has much more checks to detect broken/uncompatible
# implementations. This could be extended if issues are found in some platforms.
libintl_deps = []
if cc.has_function('ngettext')
have_bind_textdomain_codeset = cc.has_function('bind_textdomain_codeset')
else
# First just find the bare library.
libintl = cc.find_library('intl', required : false)
# The bare library probably won't link without help if it's static.
if libintl.found() and not cc.has_function('ngettext', dependencies : libintl)
libintl_iconv = cc.find_library('iconv', required : false)
# libintl supports different threading APIs, which may not
# require additional flags, but it defaults to using pthreads if
# found. Meson's "threads" dependency does not allow you to
# prefer pthreads. We may not be using pthreads for glib itself
# either so just link the library to satisfy libintl rather than
# also defining the macros with the -pthread flag.
libintl_pthread = cc.find_library('pthread', required : false)
# Try linking with just libiconv.
if libintl_iconv.found() and cc.has_function('ngettext', dependencies : [libintl, libintl_iconv])
libintl_deps += [libintl_iconv]
# Then also try linking with pthreads.
elif libintl_iconv.found() and libintl_pthread.found() and cc.has_function('ngettext', dependencies : [libintl, libintl_iconv, libintl_pthread])
libintl_deps += [libintl_iconv, libintl_pthread]
else
libintl = disabler()
endif
endif
if not libintl.found()
libintl = subproject('proxy-libintl').get_variable('intl_dep')
libintl_deps = [libintl] + libintl_deps
have_bind_textdomain_codeset = true # proxy-libintl supports it
libintl = dependency('intl', required: false)
if libintl.found()
# libintl supports different threading APIs, which may not
# require additional flags, but it defaults to using pthreads if
# found. Meson's "threads" dependency does not allow you to
# prefer pthreads. We may not be using pthreads for glib itself
# either so just link the library to satisfy libintl rather than
# also defining the macros with the -pthread flag.
#
# Meson's builtin dependency lookup as of 0.60.0 doesn't check for
# pthread, so we do this manually here.
if cc.has_function('ngettext', dependencies : libintl)
libintl_deps += [libintl]
else
libintl_deps = [libintl] + libintl_deps
have_bind_textdomain_codeset = cc.has_function('bind_textdomain_codeset',
dependencies : libintl_deps)
libintl_pthread = cc.find_library('pthread', required : false)
if libintl_pthread.found() and cc.has_function('ngettext', dependencies : [libintl, libintl_pthread])
libintl_deps += [libintl, libintl_pthread]
else
libintl = disabler()
endif
endif
endif
if libintl.found()
have_bind_textdomain_codeset = cc.has_function('bind_textdomain_codeset', dependencies: libintl_deps)
else
libintl = subproject('proxy-libintl').get_variable('intl_dep')
libintl_deps = [libintl]
have_bind_textdomain_codeset = true # proxy-libintl supports it
endif
glib_conf.set('HAVE_BIND_TEXTDOMAIN_CODESET', have_bind_textdomain_codeset)
# We require gettext to always be present

View File

@ -7,7 +7,7 @@ option('iconv',
type : 'combo',
choices : ['auto', 'libc', 'external'],
value : 'auto',
description : 'iconv implementation to use (\'libc\' = \'Part of the C library\'; \'external\' = \'External libiconv\'; \'auto\' = \'Auto-detect which iconv is available\')')
deprecated: true,)
option('charsetalias_dir',
type : 'string',
@ -116,4 +116,4 @@ option('glib_checks',
option('libelf',
type : 'feature',
value : 'auto',
description : 'Enable support for listing and extracting from ELF resource files with gresource tool')
description : 'Enable support for listing and extracting from ELF resource files with gresource tool')