Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
glib2: replace intl patch with upstream solution
Signed-off-by: Rosen Penev <rosenp@gmail.com>
- Loading branch information
Showing
3 changed files
with
145 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
From 750687bf2824fcaf8976fb8b558d583f29acdfeb Mon Sep 17 00:00:00 2001 | ||
From: Eli Schwartz <eschwartz@archlinux.org> | ||
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 : '', |
1e2f4f1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I now have problems building irqbalance (under macos) with this glib2 change in place. I have no idea if this is a glib2 and irqbalance problem.
/bin/sh ./libtool --tag=CC --mode=link ccache_cc -I/Volumes/CaseSense/wrt/staging_dir/target-x86_64_musl/usr/include/glib-2.0 -I/Volumes/CaseSense/wrt/staging_dir/target-x86_64_musl/usr/lib/glib-2.0/include -I/Volumes/CaseSense/wrt/staging_dir/target-x86_64_musl/usr/include -O2 -pipe -march=btver2 -fno-caller-saves -fno-plt -march=btver2 -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -I/Volumes/CaseSense/wrt/staging_dir/target-x86_64_musl/usr/lib/libiconv-stub/include -I/Volumes/CaseSense/wrt/staging_dir/target-x86_64_musl/usr/lib/libintl-stub/include -fmacro-prefix-map=/Volumes/CaseSense/wrt/build_dir/target-x86_64_musl/irqbalance-1.9.0=irqbalance-1.9.0 -Wformat -Werror=format-security -DPIC -fpic -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -L/Volumes/CaseSense/wrt/staging_dir/toolchain-x86_64_gcc-12.1.0_musl/usr/lib -L/Volumes/CaseSense/wrt/staging_dir/toolchain-x86_64_gcc-12.1.0_musl/lib -L/Volumes/CaseSense/wrt/staging_dir/target-x86_64_musl/usr/lib/libiconv-stub/lib -Wl,-rpath-link=/Volumes/CaseSense/wrt/staging_dir/target-x86_64_musl/usr/lib/libiconv-stub/lib -L/Volumes/CaseSense/wrt/staging_dir/target-x86_64_musl/usr/lib/libintl-stub/lib -Wl,-rpath-link=/Volumes/CaseSense/wrt/staging_dir/target-x86_64_musl/usr/lib/libintl-stub/lib -DPIC -fpic -specs=/Volumes/CaseSense/wrt/include/hardened-ld-pie.specs -znow -zrelro -o irqbalance activate.o bitmap.o classify.o cputree.o irqbalance.o irqlist.o numa.o placement.o procinterrupts.o /Volumes/CaseSense/wrt/staging_dir/target-x86_64_musl/usr/lib/libglib-2.0.a -L/Volumes/CaseSense/wrt/staging_dir/target-x86_64_musl/usr/lib/libiconv-stub/lib -Wl,-rpath-link=/Volumes/CaseSense/wrt/staging_dir/target-x86_64_musl/usr/lib/libiconv-stub/lib -liconv -lm
OpenWrt-libtool: link: ccache_cc -I/Volumes/CaseSense/wrt/staging_dir/target-x86_64_musl/usr/include/glib-2.0 -I/Volumes/CaseSense/wrt/staging_dir/target-x86_64_musl/usr/lib/glib-2.0/include -I/Volumes/CaseSense/wrt/staging_dir/target-x86_64_musl/usr/include -O2 -pipe -march=btver2 -fno-caller-saves -fno-plt -march=btver2 -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -I/Volumes/CaseSense/wrt/staging_dir/target-x86_64_musl/usr/lib/libiconv-stub/include -I/Volumes/CaseSense/wrt/staging_dir/target-x86_64_musl/usr/lib/libintl-stub/include -fmacro-prefix-map=/Volumes/CaseSense/wrt/build_dir/target-x86_64_musl/irqbalance-1.9.0=irqbalance-1.9.0 -Wformat -Werror=format-security -DPIC -fpic -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z -Wl,now -Wl,-z -Wl,relro -Wl,-rpath-link=/Volumes/CaseSense/wrt/staging_dir/target-x86_64_musl/usr/lib/libiconv-stub/lib -Wl,-rpath-link=/Volumes/CaseSense/wrt/staging_dir/target-x86_64_musl/usr/lib/libintl-stub/lib -DPIC -fpic -specs=/Volumes/CaseSense/wrt/include/hardened-ld-pie.specs -znow -zrelro -o irqbalance activate.o bitmap.o classify.o cputree.o irqbalance.o irqlist.o numa.o placement.o procinterrupts.o -Wl,-rpath-link=/Volumes/CaseSense/wrt/staging_dir/target-x86_64_musl/usr/lib/libiconv-stub/lib -L/Volumes/CaseSense/wrt/staging_dir/toolchain-x86_64_gcc-12.1.0_musl/usr/lib -L/Volumes/CaseSense/wrt/staging_dir/toolchain-x86_64_gcc-12.1.0_musl/lib -L/Volumes/CaseSense/wrt/staging_dir/target-x86_64_musl/usr/lib/libiconv-stub/lib -L/Volumes/CaseSense/wrt/staging_dir/target-x86_64_musl/usr/lib/libintl-stub/lib /Volumes/CaseSense/wrt/staging_dir/target-x86_64_musl/usr/lib/libglib-2.0.a -liconv -lm
/Volumes/CaseSense/wrt/staging_dir/toolchain-x86_64_gcc-12.1.0_musl/lib/gcc/x86_64-openwrt-linux-musl/12.1.0/../../../../x86_64-openwrt-linux-musl/bin/ld: /Volumes/CaseSense/wrt/tmp/cccPJkyK.ltrans0.ltrans.o: in function
glib_gettext': <artificial>:(.text+0x751c): undefined reference to
g_libintl_dgettext'/Volumes/CaseSense/wrt/staging_dir/toolchain-x86_64_gcc-12.1.0_musl/lib/gcc/x86_64-openwrt-linux-musl/12.1.0/../../../../x86_64-openwrt-linux-musl/bin/ld: :(.text+0x7546): undefined reference to
g_libintl_bindtextdomain' /Volumes/CaseSense/wrt/staging_dir/toolchain-x86_64_gcc-12.1.0_musl/lib/gcc/x86_64-openwrt-linux-musl/12.1.0/../../../../x86_64-openwrt-linux-musl/bin/ld: <artificial>:(.text+0x7556): undefined reference to
g_libintl_bind_textdomain_codeset'/Volumes/CaseSense/wrt/staging_dir/toolchain-x86_64_gcc-12.1.0_musl/lib/gcc/x86_64-openwrt-linux-musl/12.1.0/../../../../x86_64-openwrt-linux-musl/bin/ld: :(.text+0x759b): undefined reference to
g_libintl_textdomain' /Volumes/CaseSense/wrt/staging_dir/toolchain-x86_64_gcc-12.1.0_musl/lib/gcc/x86_64-openwrt-linux-musl/12.1.0/../../../../x86_64-openwrt-linux-musl/bin/ld: <artificial>:(.text+0x75ab): undefined reference to
g_libintl_gettext'collect2: error: ld returned 1 exit status
make[5]: *** [Makefile:565: irqbalance] Error 1
1e2f4f1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR available. On a separate note, I've never gotten glib2 to build on macOS.
1e2f4f1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ldir-EDB0 oh I see the issue. You're probably not building with CONFIG_BUILD_NLS=y
1e2f4f1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that's correct - If I build with CONFIG_BUILD_NLS=y then things are ok again. I can do that, I don't have any flash space issues :-)
1e2f4f1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm I wonder if Alpine Linux would have the same issue. I’ll look when I get back home.
1e2f4f1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still a bug though. Can you post the contents of $(PKG_BUILD_DIR)/openwrt-build/meson-logs ?
Something tells me meson is using brew’s gettext.
1e2f4f1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, let me break it again and look :-) I think you're after ./target-x86_64_musl/glib-2.70.5/openwrt-build/meson-logs/meson-log.txt ?
https://1drv.ms/u/s!Asnm-2nAdca5hpIHwfVnO8TYljnDjA?e=ZeOar5
1e2f4f1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ldir-EDB0 your log shows libintl-stub. That's not in base. It was removed with openwrt/openwrt@e6f5694 . No idea why you still have that.
1e2f4f1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not going to report this upstream. libintl-stub was a hackjob for uClibc-ng.
1e2f4f1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's mentioned in include/nls.mk
1e2f4f1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah yeah. https://patchwork.ozlabs.org/project/openwrt/patch/YpzvoD4y0PBO/UNc@darth.lan/ needs to be merged.
It looks like your staging_dir is from before openwrt/openwrt@e6f5694 was merged. If $(STAGING_DIR)/usr/lib/libintl-stub actually has stuff on your end, that's a bug.
1e2f4f1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, my staging tree has openwrt/openwrt@e6f5694 merged - but until now I didn't have the patchwork patch... so I'm trying that :-)
And it doesn't work.