From 1e2f4f1bf7d5b5851ff2a569b8305ec26ed08769 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Tue, 7 Jun 2022 16:26:49 -0700 Subject: [PATCH] glib2: replace intl patch with upstream solution Signed-off-by: Rosen Penev --- libs/glib2/Makefile | 4 +- libs/glib2/patches/007-openwrt-libintl.patch | 15 -- libs/glib2/patches/010-libintl.patch | 144 +++++++++++++++++++ 3 files changed, 145 insertions(+), 18 deletions(-) delete mode 100644 libs/glib2/patches/007-openwrt-libintl.patch create mode 100644 libs/glib2/patches/010-libintl.patch diff --git a/libs/glib2/Makefile b/libs/glib2/Makefile index 8abd87ea1d535..d36a856f54c9e 100644 --- a/libs/glib2/Makefile +++ b/libs/glib2/Makefile @@ -44,12 +44,10 @@ define Package/glib2/description The GLib library of C routines endef -HOST_LDFLAGS += -Wl,-rpath,$(STAGING_DIR_HOSTPKG)/lib TARGET_CFLAGS += -ffunction-sections -fdata-sections -TARGET_LDFLAGS += -Wl,--gc-sections $(if $(INTL_FULL),-lintl) +TARGET_LDFLAGS += -Wl,--gc-sections COMP_ARGS= \ - -Diconv=external \ -Dselinux=disabled \ -Dlibmount=disabled \ -Dman=false \ diff --git a/libs/glib2/patches/007-openwrt-libintl.patch b/libs/glib2/patches/007-openwrt-libintl.patch deleted file mode 100644 index 8441e63476d10..0000000000000 --- a/libs/glib2/patches/007-openwrt-libintl.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- a/meson.build -+++ b/meson.build -@@ -2045,8 +2045,11 @@ endif - # proxy-libintl subproject. - # FIXME: glib-gettext.m4 has much more checks to detect broken/uncompatible - # implementations. This could be extended if issues are found in some platforms. -+# -+# 007-openwrt-libintl.patch: with BUILD_NLS=y use libintl-full, else use libc -+# - libintl_deps = [] --if cc.has_function('ngettext', args : osx_ldflags) -+if get_option('nls').disabled() and cc.has_function('ngettext', args : osx_ldflags) - have_bind_textdomain_codeset = cc.has_function('bind_textdomain_codeset') - else - # First just find the bare library. diff --git a/libs/glib2/patches/010-libintl.patch b/libs/glib2/patches/010-libintl.patch new file mode 100644 index 0000000000000..7e99b82d6f103 --- /dev/null +++ b/libs/glib2/patches/010-libintl.patch @@ -0,0 +1,144 @@ +From 750687bf2824fcaf8976fb8b558d583f29acdfeb Mon Sep 17 00:00:00 2001 +From: Eli Schwartz +Date: Tue, 7 Jun 2022 16:14:04 -0400 +Subject: [PATCH 1/2] meson: simplify iconv lookups using Meson's builtin + dependency lookup + +iconv is complicated to look up. That complexity now resides in +Meson, since 0.60.0, via a `dependency('iconv')` lookup, so use that +instead. + +No effort is made to support the old option for which type of iconv to +use. It was a false choice, because if only one was available, then +that's the only one you can use, and if both are available, the external +iconv shadows the builtin one and renders the builtin one unusable, +so there is still only one you can use. + +This meant that when configuring glib with -Diconv=libc on systems that +had an external iconv, the configure check would detect a valid libc +iconv, try to use it, and then fail during the build because iconv.h +belongs to the external iconv and generates machine code using the +external iconv ABI, but fails to link to the iconv `find_library()`. +Meson handles this transparently. +--- + meson.build | 20 +------------------- + meson_options.txt | 8 +------- + 2 files changed, 2 insertions(+), 26 deletions(-) + +--- a/meson.build ++++ b/meson.build +@@ -1958,28 +1958,10 @@ glibconfig_conf.set10('G_HAVE_GROWING_ST + # 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 + 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 +2028,37 @@ endif + # 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', args : osx_ldflags) +- 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', args : osx_ldflags, 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', args : osx_ldflags, 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', args : osx_ldflags, 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', args : osx_ldflags, +- 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 +--- a/meson_options.txt ++++ b/meson_options.txt +@@ -3,12 +3,6 @@ option('runtime_libdir', + value : '', + description : 'install runtime libraries relative to libdir') + +-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\')') +- + option('charsetalias_dir', + type : 'string', + value : '',