public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely@redhat.com>
To: Keith Packard <keithp@keithp.com>
Cc: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH 1/2] libstdc++: Add --enable-pure-stdio-libstdcxx option
Date: Wed, 9 Dec 2020 10:17:00 +0000	[thread overview]
Message-ID: <20201209101700.GS2309743@redhat.com> (raw)
In-Reply-To: <87y2i98ib2.fsf@keithp.com>

[-- Attachment #1: Type: text/plain, Size: 2865 bytes --]

On 07/12/20 12:36 -0800, Keith Packard wrote:
>Jonathan Wakely <jwakely@redhat.com> writes:
>
>> GCC changelog files are autogenerated now, so patches should not touch
>> them. Just include the ChangeLog entry in the Git commit log (which
>> will usually end up being quoted in the patch and/or the email body of
>> the mail to gcc-patches).
>
>Awesome.
>
>> I think the right way to do this (or at least, the way that was
>> intended when basic_file_stdio.cc was added) is to provide a new file
>> and change GLIBCXX_ENABLE_CSTDIO in acinclude.m4 to use that new file.
>>
>> The two biggest downsides of that are that it duplicates a lot of the
>> file (because the diffs for your changes are small) and that the
>> correct name for your new file is already taken!
>
>I can definitely see a reason to use a separate file when implementing
>the basic_file interface on top of something other than stdio, but
>this patch doesn't do that -- it only changes the interaction between
>basic_file and stdio in a few places.
>
>I think it makes the best long-term sense to leave everything in
>basic_file_stdio.cc and avoid having the two implementations diverge in
>the future.
>
>> However, it's rather late in the GCC 11 process to make a change like
>> that (even though it's really just renaming some files). Would you be
>> OK waiting until after GCC 11 is released (in 4-5 months) to do it
>> "properly"? Is this blocking something that would require doing it
>> sooner?
>
>This patch enables the use of C++ with picolibc, a libc designed for 32-
>and 64- bit embedded systems.
>
>Right now, I'm working on getting picolibc support integrated into
>Zephyr, which uses toolchains build by crosstool-ng. I've gotten
>picolibc support merged to crosstool-ng, but the Zephyr developers are
>interested in having a single toolchain support three different libc
>implementations (newlib, newlib-nano and picolibc), but that's blocked
>on having C++ support available in all three libraries.
>
>So, you're at the bottom of my current dependency graph :-)
>
>I don't particularly need this released in gcc, but I would like to
>get patches reviewed and the general approach agreed on so that I can
>feel more confident in preparing patches to be applied to gcc in
>crosstool-ng itself.
>
>Once that's done, I'll also be able to release new Debian packages of
>GCC for embedded ARM and RISC-V and have those include suitable patches
>so that we can support embedded C++ development there too.

OK. In principle, changes to avoid using the POSIX APIs are definitely
fine. I would like to combine your new configure switch with the
existing --enable-cstdio one though.

How about the attached change for acinclude.m4 which would allow you
to do --enable-cstdio=stdio_pure? (It also adds "stdio_posix" as a
more accurate alternative spelling of the current "stdio" option.)




[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 1628 bytes --]

diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index fcd9ea3d23a..535ffd8682f 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -2862,24 +2862,30 @@ AC_DEFUN([GLIBCXX_ENABLE_PARALLEL], [
 
 
 dnl
-dnl Check for which I/O library to use:  stdio, or something specific.
+dnl Check for which I/O library to use:  stdio and POSIX, or pure stdio.
 dnl
-dnl Default is stdio.
+dnl Default is stdio_posix.
 dnl
 AC_DEFUN([GLIBCXX_ENABLE_CSTDIO], [
   AC_MSG_CHECKING([for underlying I/O to use])
   GLIBCXX_ENABLE(cstdio,stdio,[[[=PACKAGE]]],
-    [use target-specific I/O package], [permit stdio])
+    [use target-specific I/O package], [permit stdio|stdio_posix|stdio_pure])
 
-  # Now that libio has been removed, you can have any color you want as long
-  # as it's black.  This is one big no-op until other packages are added, but
-  # showing the framework never hurts.
+  # The only available I/O model is based on stdio, via basic_file_stdio.
+  # The default "stdio" is actually "stdio + POSIX" because it uses fdopen(3)
+  # to get a file descriptor and then uses read(3) and write(3) with it.
+  # The "stdio_pure" model doesn't use fdopen and only uses FILE* for I/O.
   case ${enable_cstdio} in
-    stdio)
+    stdio*)
       CSTDIO_H=config/io/c_io_stdio.h
       BASIC_FILE_H=config/io/basic_file_stdio.h
       BASIC_FILE_CC=config/io/basic_file_stdio.cc
       AC_MSG_RESULT(stdio)
+
+      if test "x$enable_cstdio" = "xstdio_pure" ; then
+	AC_DEFINE(_GLIBCXX_USE_PURE_STDIO, 1,
+		  [Define to restrict std::__basic_file<> to stdio APIs.])
+      fi
       ;;
   esac
 

  reply	other threads:[~2020-12-09 10:17 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-07 18:39 [PATCH 0/2] Support libc with stdio-only I/O in libstdc++ Keith Packard
2020-12-07 18:39 ` [PATCH 1/2] libstdc++: Add --enable-pure-stdio-libstdcxx option Keith Packard
2020-12-07 18:55   ` Jonathan Wakely
2020-12-07 20:36     ` Keith Packard
2020-12-09 10:17       ` Jonathan Wakely [this message]
2020-12-09 16:32         ` Keith Packard
2020-12-09 16:52           ` Jonathan Wakely
2020-12-10  2:46         ` [PATCH 0/2] Support libc with stdio-only I/O in libstdc++ Keith Packard
2020-12-10  2:46           ` [PATCH 1/2] libstdc++: Add --enable-stdio=stdio_pure option [v2] Keith Packard
2020-12-10 20:23             ` Jonathan Wakely
2020-12-10 20:56               ` Keith Packard
2020-12-15 18:43                 ` Jonathan Wakely
2020-12-10  2:46           ` [PATCH 2/2] Regenerate libstdc++-v3 autoconf files Keith Packard
2020-12-07 18:39 ` Keith Packard

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=20201209101700.GS2309743@redhat.com \
    --to=jwakely@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=keithp@keithp.com \
    --cc=libstdc++@gcc.gnu.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).