[PATCH 0/2] fix undefined reference to `__ssputws_r'
Hau Hsu
hau.hsu@sifive.com
Mon Jul 8 04:01:55 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/ed0b48da6c6c4beaacd9fad63efaddc0@syntacore.com/t/
Hau Hsu (2):
Revert "libc/stdio: Remove wchar_t functions from
NEWLIB_NANO_FORMATTED_IO"
libc/stdio: fix undefined reference to `__ssputws_r'
newlib/Makefile.in | 1004 ++++++++++++++++----------------
newlib/libc/stdio/Makefile.inc | 54 +-
2 files changed, 528 insertions(+), 530 deletions(-)
--
2.31.1
More information about the Newlib
mailing list