]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Add Filesystem TS and std::stacktrace symbols to libstdc++exp.a
authorJonathan Wakely <jwakely@redhat.com>
Thu, 7 Sep 2023 09:24:56 +0000 (10:24 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Wed, 10 Jan 2024 11:20:02 +0000 (11:20 +0000)
This consolidates the three static archives for extensions into one, so
that -lstdc++exp can be used to provide the definitions of all unstable
library features.

For this gcc-13 backport libstdc++_libbacktrace.a is still installed,
but its contents are duplicated in libstdc++exp.a. This means that users
can start using -lstdc++exp with GCC 13.3 if they want, but existing
Makefiles can continue to use -lstdc++_libbacktrace for any GCC 13.x
release.

The libstdc++fs.a archive is still installed, but its contents are
duplicated in libstdc++exp.a now. This means -lstdc++exp can be used
instead of -lstdc++fs. For targets using the GNU linker we should
consider replacing libstdc++fs.a with a linker script that does
INPUT(libstdc++exp.a).

The tests for <experimental/filesystem> could be changed to use
-lstdc++exp instead of -lstdc++fs, which would allow removing
src/filesystem/.libs from the LDFLAGS in scripts/testsuite_flags.in,
but that can be done at a later date.

libstdc++-v3/ChangeLog:

* doc/html/manual/*: Regenerate.
* doc/xml/manual/using.xml: Update documentation on linking.
* scripts/testsuite_flags.in: Adjust LDFLAGS to find
libstdc++exp instead of libstdc++_libbacktrace.
* src/c++20/Makefile.am: Fix comment.
* src/c++20/Makefile.in: Regenerate.
* src/experimental/Makefile.am: Use LIBADD to include other
libraries.
* src/experimental/Makefile.in: Regenerate.
* testsuite/19_diagnostics/stacktrace/current.cc: Adjust
dg-options to use -lstdc++exp.
* testsuite/19_diagnostics/stacktrace/entry.cc: Likewise.
* testsuite/19_diagnostics/stacktrace/stacktrace.cc: Likewise.
* testsuite/23_containers/vector/debug/assign4_backtrace_neg.cc:
Likewise.

(cherry picked from commit b96b554592c5cbb6a2c1797ffcb5706fd295f4fd)

12 files changed:
libstdc++-v3/doc/html/manual/using.html
libstdc++-v3/doc/html/manual/using_dynamic_or_shared.html
libstdc++-v3/doc/xml/manual/using.xml
libstdc++-v3/scripts/testsuite_flags.in
libstdc++-v3/src/c++20/Makefile.am
libstdc++-v3/src/c++20/Makefile.in
libstdc++-v3/src/experimental/Makefile.am
libstdc++-v3/src/experimental/Makefile.in
libstdc++-v3/testsuite/19_diagnostics/stacktrace/current.cc
libstdc++-v3/testsuite/19_diagnostics/stacktrace/entry.cc
libstdc++-v3/testsuite/19_diagnostics/stacktrace/stacktrace.cc
libstdc++-v3/testsuite/23_containers/vector/debug/assign4_backtrace_neg.cc

index eebb35da279fc2c3bc0b8aa32571313518e88237..e8e0c6c0e8590f907a950858a026892f6260a8a7 100644 (file)
       </td></tr><tr><td align="left"><code class="literal">-latomic</code></td><td align="left">Linking to <code class="filename">libatomic</code>
         is required for some uses of ISO C++11
         <code class="filename">&lt;atomic&gt;</code>.
-      </td></tr><tr><td align="left"><code class="literal">-lstdc++fs</code></td><td align="left">Linking to <code class="filename">libstdc++fs</code>
-        is required for use of the Filesystem library extensions in
-        <code class="filename">&lt;experimental/filesystem&gt;</code>.
-      </td></tr><tr><td align="left"><code class="literal">-lstdc++exp</code></td><td align="left">Linking to <code class="filename">libstdc++exp</code>
-        is required for use of the C++ Contracts extensions enabled by
-        <code class="literal">-fcontracts</code>.
-      </td></tr><tr><td align="left"><code class="literal">-lstdc++_libbacktrace</code></td><td align="left">Until C++23 support is non-experimental, linking to
-       <code class="filename">libstdc++_libbacktrace.a</code>
-       is required for use of the C++23 type
-       <code class="classname">std::stacktrace</code>
-       and related types in
-       <code class="filename">&lt;stacktrace&gt;</code>.
+      </td></tr><tr><td align="left"><code class="literal">-lstdc++exp</code></td><td align="left">Linking to <code class="filename">libstdc++exp.a</code>
+        is required for use of experimental C++ library features.
+        This currently provides support for the C++23 types defined in the
+        <code class="filename">&lt;stacktrace&gt;</code> header,
+        the Filesystem library extensions defined in the
+        <code class="filename">&lt;experimental/filesystem&gt;</code>
+        header,
+        and the Contracts extensions enabled by <code class="literal">-fcontracts</code>.
+      </td></tr><tr><td align="left"><code class="literal">-lstdc++fs</code></td><td align="left">Linking to <code class="filename">libstdc++fs.a</code>
+        is another way to use the Filesystem library extensions defined in the
+        <code class="filename">&lt;experimental/filesystem&gt;</code>
+        header.
+        The <code class="filename">libstdc++exp.a</code> library
+        also provides all the symbols contained in this library.
       </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>.
index 46ccbc55c3388f232eb2cb3e71fb9c051651f6c0..f1e727800c28771c70e20b968248428dc3fbc54d 100644 (file)
@@ -138,6 +138,10 @@ A quick read of the relevant part of the GCC
       and link with <code class="option">-lstdc++fs</code>. The library implementation
       is incomplete on non-POSIX platforms, specifically Windows is only
       partially supported.
+      Since GCC 14, <code class="filename">libstdc++exp.a</code>
+      also contains the definitions for this library,
+      so <code class="option">-lstdc++exp</code> can be used instead of
+      <code class="option">-lstdc++fs</code>.
     </p><p>
       GCC 13 includes an implementation of the C++ Contracts library defined by
       <a class="link" href="https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1429r3.pdf" target="_top">P1429R3</a>.
index 3a507fc1671b6ac548a4dc625791b88512132b97..7276cad0feb9415c41e2eb7e9bfb6633422f69da 100644 (file)
       </entry>
     </row>
 
-    <row>
-      <entry><literal>-lstdc++fs</literal></entry>
-      <entry>Linking to <filename class="libraryfile">libstdc++fs</filename>
-        is required for use of the Filesystem library extensions in
-        <filename class="headerfile">&lt;experimental/filesystem&gt;</filename>.
-      </entry>
-    </row>
-
     <row>
       <entry><literal>-lstdc++exp</literal></entry>
-      <entry>Linking to <filename class="libraryfile">libstdc++exp</filename>
-        is required for use of the C++ Contracts extensions enabled by
-        <literal>-fcontracts</literal>.
+      <entry>Linking to <filename class="libraryfile">libstdc++exp.a</filename>
+        is required for use of experimental C++ library features.
+        This currently provides support for the C++23 types defined in the
+        <filename class="headerfile">&lt;stacktrace&gt;</filename> header,
+        the Filesystem library extensions defined in the
+        <filename class="headerfile">&lt;experimental/filesystem&gt;</filename>
+        header,
+        and the Contracts extensions enabled by <literal>-fcontracts</literal>.
       </entry>
     </row>
 
     <row>
-      <entry><literal>-lstdc++_libbacktrace</literal></entry>
-      <entry>Until C++23 support is non-experimental, linking to
-       <filename class="libraryfile">libstdc++_libbacktrace.a</filename>
-       is required for use of the C++23 type
-       <classname>std::stacktrace</classname>
-       and related types in
-       <filename class="headerfile">&lt;stacktrace&gt;</filename>.
+      <entry><literal>-lstdc++fs</literal></entry>
+      <entry>Linking to <filename class="libraryfile">libstdc++fs.a</filename>
+        is another way to use the Filesystem library extensions defined in the
+        <filename class="headerfile">&lt;experimental/filesystem&gt;</filename>
+        header.
+        The <filename class="libraryfile">libstdc++exp.a</filename> library
+        also provides all the symbols contained in this library.
       </entry>
     </row>
 
@@ -1710,6 +1707,10 @@ A quick read of the relevant part of the GCC
       and link with <option>-lstdc++fs</option>. The library implementation
       is incomplete on non-POSIX platforms, specifically Windows is only
       partially supported.
+      Since GCC 14, <filename class="libraryfile">libstdc++exp.a</filename>
+      also contains the definitions for this library,
+      so <option>-lstdc++exp</option> can be used instead of
+      <option>-lstdc++fs</option>.
     </para>
 
     <para>
index 18748f0f9ce3beb225e88dc9472c58d0463b05f4..8bf4918287ad2fcb3231e8ce49f0eedf4f22ca91 100755 (executable)
@@ -78,14 +78,14 @@ case ${query} in
       ;;
     --cxxldflags)
       FS_LDFLAGS=
-      BT_LDFLAGS=
+      EXP_LDFLAGS=
       if [ -d ${BUILD_DIR}/src/filesystem/.libs ]; then
         FS_LDFLAGS=-L${BUILD_DIR}/src/filesystem/.libs
       fi
-      if [ -d ${BUILD_DIR}/src/libbacktrace/.libs ]; then
-        BT_LDFLAGS=-L${BUILD_DIR}/src/libbacktrace/.libs
+      if [ -d ${BUILD_DIR}/src/experimental/.libs ]; then
+        EXP_LDFLAGS=-L${BUILD_DIR}/src/experimental/.libs
       fi
-      SECTIONLDFLAGS="@SECTION_LDFLAGS@ @LIBICONV@ $FS_LDFLAGS $BT_LDFLAGS"
+      SECTIONLDFLAGS="@SECTION_LDFLAGS@ @LIBICONV@ $FS_LDFLAGS $EXP_LDFLAGS"
       echo ${SECTIONLDFLAGS}
       ;;
     *)
index 0bc8a7b832a9698d5730883d79ac79e6e6f4425e..e947855e6ae5b11bbd5c3ade0fa4960f15c01ea7 100644 (file)
@@ -22,7 +22,7 @@
 
 include $(top_srcdir)/fragment.am
 
-# Convenience library for C++17 runtime.
+# Convenience library for C++20 runtime.
 noinst_LTLIBRARIES = libc++20convenience.la
 
 headers =
index 23aba3d62d4e11ddbbe09330d72fde131e930542..3ec8c5ce804f145ce16ecc8dee7765237e3ef060 100644 (file)
@@ -422,7 +422,7 @@ WARN_CXXFLAGS = \
 # -I/-D flags to pass when compiling.
 AM_CPPFLAGS = $(GLIBCXX_INCLUDES) $(CPPFLAGS)
 
-# Convenience library for C++17 runtime.
+# Convenience library for C++20 runtime.
 noinst_LTLIBRARIES = libc++20convenience.la
 headers = 
 # XTEMPLATE_FLAGS =
index 3b962e7d8045a3e97e4808fe21090f04047a3dbf..1c7cea7e84675f7e4ec027f2be5459ab8993cb02 100644 (file)
@@ -24,6 +24,18 @@ include $(top_srcdir)/fragment.am
 
 toolexeclib_LTLIBRARIES = libstdc++exp.la
 
+if ENABLE_FILESYSTEM_TS
+filesystem_lib = $(top_builddir)/src/filesystem/libstdc++fs.la
+else
+filesystem_lib =
+endif
+
+if ENABLE_BACKTRACE
+backtrace_lib = $(top_builddir)/src/libbacktrace/libstdc++_libbacktrace.la
+else
+backtrace_lib =
+endif
+
 headers =
 
 sources = \
@@ -33,6 +45,12 @@ sources = \
 
 libstdc__exp_la_SOURCES = $(sources)
 
+libstdc__exp_la_LIBADD = \
+       $(filesystem_lib) $(backtrace_lib)
+
+libstdc__exp_la_DEPENDENCIES = \
+       $(filesystem_lib) $(backtrace_lib)
+
 # AM_CXXFLAGS needs to be in each subdirectory so that it can be
 # modified in a per-library or per-sub-library way.  Need to manually
 # set this option because CONFIG_CXXFLAGS has to be after
index 671f0703bcb5b26b7b7eceed2e1519e1fc7d29bb..6f6b742c1cfa3d2a0ae85c17266715cb968e19f5 100644 (file)
@@ -148,7 +148,8 @@ am__uninstall_files_from_dir = { \
   }
 am__installdirs = "$(DESTDIR)$(toolexeclibdir)"
 LTLIBRARIES = $(toolexeclib_LTLIBRARIES)
-libstdc__exp_la_LIBADD =
+@ENABLE_FILESYSTEM_TS_TRUE@am__DEPENDENCIES_1 = $(top_builddir)/src/filesystem/libstdc++fs.la
+@ENABLE_BACKTRACE_TRUE@am__DEPENDENCIES_2 = $(top_builddir)/src/libbacktrace/libstdc++_libbacktrace.la
 am__objects_1 = contract.lo
 am_libstdc__exp_la_OBJECTS = $(am__objects_1)
 libstdc__exp_la_OBJECTS = $(am_libstdc__exp_la_OBJECTS)
@@ -448,6 +449,10 @@ WARN_CXXFLAGS = \
 # -I/-D flags to pass when compiling.
 AM_CPPFLAGS = $(GLIBCXX_INCLUDES) $(CPPFLAGS)
 toolexeclib_LTLIBRARIES = libstdc++exp.la
+@ENABLE_FILESYSTEM_TS_FALSE@filesystem_lib = 
+@ENABLE_FILESYSTEM_TS_TRUE@filesystem_lib = $(top_builddir)/src/filesystem/libstdc++fs.la
+@ENABLE_BACKTRACE_FALSE@backtrace_lib = 
+@ENABLE_BACKTRACE_TRUE@backtrace_lib = $(top_builddir)/src/libbacktrace/libstdc++_libbacktrace.la
 headers = 
 sources = \
        contract.cc
@@ -455,6 +460,12 @@ sources = \
 
 # vpath % $(top_srcdir)/src/experimental
 libstdc__exp_la_SOURCES = $(sources)
+libstdc__exp_la_LIBADD = \
+       $(filesystem_lib) $(backtrace_lib)
+
+libstdc__exp_la_DEPENDENCIES = \
+       $(filesystem_lib) $(backtrace_lib)
+
 
 # AM_CXXFLAGS needs to be in each subdirectory so that it can be
 # modified in a per-library or per-sub-library way.  Need to manually
index 184e23b460e4bbe9e42f3fd0fd49a0ca7c6885bc..f6c860fc7a4b9fab45392839dbcd647c7e56de00 100644 (file)
@@ -1,4 +1,4 @@
-// { dg-options "-std=gnu++23 -lstdc++_libbacktrace" }
+// { dg-options "-std=gnu++23 -lstdc++exp" }
 // { dg-do run { target c++23 } }
 // { dg-require-effective-target stacktrace }
 
index a222c425b20a4e5ca30999f70f60b6a4dc810fbd..f0406953d032ee8e906bc38315070ca82cee8d8e 100644 (file)
@@ -1,4 +1,4 @@
-// { dg-options "-std=gnu++23 -lstdc++_libbacktrace" }
+// { dg-options "-std=gnu++23 -lstdc++exp" }
 // { dg-do run { target c++23 } }
 // { dg-require-effective-target stacktrace }
 
index 8dfdf4739bee6abe28142f65b29cffa6bc34ae6a..0a358b7b8ff715c281fcb50298ebf524a076bb60 100644 (file)
@@ -1,4 +1,4 @@
-// { dg-options "-std=gnu++23 -lstdc++_libbacktrace" }
+// { dg-options "-std=gnu++23 -lstdc++exp" }
 // { dg-do run { target c++23 } }
 // { dg-require-effective-target stacktrace }
 
index 520788d5cb7b6cfdc9fb44d0f27a3e9a7a45bed7..43a82fb120101376e58eddeddbd534786fac13fb 100644 (file)
@@ -1,5 +1,5 @@
 // { dg-do run { xfail *-*-* } }
-// { dg-options "-D_GLIBCXX_DEBUG_BACKTRACE -lstdc++_libbacktrace" }
+// { dg-options "-D_GLIBCXX_DEBUG_BACKTRACE -lstdc++exp" }
 // { dg-require-effective-target stacktrace }
 
 #include <debug/vector>