From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id 2EC823858C83; Mon, 6 Feb 2023 20:47:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2EC823858C83 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675716467; bh=T8Ha0TM17IZvvtCWnJnKbAhV/1jiPLF52WOFySBY4QU=; h=From:To:Subject:Date:From; b=fynKmhux/6mtCfk5zkggnhwvWTAGH1ZpvdEJC1icg205GLrD8fZAxydWVTbjrG+dr SR93t8w+IDsyoXgpASbVtClIEBQ0vN9WcZPTSKsqh2e72LoGC+E5lmv4MQah5iKBzL S4foWbYzf7icWjj4tV5oEncXoI55+rh+g2t5gY0E= MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r13-5722] libstdc++: Document P1642 and extensions X-Act-Checkin: gcc X-Git-Author: =?utf-8?q?Arsen_Arsenovi=C4=87?= X-Git-Refname: refs/heads/master X-Git-Oldrev: 17d0892d61a82a338925c81853b45eb8b4929fc0 X-Git-Newrev: 9f4baed6ac02f721f1adee043c4aa920dd5075b7 Message-Id: <20230206204747.2EC823858C83@sourceware.org> Date: Mon, 6 Feb 2023 20:47:47 +0000 (GMT) List-Id: https://gcc.gnu.org/g:9f4baed6ac02f721f1adee043c4aa920dd5075b7 commit r13-5722-g9f4baed6ac02f721f1adee043c4aa920dd5075b7 Author: Arsen Arsenović Date: Mon Jan 23 13:41:45 2023 +0100 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. Diff: --- 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 ce951e6cc8e..ed7021bd461 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 9c5c2d9f170..dd9e6ef3579 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 7766f133bea..24df9bd9481 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 a70613e8fd6..08ad2fd4dd8 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 ef54da8053a..90345550012 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 47bb0781417..c99d51ff709 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 10ae4ed5e1b..fadadf249bb 100644 --- a/libstdc++-v3/doc/html/manual/test.html +++ b/libstdc++-v3/doc/html/manual/test.html @@ -203,6 +203,18 @@ cat 27_io/objects/char/3_xin.in | a.out

     make check-target-libstdc++-v3 RUNTESTFLAGS='--target_board \"unix{-mabi=32,,-mabi=64}\"'
 

+

+ 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., diff --git a/libstdc++-v3/doc/html/manual/using.html b/libstdc++-v3/doc/html/manual/using.html index f2dc2078759..f23325ebe97 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 3c9e5fa54b0..73d1f18485f 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 8b3b8cab8c7..7ff07aea886 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 365df505f54..f23c64d6a29 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 7bc6e339723..964c53d2632 100644 --- a/libstdc++-v3/doc/xml/manual/test.xml +++ b/libstdc++-v3/doc/xml/manual/test.xml @@ -350,6 +350,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., diff --git a/libstdc++-v3/doc/xml/manual/using.xml b/libstdc++-v3/doc/xml/manual/using.xml index 9c444dd2997..7f011a6d931 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.