bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
* gnulib does not always detect need for iconv() hack on musl
@ 2021-10-17 14:14 Sergei Trofimovich
  2021-10-17 17:18 ` Bruno Haible
  0 siblings, 1 reply; 6+ messages in thread
From: Sergei Trofimovich @ 2021-10-17 14:14 UTC (permalink / raw)
  To: bug-gnulib; +Cc: Bruno Haible

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
          )


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-10-18  8:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-17 14:14 gnulib does not always detect need for iconv() hack on musl Sergei Trofimovich
2021-10-17 17:18 ` Bruno Haible
2021-10-17 18:13   ` Sergei Trofimovich
2021-10-17 19:27     ` Bruno Haible
2021-10-18  0:27       ` Bruno Haible
2021-10-18  8:16         ` Sergei Trofimovich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).