Re: [PATCH 0/2] fix undefined reference to `__ssputws_r'
Joern Wolfgang Rennecke <[email protected]>
| Newsgroups | gmane.comp.lib.newlib |
|---|---|
| Message-ID | <[email protected]> |
On Jul 21 09:56, Corinna Vinschen wrote:
>On 20/07/2025 15:17, Joern Wolfgang Rennecke wrote:
>> We need to decide first if --enable-newlib-nano-formatted-io should or
>> should not remove support for wide character handling.
>> Then we can look at individual test failures.
>
>Didn't we already remove wchar support at least partially with commit
>3b97a5ec67a5 ("libc/stdio: Remove wchar_t functions from
>NEWLIB_NANO_FORMATTED_IO")?
Yes, this partial removal is the cause of massive breakage both in C and
C++, because a lot of wchar functions have disappeared from libc.a, but
not all the references.
To fix the immediate breakage, we could either make the removal
complete, or use Hau Hsu's approach to revert the wchar support removal,
and fix the original problem without a feature change.
As was pointed out in
https://sourceware.org/pipermail/newlib/2024/021160.html ,
where Hau Hsu wrote on Jul 8 2024:
>The previous patch removes wchar_t functions from
>NEWLIB_NANO_FORMATTED_IO, but in the newlib/README says:
>
>> --enable-newlib-nano-formatted-io
>> This option does not affect wide-char formatted I/O functions
With newlib 4.5.0 , we now have a release where the README still says that,
but most of the wchar support is missing from the built library, and
what remains causes link failures.
>So I guess applying
https://sourceware.org/pipermail/newlib/2024/021162.html
>or something along these lines should be in order.
>
>A new patch or a resend of the patch from 2024 would be most helpful.
Ok, I've re-made the revert patch from git, and cut&pasted the patch
"[PATCH 2/2] libc/stdio: fix undefined reference to `__ssputws_r'",
and verified that both apply cleanly to my newlib 4.5.0 copy.
Both patches are attached.
rev-06aa5a751682118ef1d7f2456f8937b4ac181fac.txt
(text/plain, 151.5 KB) - not displayed
ssputws-patch.txt
(text/plain, 12.2 KB)
In a post titled "[PATCH 2/2] libc/stdio: fix undefined reference to `__ssputws_r'", Hau Hsu <[email protected]> wrote on Mon Jul 8 04:01:57 GMT 2024: *Issue* When compile a simple C++ hello world, we got undefined reference to `__ssputws_r' error with NEWLIB_NANO_FORMATTED_IO after upgrading to newlib-4.4 in risc-v toolchain: svfwprintf.c:(.text._svfwprintf_r+0x8e): undefined reference to `__ssputws_r' *Cause* This is because commit "v{fs}printf/v{fs}wprintf: create external output helpers" <https://cygwin.com/git/?p=newlib-cygwin.git;a=commit;h=61ccd3f94f92bcfc0940f0595ea5b3b72bce3c6d> introduces a new file ssputws_r.c for a wide-char-oriented helper function. But this file will not be built when newlib_nano_formated_io is enabled. The problem is that the function __ssputws_r() is used by svfwprintf(), which is compiled no matter whether newlib_nano_formated_io is enabled. *Fix* This patch fix the issue by building ssputws_r.c regardless of whether newlib_nano_formated_io is enabled. *Problem of the previous fix* Note that we also reverts a previouls patch that tries to fix the same link error: <https://cygwin.com/git/?p=newlib-cygwin.git;a=commitdiff;h=3b97a5ec67a5a52c130158bb143949cd842de305> Because we got other errors after applying this patch: undefined reference to `putwc' ... undefined reference to `getwc' ... undefined reference to `swprintf' The previous patch removes wchar_t functions from NEWLIB_NANO_FORMATTED_IO, but in the newlib/README says: > --enable-newlib-nano-formatted-io > This option does not affect wide-char formatted I/O functions Thus I think we shouldn't remove wchar_t functions from newlib_nano_formated_io. Similar bug report: * https://inbox.sourceware.org/newlib/[email protected]/t/ --- newlib/Makefile.in | 38 ++++++++++++++++------------------ newlib/libc/stdio/Makefile.inc | 2 +- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/newlib/Makefile.in b/newlib/Makefile.in index 2bd1431f9..523069ad4 100644 --- a/newlib/Makefile.in +++ b/newlib/Makefile.in @@ -243,7 +243,6 @@ check_PROGRAMS = @HAVE_STDIO_DIR_TRUE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ libc/stdio/sprint_r.c \ @HAVE_STDIO_DIR_TRUE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ libc/stdio/swprint_r.c \ @HAVE_STDIO_DIR_TRUE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ libc/stdio/ssputs_r.c \ -@HAVE_STDIO_DIR_TRUE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ libc/stdio/ssputws_r.c \ @HAVE_STDIO_DIR_TRUE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ libc/stdio/ssprint_r.c \ @HAVE_STDIO_DIR_TRUE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ libc/stdio/sswprint_r.c @@ -278,7 +277,7 @@ check_PROGRAMS = @HAVE_STDIO_DIR_TRUE@ libc/stdio/setvbuf.c \ @HAVE_STDIO_DIR_TRUE@ libc/stdio/snprintf.c \ @HAVE_STDIO_DIR_TRUE@ libc/stdio/sprintf.c libc/stdio/sscanf.c \ -@HAVE_STDIO_DIR_TRUE@ libc/stdio/stdio.c \ +@HAVE_STDIO_DIR_TRUE@ libc/stdio/ssputws_r.c libc/stdio/stdio.c \ @HAVE_STDIO_DIR_TRUE@ libc/stdio/svfiwprintf.c \ @HAVE_STDIO_DIR_TRUE@ libc/stdio/svfiwscanf.c \ @HAVE_STDIO_DIR_TRUE@ libc/stdio/svfwprintf.c \ @@ -1190,7 +1189,6 @@ am__objects_5 = libc/stdlib/libc_a-rpmatch.$(OBJEXT) \ @HAVE_STDIO_DIR_TRUE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ libc/stdio/libc_a-sprint_r.$(OBJEXT) \ @HAVE_STDIO_DIR_TRUE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ libc/stdio/libc_a-swprint_r.$(OBJEXT) \ @HAVE_STDIO_DIR_TRUE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ libc/stdio/libc_a-ssputs_r.$(OBJEXT) \ -@HAVE_STDIO_DIR_TRUE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ libc/stdio/libc_a-ssputws_r.$(OBJEXT) \ @HAVE_STDIO_DIR_TRUE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ libc/stdio/libc_a-ssprint_r.$(OBJEXT) \ @HAVE_STDIO_DIR_TRUE@@NEWLIB_NANO_FORMATTED_IO_FALSE@ libc/stdio/libc_a-sswprint_r.$(OBJEXT) @ELIX_LEVEL_1_FALSE@@HAVE_STDIO_DIR_TRUE@@NEWLIB_NANO_FORMATTED_IO_FALSE@am__objects_12 = libc/stdio/libc_a-asiprintf.$(OBJEXT) \ @@ -1316,6 +1314,7 @@ am__objects_5 = libc/stdlib/libc_a-rpmatch.$(OBJEXT) \ @HAVE_STDIO_DIR_TRUE@ libc/stdio/libc_a-snprintf.$(OBJEXT) \ @HAVE_STDIO_DIR_TRUE@ libc/stdio/libc_a-sprintf.$(OBJEXT) \ @HAVE_STDIO_DIR_TRUE@ libc/stdio/libc_a-sscanf.$(OBJEXT) \ +@HAVE_STDIO_DIR_TRUE@ libc/stdio/libc_a-ssputws_r.$(OBJEXT) \ @HAVE_STDIO_DIR_TRUE@ libc/stdio/libc_a-stdio.$(OBJEXT) \ @HAVE_STDIO_DIR_TRUE@ libc/stdio/libc_a-svfiwprintf.$(OBJEXT) \ @HAVE_STDIO_DIR_TRUE@ libc/stdio/libc_a-svfiwscanf.$(OBJEXT) \ @@ -3941,7 +3940,6 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ -runstatedir = @runstatedir@ sbindir = @sbindir@ shared_machine_dir = @shared_machine_dir@ sharedstatedir = @sharedstatedir@ @@ -6001,8 +5999,6 @@ libc/stdio/libc_a-swprint_r.$(OBJEXT): libc/stdio/$(am__dirstamp) \ libc/stdio/$(DEPDIR)/$(am__dirstamp) libc/stdio/libc_a-ssputs_r.$(OBJEXT): libc/stdio/$(am__dirstamp) \ libc/stdio/$(DEPDIR)/$(am__dirstamp) -libc/stdio/libc_a-ssputws_r.$(OBJEXT): libc/stdio/$(am__dirstamp) \ - libc/stdio/$(DEPDIR)/$(am__dirstamp) libc/stdio/libc_a-ssprint_r.$(OBJEXT): libc/stdio/$(am__dirstamp) \ libc/stdio/$(DEPDIR)/$(am__dirstamp) libc/stdio/libc_a-sswprint_r.$(OBJEXT): libc/stdio/$(am__dirstamp) \ @@ -6115,6 +6111,8 @@ libc/stdio/libc_a-sprintf.$(OBJEXT): libc/stdio/$(am__dirstamp) \ libc/stdio/$(DEPDIR)/$(am__dirstamp) libc/stdio/libc_a-sscanf.$(OBJEXT): libc/stdio/$(am__dirstamp) \ libc/stdio/$(DEPDIR)/$(am__dirstamp) +libc/stdio/libc_a-ssputws_r.$(OBJEXT): libc/stdio/$(am__dirstamp) \ + libc/stdio/$(DEPDIR)/$(am__dirstamp) libc/stdio/libc_a-stdio.$(OBJEXT): libc/stdio/$(am__dirstamp) \ libc/stdio/$(DEPDIR)/$(am__dirstamp) libc/stdio/libc_a-svfiwprintf.$(OBJEXT): libc/stdio/$(am__dirstamp) \ @@ -24092,20 +24090,6 @@ libc/stdio/libc_a-ssputs_r.obj: libc/stdio/ssputs_r.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -c -o libc/stdio/libc_a-ssputs_r.obj `if test -f 'libc/stdio/ssputs_r.c'; then $(CYGPATH_W) 'libc/stdio/ssputs_r.c'; else $(CYGPATH_W) '$(srcdir)/libc/stdio/ssputs_r.c'; fi` -libc/stdio/libc_a-ssputws_r.o: libc/stdio/ssputws_r.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT libc/stdio/libc_a-ssputws_r.o -MD -MP -MF libc/stdio/$(DEPDIR)/libc_a-ssputws_r.Tpo -c -o libc/stdio/libc_a-ssputws_r.o `test -f 'libc/stdio/ssputws_r.c' || echo '$(srcdir)/'`libc/stdio/ssputws_r.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) libc/stdio/$(DEPDIR)/libc_a-ssputws_r.Tpo libc/stdio/$(DEPDIR)/libc_a-ssputws_r.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='libc/stdio/ssputws_r.c' object='libc/stdio/libc_a-ssputws_r.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -c -o libc/stdio/libc_a-ssputws_r.o `test -f 'libc/stdio/ssputws_r.c' || echo '$(srcdir)/'`libc/stdio/ssputws_r.c - -libc/stdio/libc_a-ssputws_r.obj: libc/stdio/ssputws_r.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT libc/stdio/libc_a-ssputws_r.obj -MD -MP -MF libc/stdio/$(DEPDIR)/libc_a-ssputws_r.Tpo -c -o libc/stdio/libc_a-ssputws_r.obj `if test -f 'libc/stdio/ssputws_r.c'; then $(CYGPATH_W) 'libc/stdio/ssputws_r.c'; else $(CYGPATH_W) '$(srcdir)/libc/stdio/ssputws_r.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) libc/stdio/$(DEPDIR)/libc_a-ssputws_r.Tpo libc/stdio/$(DEPDIR)/libc_a-ssputws_r.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='libc/stdio/ssputws_r.c' object='libc/stdio/libc_a-ssputws_r.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -c -o libc/stdio/libc_a-ssputws_r.obj `if test -f 'libc/stdio/ssputws_r.c'; then $(CYGPATH_W) 'libc/stdio/ssputws_r.c'; else $(CYGPATH_W) '$(srcdir)/libc/stdio/ssputws_r.c'; fi` - libc/stdio/libc_a-ssprint_r.o: libc/stdio/ssprint_r.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT libc/stdio/libc_a-ssprint_r.o -MD -MP -MF libc/stdio/$(DEPDIR)/libc_a-ssprint_r.Tpo -c -o libc/stdio/libc_a-ssprint_r.o `test -f 'libc/stdio/ssprint_r.c' || echo '$(srcdir)/'`libc/stdio/ssprint_r.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) libc/stdio/$(DEPDIR)/libc_a-ssprint_r.Tpo libc/stdio/$(DEPDIR)/libc_a-ssprint_r.Po @@ -24890,6 +24874,20 @@ libc/stdio/libc_a-sscanf.obj: libc/stdio/sscanf.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -c -o libc/stdio/libc_a-sscanf.obj `if test -f 'libc/stdio/sscanf.c'; then $(CYGPATH_W) 'libc/stdio/sscanf.c'; else $(CYGPATH_W) '$(srcdir)/libc/stdio/sscanf.c'; fi` +libc/stdio/libc_a-ssputws_r.o: libc/stdio/ssputws_r.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT libc/stdio/libc_a-ssputws_r.o -MD -MP -MF libc/stdio/$(DEPDIR)/libc_a-ssputws_r.Tpo -c -o libc/stdio/libc_a-ssputws_r.o `test -f 'libc/stdio/ssputws_r.c' || echo '$(srcdir)/'`libc/stdio/ssputws_r.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) libc/stdio/$(DEPDIR)/libc_a-ssputws_r.Tpo libc/stdio/$(DEPDIR)/libc_a-ssputws_r.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='libc/stdio/ssputws_r.c' object='libc/stdio/libc_a-ssputws_r.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -c -o libc/stdio/libc_a-ssputws_r.o `test -f 'libc/stdio/ssputws_r.c' || echo '$(srcdir)/'`libc/stdio/ssputws_r.c + +libc/stdio/libc_a-ssputws_r.obj: libc/stdio/ssputws_r.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT libc/stdio/libc_a-ssputws_r.obj -MD -MP -MF libc/stdio/$(DEPDIR)/libc_a-ssputws_r.Tpo -c -o libc/stdio/libc_a-ssputws_r.obj `if test -f 'libc/stdio/ssputws_r.c'; then $(CYGPATH_W) 'libc/stdio/ssputws_r.c'; else $(CYGPATH_W) '$(srcdir)/libc/stdio/ssputws_r.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) libc/stdio/$(DEPDIR)/libc_a-ssputws_r.Tpo libc/stdio/$(DEPDIR)/libc_a-ssputws_r.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='libc/stdio/ssputws_r.c' object='libc/stdio/libc_a-ssputws_r.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -c -o libc/stdio/libc_a-ssputws_r.obj `if test -f 'libc/stdio/ssputws_r.c'; then $(CYGPATH_W) 'libc/stdio/ssputws_r.c'; else $(CYGPATH_W) '$(srcdir)/libc/stdio/ssputws_r.c'; fi` + libc/stdio/libc_a-stdio.o: libc/stdio/stdio.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT libc/stdio/libc_a-stdio.o -MD -MP -MF libc/stdio/$(DEPDIR)/libc_a-stdio.Tpo -c -o libc/stdio/libc_a-stdio.o `test -f 'libc/stdio/stdio.c' || echo '$(srcdir)/'`libc/stdio/stdio.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) libc/stdio/$(DEPDIR)/libc_a-stdio.Tpo libc/stdio/$(DEPDIR)/libc_a-stdio.Po diff --git a/newlib/libc/stdio/Makefile.inc b/newlib/libc/stdio/Makefile.inc index e25680212..58b40b2f5 100644 --- a/newlib/libc/stdio/Makefile.inc +++ b/newlib/libc/stdio/Makefile.inc @@ -39,7 +39,6 @@ libc_a_SOURCES += \ %D%/sprint_r.c \ %D%/swprint_r.c \ %D%/ssputs_r.c \ - %D%/ssputws_r.c \ %D%/ssprint_r.c \ %D%/sswprint_r.c endif @@ -99,6 +98,7 @@ libc_a_SOURCES += \ %D%/snprintf.c \ %D%/sprintf.c \ %D%/sscanf.c \ + %D%/ssputws_r.c \ %D%/stdio.c \ %D%/svfiwprintf.c \ %D%/svfiwscanf.c \ -- 2.31.1