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

Joern Wolfgang Rennecke <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <[email protected]>
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.
et-184-diff.txt (text/plain, 953 B)
2025-07-20  Joern Rennecke  <[email protected]>

	* 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;
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.