From: Mark Goncharov <mark.goncharov@syntacore.com>
To: "newlib@sourceware.org" <newlib@sourceware.org>
Subject: Newlib: nano-formatted-io and libstdc++ compatibility
Date: Fri, 24 May 2024 13:48:35 +0000 [thread overview]
Message-ID: <ed0b48da6c6c4beaacd9fad63efaddc0@syntacore.com> (raw)
[-- 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
reply other threads:[~2024-05-24 13:48 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ed0b48da6c6c4beaacd9fad63efaddc0@syntacore.com \
--to=mark.goncharov@syntacore.com \
--cc=newlib@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).