[PATCH] libstdc++: remove the gnu++11 in check performance script

Yuao Ma addr2line@gmail.com
Fri Aug 21 13:30:03 GMT 2026


On Fri, Aug 21, 2026 at 9:02 PM Jonathan Wakely <jwakely@redhat.com> wrote:
>
> On Fri, 21 Aug 2026 at 13:48, Yuao Ma <addr2line@gmail.com> wrote:
> >
> > On Fri, Aug 21, 2026 at 8:25 PM Jonathan Wakely <jwakely@redhat.com> wrote:
> > >
> > > On Fri, 21 Aug 2026 at 20:23 +0800, Yuao Ma wrote:
> > > >On Thu, Aug 20, 2026 at 11:34 PM Jonathan Wakely <jwakely@redhat.com> wrote:
> > > >>
> > > >> On Thu, 20 Aug 2026 at 14:38, Yuao Ma <addr2line@gmail.com> wrote:
> > > >> >
> > > >> > Hi!
> > > >> >
> > > >> > Based on previous discussions, we could remove the gnu++11 flag in the
> > > >> > check performance script. And the rebind logic removed in c++20 is
> > > >> > also adjusted.
> > > >>
> > > >> This makes the pb_ds performance tests unable to run as C++98, because
> > > >> that doesn't have std::allocator_traits. So if anybody wanted to
> > > >> compare performance of those containers in C++98 and C++20 (or C++11),
> > > >> maybe because they were adding move semantics to the pb_ds containers,
> > > >> the performance tests would not work.
> > > >>
> > > >> Although I really don't care about the pb_ds tests (because pb_ds is
> > > >> unmaintained and should be moved to a separate repo), you could make
> > > >> it work for all versions of C++ by using __gnu_cxx::__alloc_traits
> > > >> instead of std::allocator_traits.
> > > >>
> > > >
> > > >Thanks for the review! Indeed when I made the change in the patch I
> > > >did not think about the compatibility of c++98. Fixed in the new
> > > >patch.
> > > >
> > > >> >
> > > >> > Tested with make check-performance, ok for trunk?
> > > >> >
> > > >> > Thanks,
> > > >> > Yuao
> > > >>
> > >
> > > >From b243166201265b86491044b20bdba79116766ae6 Mon Sep 17 00:00:00 2001
> > > >From: Yuao Ma <c8ef@outlook.com>
> > > >Date: Fri, 21 Aug 2026 20:21:13 +0800
> > > >Subject: [PATCH] libstdc++: remove the gnu++11 in check performance script
> > > >
> > > >Nowadays gcc's default c++ version is gnu++20, maybe we should just use
> > > >this in performance check as well.
> > > >
> > > >libstdc++-v3/ChangeLog:
> > > >
> > > >       * scripts/check_performance: Remove gnu++11 flag.
> > > >       * testsuite/util/native_type/native_hash_map.hpp: Adjust rebind
> > > >       usage.
> > > >       * testsuite/util/native_type/native_hash_multimap.hpp: Ditto.
> > > >       * testsuite/util/native_type/native_hash_set.hpp: Ditto.
> > > >       * testsuite/util/native_type/native_map.hpp: Ditto.
> > > >       * testsuite/util/native_type/native_multimap.hpp: Ditto.
> > > >       * testsuite/util/native_type/native_set.hpp: Ditto.
> > > >---
> > > > libstdc++-v3/scripts/check_performance                     | 2 +-
> > > > .../testsuite/util/native_type/native_hash_map.hpp         | 2 +-
> > > > .../testsuite/util/native_type/native_hash_multimap.hpp    | 4 +---
> > > > .../testsuite/util/native_type/native_hash_set.hpp         | 2 +-
> > > > libstdc++-v3/testsuite/util/native_type/native_map.hpp     | 4 ++--
> > > > .../testsuite/util/native_type/native_multimap.hpp         | 7 ++-----
> > > > libstdc++-v3/testsuite/util/native_type/native_set.hpp     | 2 +-
> > > > 7 files changed, 9 insertions(+), 14 deletions(-)
> > > >
> > > >diff --git a/libstdc++-v3/scripts/check_performance b/libstdc++-v3/scripts/check_performance
> > > >index 4831ed71b6f..eb6adbc5ec6 100755
> > > >--- a/libstdc++-v3/scripts/check_performance
> > > >+++ b/libstdc++-v3/scripts/check_performance
> > > >@@ -32,7 +32,7 @@ SH_FLAG="-Wl,--rpath -Wl,$BUILD_DIR/../../gcc \
> > > >          -Wl,--rpath -Wl,$BUILD_DIR/src/.libs"
> > > > ST_FLAG="-static"
> > > > LINK=$SH_FLAG
> > > >-CXX="$COMPILER $INCLUDES $FLAGS -std=gnu++11 $CXXFLAGS $LINK"
> > > >+CXX="$COMPILER $INCLUDES $FLAGS $CXXFLAGS $LINK"
> > > > LIBS="./libtestc++.a"
> > > > TESTS_FILE="testsuite_files_performance"
> > > >
> > > >diff --git a/libstdc++-v3/testsuite/util/native_type/native_hash_map.hpp b/libstdc++-v3/testsuite/util/native_type/native_hash_map.hpp
> > > >index 1eb9851c886..0c0ecaeaa6b 100644
> > > >--- a/libstdc++-v3/testsuite/util/native_type/native_hash_map.hpp
> > > >+++ b/libstdc++-v3/testsuite/util/native_type/native_hash_map.hpp
> > > >@@ -50,7 +50,7 @@ namespace __gnu_pbds
> > > >   {
> > > > #define PB_DS_BASE_C_DEC \
> > > >     std::tr1::__unordered_map<Key, Data, Hash_Fn, Eq_Fn, \
> > > >-    typename _Alloc::template rebind<std::pair<const Key, Data> >::other, Cache_Hash>
> > > >+    typename __gnu_cxx::__alloc_traits<_Alloc>::template rebind_alloc<std::pair<const Key, Data>>, Cache_Hash>
> > >
> > > For C++98 compatibility we need a space between the >> tokens.
> > >
> > > >
> > > >     template<typename Key,
> > > >            typename Data,
> > > >diff --git a/libstdc++-v3/testsuite/util/native_type/native_hash_multimap.hpp b/libstdc++-v3/testsuite/util/native_type/native_hash_multimap.hpp
> > > >index 35f16de8a1c..f6808aab9d1 100644
> > > >--- a/libstdc++-v3/testsuite/util/native_type/native_hash_multimap.hpp
> > > >+++ b/libstdc++-v3/testsuite/util/native_type/native_hash_multimap.hpp
> > > >@@ -70,9 +70,7 @@ namespace __gnu_pbds
> > > >       typedef typename base_type::iterator    iterator;
> > > >       typedef typename base_type::const_iterator const_iterator;
> > > >
> > > >-      typedef
> > > >-      typename allocator::template rebind<pair_type>::other::const_reference
> > > >-      const_reference;
> > > >+      typedef const pair_type& const_reference;
> > > >
> > > >       native_hash_multimap() : base_type(Init_Size)
> > > >       { }
> > > >diff --git a/libstdc++-v3/testsuite/util/native_type/native_hash_set.hpp b/libstdc++-v3/testsuite/util/native_type/native_hash_set.hpp
> > > >index 75ebed43110..27bc4d76d3d 100644
> > > >--- a/libstdc++-v3/testsuite/util/native_type/native_hash_set.hpp
> > > >+++ b/libstdc++-v3/testsuite/util/native_type/native_hash_set.hpp
> > > >@@ -50,7 +50,7 @@ namespace __gnu_pbds
> > > >   {
> > > > #define PB_DS_BASE_C_DEC \
> > > >     std::tr1::__unordered_set<Key, Hash_Fn, Eq_Fn, \
> > > >-    typename _Alloc::template rebind<Key>::other, Cache_Hash>
> > > >+    typename __gnu_cxx::__alloc_traits<_Alloc>::template rebind_alloc<Key>, Cache_Hash>
> > > >
> > > >     template<typename Key,
> > > >            size_t Init_Size = 8,
> > > >diff --git a/libstdc++-v3/testsuite/util/native_type/native_map.hpp b/libstdc++-v3/testsuite/util/native_type/native_map.hpp
> > > >index 958553951b4..1617ed27e20 100644
> > > >--- a/libstdc++-v3/testsuite/util/native_type/native_map.hpp
> > > >+++ b/libstdc++-v3/testsuite/util/native_type/native_map.hpp
> > > >@@ -49,8 +49,8 @@ namespace __gnu_pbds
> > > >   namespace test
> > > >   {
> > > > #define PB_DS_BASE_C_DEC \
> > > >-    std::map<Key, Data, Cmp_Fn,       \
> > > >-typename _Alloc::template rebind<std::pair<const Key, Data > >::other >
> > > >+    std::map<Key, Data, Cmp_Fn, \
> > > >+    typename __gnu_cxx::__alloc_traits<_Alloc>::template rebind_alloc<std::pair<const Key, Data>>>
> > >
> > > And here.
> > >
> > > >
> > > >     template<typename Key, typename Data, class Cmp_Fn = std::less<Key>,
> > > >            typename _Alloc = std::allocator<char> >
> > > >diff --git a/libstdc++-v3/testsuite/util/native_type/native_multimap.hpp b/libstdc++-v3/testsuite/util/native_type/native_multimap.hpp
> > > >index 3646de930b4..eea682131cd 100644
> > > >--- a/libstdc++-v3/testsuite/util/native_type/native_multimap.hpp
> > > >+++ b/libstdc++-v3/testsuite/util/native_type/native_multimap.hpp
> > > >@@ -48,7 +48,7 @@ namespace __gnu_pbds
> > > >   {
> > > > #define PB_DS_BASE_C_DEC \
> > > >     std::multimap<Key, Data, Less_Fn, \
> > > >-      typename _Alloc::template rebind<std::pair<const Key, Data> >::other>
> > > >+      typename __gnu_cxx::__alloc_traits<_Alloc>::template rebind_alloc<std::pair<const Key, Data>>>
> > >
> > > And here.
> > >
> > > >
> > > >     template<typename Key, typename Data, class Less_Fn = std::less<Key>,
> > > >            typename _Alloc = std::allocator<char> >
> > > >@@ -62,10 +62,7 @@ namespace __gnu_pbds
> > > >
> > > >       typedef _Alloc allocator;
> > > >
> > > >-      typedef
> > > >-      typename _Alloc::template rebind<
> > > >-      std::pair<Key, Data> >::other::const_reference
> > > >-      const_reference;
> > > >+      typedef const std::pair<Key, Data>& const_reference;
> > > >
> > > >       typedef typename base_type::iterator iterator;
> > > >       typedef typename base_type::const_iterator const_iterator;
> > > >diff --git a/libstdc++-v3/testsuite/util/native_type/native_set.hpp b/libstdc++-v3/testsuite/util/native_type/native_set.hpp
> > > >index d382a371226..d26e665843a 100644
> > > >--- a/libstdc++-v3/testsuite/util/native_type/native_set.hpp
> > > >+++ b/libstdc++-v3/testsuite/util/native_type/native_set.hpp
> > > >@@ -48,7 +48,7 @@ namespace __gnu_pbds
> > > >   namespace test
> > > >   {
> > > > #define PB_DS_BASE_C_DEC \
> > > >-    std::set<Key, Cmp_Fn, typename _Alloc::template rebind<Key>::other>
> > > >+    std::set<Key, Cmp_Fn, typename __gnu_cxx::__alloc_traits<_Alloc>::template rebind_alloc<Key>>
> > >
> > > And here.
> > >
> > > OK for trunk with those changes, thanks.
> > >
> >
> > After some checking it seems that __gnu_cxx::__alloc_traits does not
> > support rebind_alloc in gnu++98 : (
>
> Ah, it provides __alloc_traits::rebind not rebind_alloc.
> (Because 'rebind_alloc' is not a reserved name in C++98, but 'rebind' is)
>

Ah indeed. Fixed and verified.

>
> > So in the new patch I switch to conditional macros. Both 98 and 20 are
> > verified now. And for c++11 and above we can simply use the standard
> > traits.
> >
> > > >
> > > >     template<typename Key, class Cmp_Fn = std::less<Key>,
> > > >            typename _Alloc = std::allocator<char> >
> > > >--
> > > >2.54.0
> > > >
> > >
>
-------------- next part --------------
From ab33d220b68e308cf29fc56c81d236261e9cf591 Mon Sep 17 00:00:00 2001
From: Yuao Ma <c8ef@outlook.com>
Date: Fri, 21 Aug 2026 21:29:17 +0800
Subject: [PATCH] libstdc++: remove the gnu++11 in check performance script

Nowadays gcc's default c++ version is gnu++20, maybe we should just use
this in performance check as well.

libstdc++-v3/ChangeLog:

	* scripts/check_performance: Remove gnu++11 flag.
	* testsuite/util/native_type/native_hash_map.hpp: Adjust rebind
	usage.
	* testsuite/util/native_type/native_hash_multimap.hpp: Ditto.
	* testsuite/util/native_type/native_hash_set.hpp: Ditto.
	* testsuite/util/native_type/native_map.hpp: Ditto.
	* testsuite/util/native_type/native_multimap.hpp: Ditto.
	* testsuite/util/native_type/native_set.hpp: Ditto.
---
 libstdc++-v3/scripts/check_performance                     | 2 +-
 .../testsuite/util/native_type/native_hash_map.hpp         | 2 +-
 .../testsuite/util/native_type/native_hash_multimap.hpp    | 4 +---
 .../testsuite/util/native_type/native_hash_set.hpp         | 2 +-
 libstdc++-v3/testsuite/util/native_type/native_map.hpp     | 2 +-
 .../testsuite/util/native_type/native_multimap.hpp         | 7 ++-----
 libstdc++-v3/testsuite/util/native_type/native_set.hpp     | 2 +-
 7 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/libstdc++-v3/scripts/check_performance b/libstdc++-v3/scripts/check_performance
index 4831ed71b6f..eb6adbc5ec6 100755
--- a/libstdc++-v3/scripts/check_performance
+++ b/libstdc++-v3/scripts/check_performance
@@ -32,7 +32,7 @@ SH_FLAG="-Wl,--rpath -Wl,$BUILD_DIR/../../gcc \
          -Wl,--rpath -Wl,$BUILD_DIR/src/.libs"
 ST_FLAG="-static"
 LINK=$SH_FLAG
-CXX="$COMPILER $INCLUDES $FLAGS -std=gnu++11 $CXXFLAGS $LINK"
+CXX="$COMPILER $INCLUDES $FLAGS $CXXFLAGS $LINK"
 LIBS="./libtestc++.a"
 TESTS_FILE="testsuite_files_performance"
 
diff --git a/libstdc++-v3/testsuite/util/native_type/native_hash_map.hpp b/libstdc++-v3/testsuite/util/native_type/native_hash_map.hpp
index 1eb9851c886..d374455539d 100644
--- a/libstdc++-v3/testsuite/util/native_type/native_hash_map.hpp
+++ b/libstdc++-v3/testsuite/util/native_type/native_hash_map.hpp
@@ -50,7 +50,7 @@ namespace __gnu_pbds
   {
 #define PB_DS_BASE_C_DEC \
     std::tr1::__unordered_map<Key, Data, Hash_Fn, Eq_Fn, \
-    typename _Alloc::template rebind<std::pair<const Key, Data> >::other, Cache_Hash>
+    typename __gnu_cxx::__alloc_traits<_Alloc>::template rebind<std::pair<const Key, Data> >::other, Cache_Hash>
 
     template<typename Key,
 	     typename Data,
diff --git a/libstdc++-v3/testsuite/util/native_type/native_hash_multimap.hpp b/libstdc++-v3/testsuite/util/native_type/native_hash_multimap.hpp
index 35f16de8a1c..f6808aab9d1 100644
--- a/libstdc++-v3/testsuite/util/native_type/native_hash_multimap.hpp
+++ b/libstdc++-v3/testsuite/util/native_type/native_hash_multimap.hpp
@@ -70,9 +70,7 @@ namespace __gnu_pbds
       typedef typename base_type::iterator 	iterator;
       typedef typename base_type::const_iterator const_iterator;
 
-      typedef
-      typename allocator::template rebind<pair_type>::other::const_reference
-      const_reference;
+      typedef const pair_type& const_reference;
 
       native_hash_multimap() : base_type(Init_Size)
       { }
diff --git a/libstdc++-v3/testsuite/util/native_type/native_hash_set.hpp b/libstdc++-v3/testsuite/util/native_type/native_hash_set.hpp
index 75ebed43110..a2b2be5f3a0 100644
--- a/libstdc++-v3/testsuite/util/native_type/native_hash_set.hpp
+++ b/libstdc++-v3/testsuite/util/native_type/native_hash_set.hpp
@@ -50,7 +50,7 @@ namespace __gnu_pbds
   {
 #define PB_DS_BASE_C_DEC \
     std::tr1::__unordered_set<Key, Hash_Fn, Eq_Fn, \
-    typename _Alloc::template rebind<Key>::other, Cache_Hash>
+    typename __gnu_cxx::__alloc_traits<_Alloc>::template rebind<Key>::other, Cache_Hash>
 
     template<typename Key,
 	     size_t Init_Size = 8,
diff --git a/libstdc++-v3/testsuite/util/native_type/native_map.hpp b/libstdc++-v3/testsuite/util/native_type/native_map.hpp
index 958553951b4..72127f90446 100644
--- a/libstdc++-v3/testsuite/util/native_type/native_map.hpp
+++ b/libstdc++-v3/testsuite/util/native_type/native_map.hpp
@@ -50,7 +50,7 @@ namespace __gnu_pbds
   {
 #define PB_DS_BASE_C_DEC \
     std::map<Key, Data, Cmp_Fn,	\
-typename _Alloc::template rebind<std::pair<const Key, Data > >::other >
+typename __gnu_cxx::__alloc_traits<_Alloc>::template rebind<std::pair<const Key, Data > >::other >
 
     template<typename Key, typename Data, class Cmp_Fn = std::less<Key>,
 	     typename _Alloc = std::allocator<char> >
diff --git a/libstdc++-v3/testsuite/util/native_type/native_multimap.hpp b/libstdc++-v3/testsuite/util/native_type/native_multimap.hpp
index 3646de930b4..234b956fc60 100644
--- a/libstdc++-v3/testsuite/util/native_type/native_multimap.hpp
+++ b/libstdc++-v3/testsuite/util/native_type/native_multimap.hpp
@@ -48,7 +48,7 @@ namespace __gnu_pbds
   {
 #define PB_DS_BASE_C_DEC \
     std::multimap<Key, Data, Less_Fn, \
-      typename _Alloc::template rebind<std::pair<const Key, Data> >::other>
+      typename __gnu_cxx::__alloc_traits<_Alloc>::template rebind<std::pair<const Key, Data> >::other>
 
     template<typename Key, typename Data, class Less_Fn = std::less<Key>,
 	     typename _Alloc = std::allocator<char> >
@@ -62,10 +62,7 @@ namespace __gnu_pbds
 
       typedef _Alloc allocator;
 
-      typedef
-      typename _Alloc::template rebind<
-	std::pair<Key, Data> >::other::const_reference
-      const_reference;
+      typedef const std::pair<Key, Data>& const_reference;
 
       typedef typename base_type::iterator iterator;
       typedef typename base_type::const_iterator const_iterator;
diff --git a/libstdc++-v3/testsuite/util/native_type/native_set.hpp b/libstdc++-v3/testsuite/util/native_type/native_set.hpp
index d382a371226..59ce1f40808 100644
--- a/libstdc++-v3/testsuite/util/native_type/native_set.hpp
+++ b/libstdc++-v3/testsuite/util/native_type/native_set.hpp
@@ -48,7 +48,7 @@ namespace __gnu_pbds
   namespace test
   {
 #define PB_DS_BASE_C_DEC \
-    std::set<Key, Cmp_Fn, typename _Alloc::template rebind<Key>::other>
+    std::set<Key, Cmp_Fn, typename __gnu_cxx::__alloc_traits<_Alloc>::template rebind<Key>::other>
 
     template<typename Key, class Cmp_Fn = std::less<Key>,
 	     typename _Alloc = std::allocator<char> >
-- 
2.54.0



More information about the Libstdc++ mailing list