[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnulib does not always detect need for iconv() hack on musl
From: |
Sergei Trofimovich |
Subject: |
gnulib does not always detect need for iconv() hack on musl |
Date: |
Sun, 17 Oct 2021 15:14:26 +0100 |
Hi gnulib! The problem:
The following fails bison-3.8.2 tests:
$ ./configure && make && make check
The following succeeds:
$ ./configure --host=x86_64-unknown-linux-musl && make && make check
The failure happens due to unexpected '*' output in report logs instead
of '%empty' on 'ASCII' locales.
These unexpected '*' pop back again because gnulib relies on '--host='
parameter for './configure' to detect musl target (for lack of better
signal?):
https://git.savannah.gnu.org/cgit/gnulib.git/tree/m4/musl.m4#n16
case "$host_os" in
*-musl*) AC_DEFINE([MUSL_LIBC], [1], [Define to 1 on musl libc.]) ;;
https://git.savannah.gnu.org/cgit/gnulib.git/tree/lib/unicodeio.c#n151
/* FreeBSD iconv(), NetBSD iconv(), and Solaris 11 iconv() insert
a '?' if they cannot convert. */
# if !defined _LIBICONV_VERSION
|| (res > 0 && outptr - outbuf == 1 && *outbuf == '?')
# endif
/* musl libc iconv() inserts a '*' if it cannot convert. */
# if !defined _LIBICONV_VERSION && MUSL_LIBC
|| (res > 0 && outptr - outbuf == 1 && *outbuf == '*')
# endif
)
return failure (code, NULL, callback_arg);
What do you think of enabling the workaround regardless of MUSL_LIBC
define?
Or perhaps gnulib should perform runtime testing to detect the need for
a hack? Here is how musl mangles symbols:
https://git.musl-libc.org/cgit/musl/tree/src/locale/iconv.c#n545
case US_ASCII:
if (c > 0x7f) subst: x++, c='*';
Below implements unconditional workaround.
Thank you!
--- a/lib/unicodeio.c
+++ b/lib/unicodeio.c
@@ -148,7 +148,7 @@ unicode_to_mb (unsigned int code,
|| (res > 0 && outptr - outbuf == 1 && *outbuf == '?')
# endif
/* musl libc iconv() inserts a '*' if it cannot convert. */
-# if !defined _LIBICONV_VERSION && MUSL_LIBC
+# if !defined _LIBICONV_VERSION
|| (res > 0 && outptr - outbuf == 1 && *outbuf == '*')
# endif
)
- gnulib does not always detect need for iconv() hack on musl,
Sergei Trofimovich <=