]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Document P1642 and extensions
authorArsen Arsenović <arsen@aarsen.me>
Mon, 23 Jan 2023 12:41:45 +0000 (13:41 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Mon, 6 Feb 2023 20:46:52 +0000 (20:46 +0000)
libstdc++-v3/ChangeLog:

* doc/xml/manual/using.xml: Document newly-freestanding
headers and the effect of the -ffreestanding flag.
* doc/xml/manual/status_cxx2023.xml: Document P1642R11 as
completed.
* doc/xml/manual/configure.xml: Document that hosted installs
respect __STDC_HOSTED__.
* doc/xml/manual/test.xml: Document how to run tests in
freestanding mode.
* doc/html/*: Regenerate.

13 files changed:
libstdc++-v3/doc/html/index.html
libstdc++-v3/doc/html/manual/configure.html
libstdc++-v3/doc/html/manual/documentation_hacking.html
libstdc++-v3/doc/html/manual/memory.html
libstdc++-v3/doc/html/manual/policy_data_structures.html
libstdc++-v3/doc/html/manual/status.html
libstdc++-v3/doc/html/manual/test.html
libstdc++-v3/doc/html/manual/using.html
libstdc++-v3/doc/html/manual/using_dynamic_or_shared.html
libstdc++-v3/doc/xml/manual/configure.xml
libstdc++-v3/doc/xml/manual/status_cxx2023.xml
libstdc++-v3/doc/xml/manual/test.xml
libstdc++-v3/doc/xml/manual/using.xml

index ce951e6cc8e4a8e715bc7bad7e56bdb890945fa0..ed7021bd4610c2c3c35b35bd4a667d1e1c090149 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>The GNU C++ Library</title><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><meta name="description" content="Short Contents Copyright (C) 2008-2022 FSF Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. This is the top level of the libstdc++ documentation set. The documentation is divided into the following three sections. Manual Frequently Asked Questions API and Source Documentation" /><meta name="keywords" content="ISO C++, runtime, library" /><link rel="home" href="index.html" title="The GNU C++ Library" /><link rel="next" href="manual/index.html" title="The GNU C++ Library Manual" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">The GNU C++ Library</th></tr><tr><td width="20%" align="left"> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="manual/index.html">Next</a></td></tr></table><hr /></div><div class="set" lang="en" xml:lang="en"><div class="titlepage"><div><div><h1 class="title"><a id="set-index"></a>The GNU C++ Library</h1></div><div><div class="abstract"><a id="contents"></a><p class="title"><strong>Short Contents</strong></p><p>
-      Copyright (C) 2008-2022
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>The GNU C++ Library</title><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><meta name="description" content="Short Contents Copyright (C) 2008-2023 FSF Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. This is the top level of the libstdc++ documentation set. The documentation is divided into the following three sections. Manual Frequently Asked Questions API and Source Documentation" /><meta name="keywords" content="ISO C++, runtime, library" /><link rel="home" href="index.html" title="The GNU C++ Library" /><link rel="next" href="manual/index.html" title="The GNU C++ Library Manual" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">The GNU C++ Library</th></tr><tr><td width="20%" align="left"> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="manual/index.html">Next</a></td></tr></table><hr /></div><div class="set" lang="en" xml:lang="en"><div class="titlepage"><div><div><h1 class="title"><a id="set-index"></a>The GNU C++ Library</h1></div><div><div class="abstract"><a id="contents"></a><p class="title"><strong>Short Contents</strong></p><p>
+      Copyright (C) 2008-2023
       <a class="link" href="https://www.fsf.org" target="_top">FSF
       </a>
     </p><p>
index 9c5c2d9f17081b3ad7879d1efcc4d11a8d38b92d..dd9e6ef3579d2f663564448821145a71e41cee39 100644 (file)
      built.  The C++ Standard also describes a
      <span class="emphasis"><em>freestanding</em></span> environment, in which only a
      minimal set of headers are provided.  This option builds such an
-     environment.
+     environment.  Note that a hosted library installs headers that still can
+     be used in non hosted environments, as the library checks for
+     <code class="code">__STDC_HOSTED__</code>, however, a library configured with
+     <code class="code">--disable-hosted-libstdcxx</code> will not install unusable headers.
      </p></dd><dt><span class="term"><code class="code">--disable-libstdcxx-hosted</code></span></dt><dd><p>This is an alias for <code class="code">--disable-hosted-libstdcxx</code>.</p></dd><dt><span class="term"><code class="code">--disable-libstdcxx-verbose</code></span></dt><dd><p>
      By default, the library is configured to write descriptive messages
      to standard error for certain events such as calling a pure virtual
index 7766f133bea0e4ea06a677d413c36a1f82d23ac8..24df9bd9481d93ec8cc5d1cf93bc69f83083511c 100644 (file)
@@ -560,4 +560,4 @@ make <code class="literal">XSL_STYLE_DIR="/usr/share/xml/docbook/stylesheet/nwal
       </td></tr></tbody></table></div></div><br class="table-break" /></div></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="appendix_porting.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="appendix_porting.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="internals.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Appendix B. 
   Porting and Maintenance
   
- </td><td width="20%" align="center"><a accesskey="h" href="../index.html">Home</a></td><td width="40%" align="right" valign="top"> Porting to New Hardware or Operating Systems</td></tr></table></div></body></html>
+ </td><td width="20%" align="center"><a accesskey="h" href="../index.html">Home</a></td><td width="40%" align="right" valign="top"> Porting to New Hardware or Operating Systems</td></tr></table></div></body></html>
\ No newline at end of file
index a70613e8fd64e28badcff35c45e6cf85838cf74d..08ad2fd4dd8f399b4a4b111f6590ce67d13fa1d9 100644 (file)
@@ -644,4 +644,4 @@ be private.
        </a>
       </em>. </span><span class="subtitle">
       N2461
-    . </span></p></div></div></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="pairs.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="utilities.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="traits.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Pairs </td><td width="20%" align="center"><a accesskey="h" href="../index.html">Home</a></td><td width="40%" align="right" valign="top"> Traits</td></tr></table></div></body></html>
+    . </span></p></div></div></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="pairs.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="utilities.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="traits.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Pairs </td><td width="20%" align="center"><a accesskey="h" href="../index.html">Home</a></td><td width="40%" align="right" valign="top"> Traits</td></tr></table></div></body></html>
\ No newline at end of file
index ef54da8053a43abc8aebf5fa0af1a23eddbae5af..90345550012920232cd2641ec5d654b347da39f4 100644 (file)
            Wickland
          </span>. </span><span class="publisher"><span class="publishername">
          National Psychological Institute
-       . </span></span></p></div></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="bitmap_allocator_impl.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="extensions.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="policy_data_structures_using.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Implementation </td><td width="20%" align="center"><a accesskey="h" href="../index.html">Home</a></td><td width="40%" align="right" valign="top"> Using</td></tr></table></div></body></html>
+       . </span></span></p></div></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="bitmap_allocator_impl.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="extensions.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="policy_data_structures_using.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Implementation </td><td width="20%" align="center"><a accesskey="h" href="../index.html">Home</a></td><td width="40%" align="right" valign="top"> Using</td></tr></table></div></body></html>
\ No newline at end of file
index 47bb078141741c99293ae59bb40a953ff8fef514..c99d51ff709cf6e45a650f2188bec659236a7aaa 100644 (file)
@@ -1916,7 +1916,11 @@ or any notes about the implementation.
         <a class="link" href="https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2186r2.html" target="_top">
         P2186R2
         </a>
-      </td><td align="center"> 12.1 </td><td align="left"> </td></tr></tbody></table></div></div><br class="table-break" /></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="status.iso.tr1"></a>C++ TR1</h3></div></div></div><p>
+      </td><td align="center"> 12.1 </td><td align="left"> </td></tr><tr><td align="left"> Easy [utilities], [ranges], and [iterators] </td><td align="left">
+        <a class="link" href="https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p1642r11.html" target="_top">
+        P1642R11
+        </a>
+      </td><td align="center"> 13.1 </td><td align="left"> </td></tr></tbody></table></div></div><br class="table-break" /></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="status.iso.tr1"></a>C++ TR1</h3></div></div></div><p>
 This table is based on the table of contents of ISO/IEC DTR 19768,
 Doc No: N1836=05-0096, Date: 2005-06-24,
 "Draft Technical Report on C++ Library Extensions".
index 10ae4ed5e1b34e14d0da1dde7a505975d2c8d9da..fadadf249bb35020c38b4338ba4600782e34075c 100644 (file)
@@ -203,6 +203,18 @@ cat 27_io/objects/char/3_xin.in | a.out</pre></dd><dt><span class="term"><code c
  </p><pre class="programlisting">
     make check-target-libstdc++-v3 RUNTESTFLAGS='--target_board \"unix{-mabi=32,,-mabi=64}\"'
 </pre><p>
+    </p><p>
+      If you wish to run the testsuite in a freestanding configuration, you can
+      pass the <code class="code">-ffreestanding</code> flag.  Doing so will run the tests
+      that do not require hosted features, and emit a
+      <code class="literal">UNSUPPORTED</code> for those that do.  To run tests in the
+      freestanding configuration, you still need to build for a target you can
+      run programs on, e.g. <code class="code">x86_64-pc-linux-gnu</code>, as a few tests
+      still execute the code they build.  Here's an example of how to run the
+      testsuite with libstdc++ in freestanding mode:
+      </p><pre class="programlisting">
+    make check-target-libstdc++-v3 RUNTESTFLAGS='--target_board=unix/-ffreestanding'
+      </pre><p>
     </p><p>
       You can run the tests with a compiler and library that have
       already been installed.  Make sure that the compiler (e.g.,
index f2dc2078759aeaffdc16804641a04057758ddcbf..f23325ebe9747acaa218a1485158e99ce74e38ca 100644 (file)
       </td></tr><tr><td align="left"><code class="literal">-fopenmp</code></td><td align="left">For <a class="link" href="parallel_mode.html" title="Chapter 18. Parallel Mode">parallel</a> mode.</td></tr><tr><td align="left"><code class="literal">-ltbb</code></td><td align="left">Linking to tbb (Thread Building Blocks) is required for use of the
         Parallel Standard Algorithms and execution policies in
         <code class="filename">&lt;execution&gt;</code>.
+      </td></tr><tr><td align="left"><code class="literal">-ffreestanding</code></td><td align="left">
+       Limits the library to its freestanding subset.  Headers that are
+       not supported in freestanding will emit a "This header is not available
+       in freestanding mode" error.
+       Headers that are in the freestanding subset partially will not expose
+       functionality that is not part of the freestanding subset.
       </td></tr></tbody></table></div></div><br class="table-break" /></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="make.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="intro.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="using_headers.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Make </td><td width="20%" align="center"><a accesskey="h" href="../index.html">Home</a></td><td width="40%" align="right" valign="top"> Headers</td></tr></table></div></body></html>
\ No newline at end of file
index 3c9e5fa54b03efdee2d84dca6bb2b5455a3dad42..73d1f18485fae120e043218bd13d10cfba4afe6a 100644 (file)
          <code class="filename">initializer_list</code>
          </p></li><li class="listitem"><p>
          <code class="filename">type_traits</code>
-         </p></li></ul></div><p> There exists a library that offers runtime support for
-       just these headers, and it is called
-       <code class="filename">libsupc++.a</code>. To use it, compile with <span class="command"><strong>gcc</strong></span> instead of <span class="command"><strong>g++</strong></span>, like so:
+         </p></li></ul></div><p>
+       As of GCC 13, libstdc++ implements P1642, which brings in many more
+       headers, as well a quite a few ones not covered by the paper.
+
+       In general, if a feature does not require traditionally libc-provided
+       facilities, or dynamic memory allocation, it's enabled in the
+       freestanding subset.  In addition, if only a subset of a header
+       requires such features, it is partially included.  Some examples
+       include:
+      </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
+         <code class="filename">string_view</code>
+         </p></li><li class="listitem"><p>
+         <code class="filename">tuple</code>
+         </p></li><li class="listitem"><p>
+         <code class="filename">bitset</code>
+         </p></li></ul></div><p>
+       Currently, this subset includes all of the iterator APIs (including the
+       ranges APIs) that do not involve streams, the entire C++ algorithms
+       library, excluding parallel algorithms, and a large part of the
+       utilities library.  This is on top of the headers included in the lists
+       above.
+      </p><p>
+       If you're using a libstdc++ configured for hosted environments, and
+       would like to not involve the libraries libstdc++ would depend on in
+       your programs, you will need to use <span class="command"><strong>gcc</strong></span> to link your
+       application with only <code class="filename">libsupc++.a</code>,
+       like so:
       </p><p>
-       <span class="command"><strong>gcc foo.cc -lsupc++</strong></span>
+       <span class="command"><strong>gcc -ffreestanding foo.cc -lsupc++</strong></span>
       </p><p>
-       No attempt is made to verify that only the minimal subset
-       identified above is actually used at compile time. Violations
-       are diagnosed as undefined symbols at link time.
+       If you configured libstdc++ with
+       <code class="code">--disable-hosted-libstdcxx</code>, however, you can use the
+       normal <span class="command"><strong>g++</strong></span> command to link, as this configuration
+       provides a (nearly) empty <code class="filename">libstdc++.a</code>.
       </p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="manual.intro.using.linkage.dynamic"></a>Finding Dynamic or Shared Libraries</h3></div></div></div><p>
       If the only library built is the static library
       (<code class="filename">libstdc++.a</code>), or if
index 8b3b8cab8c716c514fadd60be3a1c8261c23945f..7ff07aea8864ed309fd8e3b0a95da19461277b0e 100644 (file)
      built.  The C++ Standard also describes a
      <emphasis>freestanding</emphasis> environment, in which only a
      minimal set of headers are provided.  This option builds such an
-     environment.
+     environment.  Note that a hosted library installs headers that still can
+     be used in non hosted environments, as the library checks for
+     <code>__STDC_HOSTED__</code>, however, a library configured with
+     <code>--disable-hosted-libstdcxx</code> will not install unusable headers.
      </para>
  </listitem></varlistentry>
 
index 365df505f54cf0c4d5415cb9072cb7527b8ee313..f23c64d6a29effdbcb8a87208de74b0c45147312 100644 (file)
@@ -566,6 +566,17 @@ or any notes about the implementation.
       <entry />
     </row>
 
+    <row>
+      <entry> Easy [utilities], [ranges], and [iterators] </entry>
+      <entry>
+        <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p1642r11.html">
+        P1642R11
+        </link>
+      </entry>
+      <entry align="center"> 13.1 </entry>
+      <entry />
+    </row>
+
   </tbody>
 </tgroup>
 </table>
index 7bc6e3397230d97b1d8d63c9072074290e2e9a93..964c53d263226829e3f40a53c9995400320d7f82 100644 (file)
@@ -350,6 +350,20 @@ cat 27_io/objects/char/3_xin.in | a.out</programlisting>
 </programlisting>
     </para>
 
+    <para>
+      If you wish to run the testsuite in a freestanding configuration, you can
+      pass the <code>-ffreestanding</code> flag.  Doing so will run the tests
+      that do not require hosted features, and emit a
+      <literal>UNSUPPORTED</literal> for those that do.  To run tests in the
+      freestanding configuration, you still need to build for a target you can
+      run programs on, e.g. <code>x86_64-pc-linux-gnu</code>, as a few tests
+      still execute the code they build.  Here's an example of how to run the
+      testsuite with libstdc++ in freestanding mode:
+      <programlisting>
+    make check-target-libstdc++-v3 RUNTESTFLAGS='--target_board=unix/-ffreestanding'
+      </programlisting>
+    </para>
+
     <para>
       You can run the tests with a compiler and library that have
       already been installed.  Make sure that the compiler (e.g.,
index 9c444dd2997aba4b1009e9e47d01779c6a12c407..7f011a6d9316a4c4ee7aa68e858777ffcec63dc4 100644 (file)
       </entry>
     </row>
 
+    <row>
+      <entry><literal>-ffreestanding</literal></entry>
+      <entry>
+       Limits the library to its freestanding subset.  Headers that are
+       not supported in freestanding will emit a "This header is not available
+       in freestanding mode" error.
+       Headers that are in the freestanding subset partially will not expose
+       functionality that is not part of the freestanding subset.
+      </entry>
+    </row>
+
   </tbody>
 
 </tgroup>
@@ -1523,19 +1534,60 @@ namespace gtk
        </listitem>
       </itemizedlist>
 
-      <para> There exists a library that offers runtime support for
-       just these headers, and it is called
-       <filename class="libraryfile">libsupc++.a</filename>. To use it, compile with <command>gcc</command> instead of <command>g++</command>, like so:
+      <para>
+       As of GCC 13, libstdc++ implements P1642, which brings in many more
+       headers, as well a quite a few ones not covered by the paper.
+
+       In general, if a feature does not require traditionally libc-provided
+       facilities, or dynamic memory allocation, it's enabled in the
+       freestanding subset.  In addition, if only a subset of a header
+       requires such features, it is partially included.  Some examples
+       include:
+      </para>
+
+      <itemizedlist>
+       <listitem>
+         <para>
+         <filename class="headerfile">string_view</filename>
+         </para>
+       </listitem>
+       <listitem>
+         <para>
+         <filename class="headerfile">tuple</filename>
+         </para>
+       </listitem>
+       <listitem>
+         <para>
+         <filename class="headerfile">bitset</filename>
+         </para>
+       </listitem>
+      </itemizedlist>
+
+      <para>
+       Currently, this subset includes all of the iterator APIs (including the
+       ranges APIs) that do not involve streams, the entire C++ algorithms
+       library, excluding parallel algorithms, and a large part of the
+       utilities library.  This is on top of the headers included in the lists
+       above.
+      </para>
+
+      <para>
+       If you're using a libstdc++ configured for hosted environments, and
+       would like to not involve the libraries libstdc++ would depend on in
+       your programs, you will need to use <command>gcc</command> to link your
+       application with only <filename class="libraryfile">libsupc++.a</filename>,
+       like so:
       </para>
 
       <para>
-       <command>gcc foo.cc -lsupc++</command>
+       <command>gcc -ffreestanding foo.cc -lsupc++</command>
       </para>
 
       <para>
-       No attempt is made to verify that only the minimal subset
-       identified above is actually used at compile time. Violations
-       are diagnosed as undefined symbols at link time.
+       If you configured libstdc++ with
+       <code>--disable-hosted-libstdcxx</code>, however, you can use the
+       normal <command>g++</command> command to link, as this configuration
+       provides a (nearly) empty <filename class="libraryfile">libstdc++.a</filename>.
       </para>
     </section>