* Newlib: nano-formatted-io and libstdc++ compatibility
@ 2024-05-24 13:48 Mark Goncharov
0 siblings, 0 replies; only message in thread
From: Mark Goncharov @ 2024-05-24 13:48 UTC (permalink / raw)
To: newlib
[-- Attachment #1: Type: text/plain, Size: 2161 bytes --]
Hello.
My name is Mark.
My problem has appeared on RISC-V target, but seems to be the same for every target.
To reproduce the bug:
#include <iostream>
int main() { std::cout << "Hello world"; }
Compile: riscv64-unknown-elf-g++ --specs=nano.specs a.cpp
Have different outputs with gcc-13.2 that was built with newlib-nano and --enable-newlib-nano-formatted-io option as in https://github.com/riscv-collab/riscv-gnu-toolchain do:
1) newlib-4.3
Works good
2) newlib-4.4 without patch - https://cygwin.com/git/?p=newlib-cygwin.git;a=commit;h=61ccd3f94f92bcfc0940f0595ea5b3b72bce3c6d
Also works good
3) newlib-4.4
Fail with error
libc_nano.a(libc_a-svfwprintf.o): in function `_svfwprintf_r':
(.text._svfwprintf_r+0x7a): undefined reference to `__ssputws_r'
4) newlib-4.4 + fix regression for arm https://cygwin.com/git/?p=newlib-cygwin.git;a=commitdiff;h=3b97a5ec67a5a52c130158bb143949cd842de305
Fail with error
in function `__gnu_cxx::stdio_sync_filebuf<wchar_t, std::char_traits<wchar_t> >::uflow()':
(.text._ZN9__gnu_cxx18stdio_sync_filebufIwSt11char_traitsIwEE5uflowEv[_ZN9__gnu_cxx18stdio_sync_filebufIwSt11char_traitsIwEE5uflowEv]+0xa): undefined reference to `getwc
... // same for putwc, ungetwc and swprintf
The first patch changes newlib/libc/stdio/vfwprintf.c file and defines __ssputws_r instead of __ssputs_r. Of course, it fails, because nano-formatted-io doesn't implement this function (see newlib/libc/stdio/Makefile.inc for NEWLIB_NANO_FORMATTED_IO case)
The second patch removes every wide-char usage for nano_formatted_io, so, the simplest "Hello world" can't be compiled with newlib-nano, because libstdc++ links even with unused symbols.
----------------------------------------------------------------
Finally, I have a question.
In newlib/README:
--enable-newlib-nano-formatted-io
This option does not affect wide-char formatted I/O functions
But current implementation affect wide-char formatted I/O. We really want to broke compatibility with nano-formatted-io and libstdc++?
I propose, we need to get back wide-char support for nano-formatted-io.
With best regards,
Mark
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-05-24 13:48 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-24 13:48 Newlib: nano-formatted-io and libstdc++ compatibility Mark Goncharov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).