[PATCH v2] libc/stdio: Remove wchar_t functions from NEWLIB_NANO_FORMATTED_IO

Joern Wolfgang Rennecke joern.rennecke@riscy-ip.com
Sun Jul 20 13:01:36 GMT 2025


Apologies for the late reply, but we just upgraded our newlib base 
version, and I found that this patch:
https://sourceware.org/git/?p=newlib-cygwin.git;a=commitdiff;h=3b97a5ec67a5a52c130158bb143949cd842de305

causes more than 23000 regressions in the gcc testsuite for eSi-RISC .
We got:
amylaar@thian:~/riscy-ip$ egrep 
'HAVE_STDIO_DIR|NEWLIB_NANO_FORMATTED_IO|ELIX_LEVEL' 
gcc15/gcc/trunk/build/esirisc-elf/esi3250_kintex7demo/newlib/config.statusS["HAVE_STDIO_DIR_FALSE"]="#"
S["HAVE_STDIO_DIR_TRUE"]=""
S["ELIX_LEVEL_4_FALSE"]=""
S["ELIX_LEVEL_4_TRUE"]="#"
S["ELIX_LEVEL_3_FALSE"]=""
S["ELIX_LEVEL_3_TRUE"]="#"
S["ELIX_LEVEL_2_FALSE"]=""
S["ELIX_LEVEL_2_TRUE"]="#"
S["ELIX_LEVEL_1_FALSE"]=""
S["ELIX_LEVEL_1_TRUE"]="#"
S["ELIX_LEVEL_0_FALSE"]="#"
S["ELIX_LEVEL_0_TRUE"]=""
S["NEWLIB_NANO_FORMATTED_IO_FALSE"]="#"
S["NEWLIB_NANO_FORMATTED_IO_TRUE"]=""


cc15/gcc/trunk/build/esirisc-elf/esi3250_kintex7demo/newlib/targ-include/newlib.h 
has:
/* EL/IX level */
/* #undef _ELIX_LEVEL */
...
/* Define if wide char orientation is supported. */
#define _WIDE_ORIENT 1

Thus,  libc_a-fputwc.o is not built, but _fputwc_r is referenced twice 
in libc_a-nano-vfprintf.o

The attached patch avoids these references Apologies for the late reply, 
but we just upgraded our newlib base version, and I found that this patch:
https://sourceware.org/git/?p=newlib-cygwin.git;a=commitdiff;h=3b97a5ec67a5a52c130158bb143949cd842de305

causes more than 23000 regressions in the gcc testsuite for eSi-RISC .
We got:
amylaar@thian:~/riscy-ip$ egrep 
'HAVE_STDIO_DIR|NEWLIB_NANO_FORMATTED_IO|ELIX_LEVEL' 
gcc15/gcc/trunk/build/esirisc-elf/esi3250_kintex7demo/newlib/config.statusS["HAVE_STDIO_DIR_FALSE"]="#"
S["HAVE_STDIO_DIR_TRUE"]=""
S["ELIX_LEVEL_4_FALSE"]=""
S["ELIX_LEVEL_4_TRUE"]="#"
S["ELIX_LEVEL_3_FALSE"]=""
S["ELIX_LEVEL_3_TRUE"]="#"
S["ELIX_LEVEL_2_FALSE"]=""
S["ELIX_LEVEL_2_TRUE"]="#"
S["ELIX_LEVEL_1_FALSE"]=""
S["ELIX_LEVEL_1_TRUE"]="#"
S["ELIX_LEVEL_0_FALSE"]="#"
S["ELIX_LEVEL_0_TRUE"]=""
S["NEWLIB_NANO_FORMATTED_IO_FALSE"]="#"
S["NEWLIB_NANO_FORMATTED_IO_TRUE"]=""


cc15/gcc/trunk/build/esirisc-elf/esi3250_kintex7demo/newlib/targ-include/newlib.h 
has:
/* EL/IX level */
/* #undef _ELIX_LEVEL */
...
/* Define if wide char orientation is supported. */
#define _WIDE_ORIENT 1

Thus, libc_a-fputwc.o is not built, but _fputwc_r is referenced twice in 
libc_a-nano-vfprintf.o .

The attached patch avoids these references when libc_a-fputwc.o is not 
built.
-------------- next part --------------
2025-07-20  Joern Rennecke  <joern.rennecke@riscy-ip.com>

	* newlib/libc/stdio/nano-vfprintf.c (__sprint_r, __sfputs_r)
	[!defined _ELIX_LEVEL && !defined (_NANO_FORMATTED_IO)]:
	Disable wide character code.

Index: nano-vfprintf.c
===================================================================
--- nano-vfprintf.c	(revision 6747)
+++ nano-vfprintf.c	(working copy)
@@ -356,7 +356,7 @@
       uio->uio_iovcnt = 0;
       return 0;
     }
-#if defined _WIDE_ORIENT && (!defined _ELIX_LEVEL || _ELIX_LEVEL >= 4)
+#if defined _WIDE_ORIENT && (defined _ELIX_LEVEL ? _ELIX_LEVEL >= 4 : !defined (_NANO_FORMATTED_IO))
     if (fp->_flags2 & __SWID)
       {
 	struct __siov *iov;
@@ -407,7 +407,7 @@
 {
   register int i;
 
-#if defined _WIDE_ORIENT && (!defined _ELIX_LEVEL || _ELIX_LEVEL >= 4)
+#if defined _WIDE_ORIENT && (defined _ELIX_LEVEL ? _ELIX_LEVEL >= 4 : !defined (_NANO_FORMATTED_IO))
   if (fp->_flags2 & __SWID)
     {
       wchar_t *p;


More information about the Newlib mailing list