libc/stdio: Remove wchar_t functions from NEWLIB_NANO_FORMATTED_IO

Message ID 20240223153111.3265858-1-torbjorn.svensson@foss.st.com
State New
Headers
Series libc/stdio: Remove wchar_t functions from NEWLIB_NANO_FORMATTED_IO |

Commit Message

Torbjorn SVENSSON Feb. 23, 2024, 3:31 p.m. UTC
  When I regtested this, I used the official Ubuntu 20.04 package of
automake 1.15. When generating the Makefile.in, I do see a few entries
that I did not expect, so therfore I would like someone with the right
versions to generate the Makefile.in and submit this for me.

The alternative approach to this patch is to figure out what functions
(in addition to __ssputws_r) that is also needed in nano formatted io.

--

Regression tested in basepoints/gcc-14-9032-g945cb8490cb with arm-none-eabi.

Example failure without this change:
$ arm-none-eabi-g++ .../pr100611.C -std=c++20 --specs=nosys.specs -o /dev/null --specs=nano.specs
.../ld: .../libc_nano.a(libc_a-svfwprintf.o): in function `_svfwprintf_r':
(.text._svfwprintf_r+0xd8): undefined reference to `__ssputws_r'
.../ld: (.text._svfwprintf_r+0x834): undefined reference to `__ssputws_r'
.../ld: (.text._svfwprintf_r+0x85c): undefined reference to `__ssputws_r'
.../ld: (.text._svfwprintf_r+0x8a8): undefined reference to `__ssputws_r'
.../ld: (.text._svfwprintf_r+0x8dc): undefined reference to `__ssputws_r'
.../ld: .../libc_nano.a(libc_a-svfwprintf.o):(.text._svfwprintf_r+0x900): more undefined references to `__ssputws_r' follow
collect2: error: ld returned 1 exit status

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
Co-authored-by: Yvan ROUX <yvan.roux@foss.st.com>
---
 newlib/libc/stdio/Makefile.inc | 52 +++++++++++++++++-----------------
 1 file changed, 26 insertions(+), 26 deletions(-)
  

Comments

R. Diez Feb. 23, 2024, 4:05 p.m. UTC | #1
> When I regtested this, I used the official Ubuntu 20.04 package of
> automake 1.15. When generating the Makefile.in, I do see a few entries
> that I did not expect, so therfore I would like someone with the right
> versions to generate the Makefile.in and submit this for me.
> [...]

In case you need different Autotools releases often, building your own Autotools set is not hard, and I have written a script which automatically downloads and builds the desired versions:

https://github.com/rdiez/Tools/tree/master/Autotools

Regards,
   rdiez
  

Patch

diff --git a/newlib/libc/stdio/Makefile.inc b/newlib/libc/stdio/Makefile.inc
index e25680212..ce298e5cb 100644
--- a/newlib/libc/stdio/Makefile.inc
+++ b/newlib/libc/stdio/Makefile.inc
@@ -41,7 +41,14 @@  libc_a_SOURCES += \
 	%D%/ssputs_r.c \
 	%D%/ssputws_r.c \
 	%D%/ssprint_r.c \
-	%D%/sswprint_r.c
+	%D%/sswprint_r.c \
+	%D%/svfiwprintf.c \
+	%D%/svfiwscanf.c \
+	%D%/svfwprintf.c \
+	%D%/svfwscanf.c \
+	%D%/vfiwprintf.c \
+	%D%/vfiwscanf.c \
+	%D%/vfwscanf.c
 endif
 
 libc_a_SOURCES += \
@@ -100,17 +107,10 @@  libc_a_SOURCES += \
 	%D%/sprintf.c \
 	%D%/sscanf.c \
 	%D%/stdio.c \
-	%D%/svfiwprintf.c \
-	%D%/svfiwscanf.c \
-	%D%/svfwprintf.c \
-	%D%/svfwscanf.c \
 	%D%/tmpfile.c \
 	%D%/tmpnam.c \
 	%D%/ungetc.c \
 	%D%/vdprintf.c \
-	%D%/vfiwprintf.c \
-	%D%/vfiwscanf.c \
-	%D%/vfwscanf.c \
 	%D%/vprintf.c \
 	%D%/vscanf.c \
 	%D%/vsnprintf.c \
@@ -127,13 +127,13 @@  if !ELIX_LEVEL_1
 	%D%/fcloseall.c \
 	%D%/fseeko.c \
 	%D%/ftello.c \
-	%D%/getw.c \
 	%D%/mktemp.c \
-	%D%/putw.c \
 	%D%/vasprintf.c
 if !NEWLIB_NANO_FORMATTED_IO
 %C%_ELIX_2_SOURCES += \
 	%D%/asiprintf.c \
+	%D%/getw.c \
+	%D%/putw.c \
 	%D%/vasiprintf.c
 endif !NEWLIB_NANO_FORMATTED_IO
 endif !ELIX_LEVEL_1
@@ -157,52 +157,52 @@  else
 	%D%/fflush_u.c \
 	%D%/fgetc_u.c \
 	%D%/fgets_u.c \
-	%D%/fgetwc.c \
-	%D%/fgetwc_u.c \
-	%D%/fgetws.c \
-	%D%/fgetws_u.c \
 	%D%/fileno_u.c \
 	%D%/fmemopen.c \
 	%D%/fopencookie.c \
 	%D%/fpurge.c \
 	%D%/fputc_u.c \
 	%D%/fputs_u.c \
+	%D%/fread_u.c \
+	%D%/fsetlocking.c \
+	%D%/funopen.c \
+	%D%/fwrite_u.c \
+	%D%/open_memstream.c \
+	%D%/stdio_ext.c \
+	%D%/vasnprintf.c
+if !NEWLIB_NANO_FORMATTED_IO
+%C%_ELIX_4_SOURCES += \
+	%D%/asniprintf.c \
+	%D%/diprintf.c \
+	%D%/fgetwc.c \
+	%D%/fgetwc_u.c \
+	%D%/fgetws.c \
+	%D%/fgetws_u.c \
 	%D%/fputwc.c \
 	%D%/fputwc_u.c \
 	%D%/fputws.c \
 	%D%/fputws_u.c \
-	%D%/fread_u.c \
-	%D%/fsetlocking.c \
-	%D%/funopen.c \
 	%D%/fwide.c \
 	%D%/fwprintf.c \
-	%D%/fwrite_u.c \
 	%D%/fwscanf.c \
 	%D%/getwc.c \
 	%D%/getwc_u.c \
 	%D%/getwchar.c \
 	%D%/getwchar_u.c \
-	%D%/open_memstream.c \
 	%D%/putwc.c \
 	%D%/putwc_u.c \
 	%D%/putwchar.c \
 	%D%/putwchar_u.c \
-	%D%/stdio_ext.c \
 	%D%/swprintf.c \
 	%D%/swscanf.c \
 	%D%/ungetwc.c \
-	%D%/vasnprintf.c \
+	%D%/vasniprintf.c \
 	%D%/vswprintf.c \
 	%D%/vswscanf.c \
 	%D%/vwprintf.c \
 	%D%/vwscanf.c \
 	%D%/wprintf.c \
 	%D%/wscanf.c
-if !NEWLIB_NANO_FORMATTED_IO
-%C%_ELIX_4_SOURCES += \
-	%D%/asniprintf.c \
-	%D%/diprintf.c \
-	%D%/vasniprintf.c
 endif !NEWLIB_NANO_FORMATTED_IO
 endif !ELIX_LEVEL_3
 endif !ELIX_LEVEL_2