Re: [BUG] coreutils 9.11 does not compile with uClibc-ng

Paul Eggert <[email protected]>
Newsgroups gmane.comp.lib.gnulib.bugs
Organization UCLA Computer Science Department
Message-ID <[email protected]>
Thanks for reporting that. I installed the attached somewhat lengthier 
patch into Gnulib; please take a look and give it a try.
0001-mbrtoc32-mbrtowc-do-not-optimze-for-uClibc-ng.patch (text/x-patch, 3.3 KB)
From 17dc60e624cd6fc3491f9cb002f760d60e66ce8b Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email protected]>
Date: Mon, 25 May 2026 20:37:32 +0200
Subject: [PATCH] mbrtoc32, mbrtowc: do not optimze for uClibc-ng

Problem reported by Waldemar Brodkorb in:
https://lists.gnu.org/r/bug-gnulib/2026-05/msg00145.html
* lib/mbrtoc32.c (mbrtoc32):
* lib/mbrtowc.c (rpl_mbrtowc):
Treat uClibc-ng as non-glibc.
---
 ChangeLog      | 7 +++++++
 lib/mbrtoc32.c | 7 ++++---
 lib/mbrtowc.c  | 7 ++++---
 3 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ec8648260e..7c1b291c75 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2026-05-25  Waldemar Brodkorb  <[email protected]>
+
+	mbrtoc32: do not optimze for uClibc-ng
+	* lib/mbrtoc32.c (mbrtoc32):
+	* lib/mbrtowc.c (rpl_mbrtowc):
+	Treat uClibc-ng as non-glibc.
+
 2026-05-25  Paul Eggert  <[email protected]>
 
 	quotearg: support USE_C_LOCALE variant
diff --git a/lib/mbrtoc32.c b/lib/mbrtoc32.c
index 7d691b8b2f..5f89e05460 100644
--- a/lib/mbrtoc32.c
+++ b/lib/mbrtoc32.c
@@ -97,7 +97,7 @@ mbrtoc32 (char32_t *pwc, const char *s, size_t n, mbstate_t *ps)
 #  include <locale.h>
 # endif
 
-# if (GNULIB_WCHAR_SINGLE_LOCALE && __GLIBC__ >= 2)
+# if (GNULIB_WCHAR_SINGLE_LOCALE && __GLIBC__ >= 2 && !__UCLIBC__)
 
 /* Returns 1 if the current locale is an UTF-8 locale, 0 otherwise.  */
 static inline int
@@ -134,7 +134,8 @@ mbrtoc32 (char32_t *pwc, const char *s, size_t n, mbstate_t *ps)
       n = 1;
     }
 
-# if MBRTOC32_EMPTY_INPUT_BUG || _GL_SMALL_WCHAR_T || (GNULIB_WCHAR_SINGLE_LOCALE && __GLIBC__ >= 2)
+# if (MBRTOC32_EMPTY_INPUT_BUG || _GL_SMALL_WCHAR_T \
+      || (GNULIB_WCHAR_SINGLE_LOCALE && __GLIBC__ >= 2 && !__UCLIBC__))
   if (n == 0)
     return (size_t) -2;
 # endif
@@ -142,7 +143,7 @@ mbrtoc32 (char32_t *pwc, const char *s, size_t n, mbstate_t *ps)
   if (ps == NULL)
     ps = &internal_state;
 
-# if (GNULIB_WCHAR_SINGLE_LOCALE && __GLIBC__ >= 2)
+# if (GNULIB_WCHAR_SINGLE_LOCALE && __GLIBC__ >= 2 && !__UCLIBC__)
   /* Optimize the frequent case of an UTF-8 locale.
      Since here we are in the !GNULIB_defined_mbstate_t case, i.e. we use
      the system's mbstate_t type and have to provide interoperability with
diff --git a/lib/mbrtowc.c b/lib/mbrtowc.c
index 59320cd51c..f533b554f3 100644
--- a/lib/mbrtowc.c
+++ b/lib/mbrtowc.c
@@ -83,7 +83,7 @@ mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
 #  include <locale.h>
 # endif
 
-# if (GNULIB_WCHAR_SINGLE_LOCALE && __GLIBC__ >= 2)
+# if (GNULIB_WCHAR_SINGLE_LOCALE && __GLIBC__ >= 2 && !__UCLIBC__)
 
 /* Returns 1 if the current locale is an UTF-8 locale, 0 otherwise.  */
 static inline int
@@ -119,12 +119,13 @@ rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
     }
 # endif
 
-# if MBRTOWC_EMPTY_INPUT_BUG || (GNULIB_WCHAR_SINGLE_LOCALE && __GLIBC__ >= 2)
+# if (MBRTOC32_EMPTY_INPUT_BUG || _GL_SMALL_WCHAR_T \
+      || (GNULIB_WCHAR_SINGLE_LOCALE && __GLIBC__ >= 2 && !__UCLIBC__))
   if (n == 0)
     return (size_t) -2;
 # endif
 
-# if (GNULIB_WCHAR_SINGLE_LOCALE && __GLIBC__ >= 2)
+# if (GNULIB_WCHAR_SINGLE_LOCALE && __GLIBC__ >= 2 && !__UCLIBC__)
   /* Optimize the frequent case of an UTF-8 locale.
      Since here we are in the !GNULIB_defined_mbstate_t case, i.e. we use
      the system's mbstate_t type and have to provide interoperability with
-- 
2.53.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.