From 9f4baed6ac02f721f1adee043c4aa920dd5075b7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Arsen=20Arsenovi=C4=87?= Date: Mon, 23 Jan 2023 13:41:45 +0100 Subject: [PATCH] libstdc++: Document P1642 and extensions 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. --- libstdc++-v3/doc/html/index.html | 4 +- libstdc++-v3/doc/html/manual/configure.html | 5 +- .../doc/html/manual/documentation_hacking.html | 2 +- libstdc++-v3/doc/html/manual/memory.html | 2 +- .../doc/html/manual/policy_data_structures.html | 2 +- libstdc++-v3/doc/html/manual/status.html | 6 +- libstdc++-v3/doc/html/manual/test.html | 12 ++++ libstdc++-v3/doc/html/manual/using.html | 6 ++ .../doc/html/manual/using_dynamic_or_shared.html | 39 ++++++++++--- libstdc++-v3/doc/xml/manual/configure.xml | 5 +- libstdc++-v3/doc/xml/manual/status_cxx2023.xml | 11 ++++ libstdc++-v3/doc/xml/manual/test.xml | 14 +++++ libstdc++-v3/doc/xml/manual/using.xml | 66 +++++++++++++++++++--- 13 files changed, 152 insertions(+), 22 deletions(-) diff --git a/libstdc++-v3/doc/html/index.html b/libstdc++-v3/doc/html/index.html index ce951e6..ed7021b 100644 --- a/libstdc++-v3/doc/html/index.html +++ b/libstdc++-v3/doc/html/index.html @@ -1,6 +1,6 @@ -The GNU C++ Library

The GNU C++ Library

Short Contents

- Copyright (C) 2008-2022 +The GNU C++ Library

The GNU C++ Library

Short Contents

+ Copyright (C) 2008-2023 FSF

diff --git a/libstdc++-v3/doc/html/manual/configure.html b/libstdc++-v3/doc/html/manual/configure.html index 9c5c2d9..dd9e6ef 100644 --- a/libstdc++-v3/doc/html/manual/configure.html +++ b/libstdc++-v3/doc/html/manual/configure.html @@ -219,7 +219,10 @@ built. The C++ Standard also describes a freestanding 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 + __STDC_HOSTED__, however, a library configured with + --disable-hosted-libstdcxx will not install unusable headers.

--disable-libstdcxx-hosted

This is an alias for --disable-hosted-libstdcxx.

--disable-libstdcxx-verbose

By default, the library is configured to write descriptive messages to standard error for certain events such as calling a pure virtual diff --git a/libstdc++-v3/doc/html/manual/documentation_hacking.html b/libstdc++-v3/doc/html/manual/documentation_hacking.html index 7766f13..24df9bd 100644 --- a/libstdc++-v3/doc/html/manual/documentation_hacking.html +++ b/libstdc++-v3/doc/html/manual/documentation_hacking.html @@ -560,4 +560,4 @@ make XSL_STYLE_DIR="/usr/share/xml/docbook/stylesheet/nwal


+ Home Porting to New Hardware or Operating Systems
\ No newline at end of file diff --git a/libstdc++-v3/doc/html/manual/memory.html b/libstdc++-v3/doc/html/manual/memory.html index a70613e..08ad2fd 100644 --- a/libstdc++-v3/doc/html/manual/memory.html +++ b/libstdc++-v3/doc/html/manual/memory.html @@ -644,4 +644,4 @@ be private. . N2461 - .

+ .

\ No newline at end of file diff --git a/libstdc++-v3/doc/html/manual/policy_data_structures.html b/libstdc++-v3/doc/html/manual/policy_data_structures.html index ef54da8..9034555 100644 --- a/libstdc++-v3/doc/html/manual/policy_data_structures.html +++ b/libstdc++-v3/doc/html/manual/policy_data_structures.html @@ -1297,4 +1297,4 @@ Wickland . National Psychological Institute - .

+ .

\ No newline at end of file diff --git a/libstdc++-v3/doc/html/manual/status.html b/libstdc++-v3/doc/html/manual/status.html index 47bb078..c99d51f 100644 --- a/libstdc++-v3/doc/html/manual/status.html +++ b/libstdc++-v3/doc/html/manual/status.html @@ -1916,7 +1916,11 @@ or any notes about the implementation. P2186R2 - 12.1  

C++ TR1

+ 12.1   Easy [utilities], [ranges], and [iterators] + + P1642R11 + + 13.1  


C++ TR1

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". diff --git a/libstdc++-v3/doc/html/manual/test.html b/libstdc++-v3/doc/html/manual/test.html index 10ae4ed..fadadf2 100644 --- a/libstdc++-v3/doc/html/manual/test.html +++ b/libstdc++-v3/doc/html/manual/test.html @@ -204,6 +204,18 @@ cat 27_io/objects/char/3_xin.in | a.out

+ If you wish to run the testsuite in a freestanding configuration, you can + pass the -ffreestanding flag. Doing so will run the tests + that do not require hosted features, and emit a + UNSUPPORTED 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. x86_64-pc-linux-gnu, 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: +

+    make check-target-libstdc++-v3 RUNTESTFLAGS='--target_board=unix/-ffreestanding'
+      

+

You can run the tests with a compiler and library that have already been installed. Make sure that the compiler (e.g., g++) is in your PATH. If you are diff --git a/libstdc++-v3/doc/html/manual/using.html b/libstdc++-v3/doc/html/manual/using.html index f2dc207..f23325e 100644 --- a/libstdc++-v3/doc/html/manual/using.html +++ b/libstdc++-v3/doc/html/manual/using.html @@ -40,4 +40,10 @@ -fopenmpFor parallel mode.-ltbbLinking to tbb (Thread Building Blocks) is required for use of the Parallel Standard Algorithms and execution policies in <execution>. + -ffreestanding + 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.


\ No newline at end of file diff --git a/libstdc++-v3/doc/html/manual/using_dynamic_or_shared.html b/libstdc++-v3/doc/html/manual/using_dynamic_or_shared.html index 3c9e5fa..73d1f18 100644 --- a/libstdc++-v3/doc/html/manual/using_dynamic_or_shared.html +++ b/libstdc++-v3/doc/html/manual/using_dynamic_or_shared.html @@ -30,15 +30,40 @@ initializer_list

  • type_traits -

  • There exists a library that offers runtime support for - just these headers, and it is called - libsupc++.a. To use it, compile with gcc instead of g++, like so: +

    + 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: +

    • + string_view +

    • + tuple +

    • + bitset +

    + 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. +

    + 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 gcc to link your + application with only libsupc++.a, + like so:

    - gcc foo.cc -lsupc++ + gcc -ffreestanding foo.cc -lsupc++

    - 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 + --disable-hosted-libstdcxx, however, you can use the + normal g++ command to link, as this configuration + provides a (nearly) empty libstdc++.a.

    Finding Dynamic or Shared Libraries

    If the only library built is the static library (libstdc++.a), or if diff --git a/libstdc++-v3/doc/xml/manual/configure.xml b/libstdc++-v3/doc/xml/manual/configure.xml index 8b3b8ca..7ff07ae 100644 --- a/libstdc++-v3/doc/xml/manual/configure.xml +++ b/libstdc++-v3/doc/xml/manual/configure.xml @@ -362,7 +362,10 @@ built. The C++ Standard also describes a freestanding 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 + __STDC_HOSTED__, however, a library configured with + --disable-hosted-libstdcxx will not install unusable headers. diff --git a/libstdc++-v3/doc/xml/manual/status_cxx2023.xml b/libstdc++-v3/doc/xml/manual/status_cxx2023.xml index 365df50..f23c64d 100644 --- a/libstdc++-v3/doc/xml/manual/status_cxx2023.xml +++ b/libstdc++-v3/doc/xml/manual/status_cxx2023.xml @@ -566,6 +566,17 @@ or any notes about the implementation. + + Easy [utilities], [ranges], and [iterators] + + + P1642R11 + + + 13.1 + + + diff --git a/libstdc++-v3/doc/xml/manual/test.xml b/libstdc++-v3/doc/xml/manual/test.xml index 7bc6e33..964c53d 100644 --- a/libstdc++-v3/doc/xml/manual/test.xml +++ b/libstdc++-v3/doc/xml/manual/test.xml @@ -351,6 +351,20 @@ cat 27_io/objects/char/3_xin.in | a.out + If you wish to run the testsuite in a freestanding configuration, you can + pass the -ffreestanding flag. Doing so will run the tests + that do not require hosted features, and emit a + UNSUPPORTED 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. x86_64-pc-linux-gnu, 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: + + make check-target-libstdc++-v3 RUNTESTFLAGS='--target_board=unix/-ffreestanding' + + + + You can run the tests with a compiler and library that have already been installed. Make sure that the compiler (e.g., g++) is in your PATH. If you are diff --git a/libstdc++-v3/doc/xml/manual/using.xml b/libstdc++-v3/doc/xml/manual/using.xml index 9c444dd..7f011a6 100644 --- a/libstdc++-v3/doc/xml/manual/using.xml +++ b/libstdc++-v3/doc/xml/manual/using.xml @@ -132,6 +132,17 @@ + + -ffreestanding + + 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. + + + @@ -1523,19 +1534,60 @@ namespace gtk - There exists a library that offers runtime support for - just these headers, and it is called - libsupc++.a. To use it, compile with gcc instead of g++, like so: + + 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: + + + + + + string_view + + + + + tuple + + + + + bitset + + + + + + 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. + + + + 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 gcc to link your + application with only libsupc++.a, + like so: - gcc foo.cc -lsupc++ + gcc -ffreestanding foo.cc -lsupc++ - 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 + --disable-hosted-libstdcxx, however, you can use the + normal g++ command to link, as this configuration + provides a (nearly) empty libstdc++.a. -- 2.7.4