Sync libstdc++ pretty printers to latest GTS

Resolves: RHEL-81975
This commit is contained in:
Siddhesh Poyarekar 2025-06-23 07:09:32 -04:00 committed by Siddhesh Poyarekar
parent deef6754b7
commit 6ee19f4557
5 changed files with 4451 additions and 1 deletions

View File

@ -4,7 +4,7 @@
%global gcc_major 11
# Note, gcc_release must be integer, if you want to add suffixes to
# %%{release}, append them after %%{gcc_release} on Release: line.
%global gcc_release 7
%global gcc_release 8
%global nvptx_tools_gitrev 5f6f343a302d620b0868edab376c00b15741e39e
%global newlib_cygwin_gitrev 50e2a63b04bdd018484605fbb954fd1bd5147fa0
%global _unpackaged_files_terminate_build 0
@ -313,6 +313,11 @@ Patch107: gcc11-fortran-fdec-promotion.patch
Patch108: gcc11-fortran-fdec-sequence.patch
Patch109: gcc11-fortran-fdec-add-missing-indexes.patch
# Pretty printer update.
Patch1000: gcc11-libstdc++-prettyprinter-update-15.patch
Patch1001: gcc11-libstdc++-prettyprinter-update-15-tests.patch
Patch1002: gcc11-libstdc++-prettyprinter-update-15-tests-48362.patch
# On ARM EABI systems, we do want -gnueabi to be part of the
# target triple.
%ifnarch %{arm}
@ -921,6 +926,10 @@ mark them as cross compiled.
%patch109 -p1 -b .fortran-fdec-add-missing-indexes~
%endif
%patch1000 -p1 -b .libstdc++-prettyprinter-update-15
%patch1001 -p1 -b .libstdc++-prettyprinter-update-15-tests
%patch1002 -p1 -b .libstdc++-prettyprinter-update-15-tests-48362
%ifarch %{arm}
rm -f gcc/testsuite/go.test/test/fixedbugs/issue19182.go
%endif
@ -3603,6 +3612,9 @@ end
%endif
%changelog
* Mon Jun 23 2025 Siddhesh Poyarekar <siddhesh@redhat.com> - 11.5.0-8
- Sync libstdc++ pretty printers to latest GTS (RHEL-81975)
* Thu May 29 2025 Joseph Myers <josmyers@redhat.com> - 11.5.0-7
- Fix folding of BIT_NOT_EXPR for POLY_INT_CST (PR 118976, RHEL-90239)

View File

@ -0,0 +1,27 @@
commit 190c644c06369766aa2537851ddbf83b1231b65b
Author: Philipp Fent <fent@in.tum.de>
Date: Sun Sep 4 20:47:34 2022 +0200
libstdc++: Fix pretty printer tests of tuple indexes
Signed-off-by: Philipp Fent <fent@in.tum.de>
libstdc++-v3/ChangeLog:
* testsuite/libstdc++-prettyprinters/48362.cc: Fix expected
tuple indices.
* testsuite/libstdc++-prettyprinters/cxx11.cc: Likewise.
diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/48362.cc b/libstdc++-v3/testsuite/libstdc++-prettyprinters/48362.cc
index cc91803e247..af335d0d3c7 100644
--- a/libstdc++-v3/testsuite/libstdc++-prettyprinters/48362.cc
+++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/48362.cc
@@ -29,7 +29,7 @@ main()
// { dg-final { note-test t1 {empty std::tuple} } }
std::tuple<std::string, int, std::tuple<>> t2{ "Johnny", 5, {} };
-// { dg-final { regexp-test t2 {std::tuple containing = {\[1\] = "Johnny", \[2\] = 5, \[3\] = empty std::tuple}} } }
+// { dg-final { regexp-test t2 {std::tuple containing = {\[0\] = "Johnny", \[1\] = 5, \[2\] = empty std::tuple}} } }
std::cout << "\n";
return 0; // Mark SPOT

View File

@ -0,0 +1,270 @@
.../testsuite/libstdc++-prettyprinters/compat.cc | 10 +++----
.../testsuite/libstdc++-prettyprinters/cxx11.cc | 33 +++++++++++++++++-----
.../testsuite/libstdc++-prettyprinters/cxx17.cc | 27 ++++++++----------
.../libstdc++-prettyprinters/filesystem-ts.cc | 2 +-
.../libstdc++-prettyprinters/libfundts.cc | 25 ++++++++--------
5 files changed, 58 insertions(+), 39 deletions(-)
diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/compat.cc b/libstdc++-v3/testsuite/libstdc++-prettyprinters/compat.cc
index 35243e5f892..2ef5979834f 100644
--- a/libstdc++-v3/testsuite/libstdc++-prettyprinters/compat.cc
+++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/compat.cc
@@ -1,7 +1,7 @@
// { dg-options "-g -O0" }
// { dg-do run { target c++11 } }
-// Copyright (C) 2014-2021 Free Software Foundation, Inc.
+// Copyright (C) 2014-2025 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@@ -102,13 +102,13 @@ main()
using std::optional;
optional<int> o;
-// { dg-final { note-test o {std::optional<int> [no contained value]} } }
+// { dg-final { note-test o {std::optional [no contained value]} } }
optional<bool> ob{false};
-// { dg-final { note-test ob {std::optional<bool> = {[contained value] = false}} } }
+// { dg-final { note-test ob {std::optional = {[contained value] = false}} } }
optional<int> oi{5};
-// { dg-final { note-test oi {std::optional<int> = {[contained value] = 5}} } }
+// { dg-final { note-test oi {std::optional = {[contained value] = 5}} } }
optional<void*> op{nullptr};
-// { dg-final { note-test op {std::optional<void *> = {[contained value] = 0x0}} } }
+// { dg-final { note-test op {std::optional = {[contained value] = 0x0}} } }
__builtin_puts("");
return 0; // Mark SPOT
diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx11.cc b/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx11.cc
index 0545076fb6f..23f6d97ddd4 100644
--- a/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx11.cc
+++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx11.cc
@@ -1,7 +1,7 @@
// { dg-do run { target c++11 } }
// { dg-options "-g -O0" }
-// Copyright (C) 2011-2021 Free Software Foundation, Inc.
+// Copyright (C) 2011-2025 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@@ -26,6 +26,7 @@
#include <iostream>
#include <future>
#include <initializer_list>
+#include <atomic>
#include "../util/testsuite_allocator.h" // NullablePointer
typedef std::tuple<int, int> ExTuple;
@@ -62,6 +63,11 @@ struct datum
std::unique_ptr<datum> global;
+struct custom_cat : std::error_category {
+ const char* name() const noexcept { return "miaow"; }
+ std::string message(int) const { return ""; }
+};
+
int
main()
{
@@ -165,9 +171,9 @@ main()
// { dg-final { note-test runiq_ptr {std::unique_ptr<int> = {get() = 0x0}} } }
ExTuple tpl(6,7);
-// { dg-final { note-test tpl {std::tuple containing = {[1] = 6, [2] = 7}} } }
+// { dg-final { note-test tpl {std::tuple containing = {[0] = 6, [1] = 7}} } }
ExTuple &rtpl = tpl;
-// { dg-final { note-test rtpl {std::tuple containing = {[1] = 6, [2] = 7}} } }
+// { dg-final { note-test rtpl {std::tuple containing = {[0] = 6, [1] = 7}} } }
std::error_code e0;
// { dg-final { note-test e0 {std::error_code = { }} } }
@@ -178,10 +184,7 @@ main()
std::error_condition ecinval = std::make_error_condition(std::errc::invalid_argument);
// { dg-final { note-test ecinval {std::error_condition = {"generic": EINVAL}} } }
- struct custom_cat : std::error_category {
- const char* name() const noexcept { return "miaow"; }
- std::string message(int) const { return ""; }
- } cat;
+ custom_cat cat;
std::error_code emiaow(42, cat);
// { dg-final { note-test emiaow {std::error_code = {custom_cat: 42}} } }
std::error_condition ecmiaow(42, cat);
@@ -197,6 +200,22 @@ main()
std::initializer_list<int> il = {3, 4};
// { dg-final { note-test il {std::initializer_list of length 2 = {3, 4}} } }
+ std::atomic<int> ai{100};
+ // { dg-final { note-test ai {std::atomic<int> = { 100 }} } }
+ long l{};
+ std::atomic<long*> ap{&l};
+ // { dg-final { regexp-test ap {std::atomic.long \*. = { 0x.* }} } }
+ struct Value { int i, j; };
+ std::atomic<Value> av{{8, 9}};
+ // { dg-final { note-test av {std::atomic<Value> = { {i = 8, j = 9} }} } }
+
+ std::integral_constant<int, 1> one;
+ // { dg-final { note-test one {std::integral_constant<int, 1>} } }
+ std::integral_constant<bool, true> truth;
+ // { dg-final { note-test truth {std::true_type} } }
+ std::integral_constant<bool, 0> lies;
+ // { dg-final { note-test lies {std::false_type} } }
+
placeholder(""); // Mark SPOT
use(efl);
use(fl);
diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx17.cc b/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx17.cc
index 72c66d3b785..6dd2b60c0a5 100644
--- a/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx17.cc
+++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx17.cc
@@ -1,7 +1,7 @@
// { dg-options "-g -O0" }
// { dg-do run { target c++17 } }
-// Copyright (C) 2014-2021 Free Software Foundation, Inc.
+// Copyright (C) 2014-2025 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@@ -18,9 +18,6 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// Type printers only recognize the old std::string for now.
-#define _GLIBCXX_USE_CXX11_ABI 0
-
#include <filesystem>
#include <any>
#include <optional>
@@ -53,18 +50,18 @@ main()
// { dg-final { note-test str "\"string\"" } }
optional<int> o;
-// { dg-final { note-test o {std::optional<int> [no contained value]} } }
+// { dg-final { note-test o {std::optional [no contained value]} } }
optional<bool> ob{false};
-// { dg-final { note-test ob {std::optional<bool> = {[contained value] = false}} } }
+// { dg-final { note-test ob {std::optional = {[contained value] = false}} } }
optional<int> oi{5};
-// { dg-final { note-test oi {std::optional<int> = {[contained value] = 5}} } }
+// { dg-final { note-test oi {std::optional = {[contained value] = 5}} } }
optional<void*> op{nullptr};
-// { dg-final { note-test op {std::optional<void *> = {[contained value] = 0x0}} } }
+// { dg-final { note-test op {std::optional = {[contained value] = 0x0}} } }
optional<std::map<int, double>> om;
om = std::map<int, double>{ {1, 2.}, {3, 4.}, {5, 6.} };
-// { dg-final { regexp-test om {std::optional<std::(__debug::)?map<int, double>> containing std::(__debug::)?map with 3 elements = {\[1\] = 2, \[3\] = 4, \[5\] = 6}} } }
+// { dg-final { regexp-test om {std::optional containing std::(__debug::)?map with 3 elements = {\[1\] = 2, \[3\] = 4, \[5\] = 6}} } }
optional<std::string> os{ "stringy" };
-// { dg-final { note-test os {std::optional<std::string> = {[contained value] = "stringy"}} } }
+// { dg-final { note-test os {std::optional = {[contained value] = "stringy"}} } }
any a;
// { dg-final { note-test a {std::any [no contained value]} } }
@@ -86,18 +83,18 @@ main()
struct S { operator int() { throw 42; }};
variant<float, int, string_view> v0;
-// { dg-final { note-test v0 {std::variant<float, int, std::string_view> [index 0] = {0}} } }
+// { dg-final { note-test v0 {std::variant [index 0] = {0}} } }
variant<float, int, string_view> v1{ 0.5f };
-// { dg-final { note-test v1 {std::variant<float, int, std::string_view> [index 0] = {0.5}} } }
+// { dg-final { note-test v1 {std::variant [index 0] = {0.5}} } }
variant<float, X, string_view> v2;
try {
v2.emplace<1>(S());
} catch (int) { }
-// { dg-final { note-test v2 {std::variant<float, X, std::string_view> [no contained value]} } }
+// { dg-final { note-test v2 {std::variant [no contained value]} } }
variant<float, int, string_view> v3{ 3 };
-// { dg-final { note-test v3 {std::variant<float, int, std::string_view> [index 1] = {3}} } }
+// { dg-final { note-test v3 {std::variant [index 1] = {3}} } }
variant<float, int, string_view> v4{ str };
-// { dg-final { note-test v4 {std::variant<float, int, std::string_view> [index 2] = {"string"}} } }
+// { dg-final { note-test v4 {std::variant [index 2] = {"string"}} } }
map<int, string_view> m{ {1, "one"} };
map<int, string_view>::node_type n0;
diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/filesystem-ts.cc b/libstdc++-v3/testsuite/libstdc++-prettyprinters/filesystem-ts.cc
index 00d100bd066..3221f2df90d 100644
--- a/libstdc++-v3/testsuite/libstdc++-prettyprinters/filesystem-ts.cc
+++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/filesystem-ts.cc
@@ -2,7 +2,7 @@
// { dg-do run { target c++11 } }
// { dg-require-filesystem-ts "" }
-// Copyright (C) 2020-2021 Free Software Foundation, Inc.
+// Copyright (C) 2020-2025 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/libfundts.cc b/libstdc++-v3/testsuite/libstdc++-prettyprinters/libfundts.cc
index 85005c0617f..bfb86885457 100644
--- a/libstdc++-v3/testsuite/libstdc++-prettyprinters/libfundts.cc
+++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/libfundts.cc
@@ -1,7 +1,7 @@
// { dg-do run { target c++14 } }
// { dg-options "-g -O0" }
-// Copyright (C) 2014-2021 Free Software Foundation, Inc.
+// Copyright (C) 2014-2025 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@@ -18,9 +18,6 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// Type printers only recognize the old std::string for now.
-#define _GLIBCXX_USE_CXX11_ABI 0
-
#include <experimental/any>
#include <experimental/optional>
#include <experimental/string_view>
@@ -35,22 +32,28 @@ using std::experimental::string_view;
int
main()
{
+ // Ensure debug info for std::string is issued in the local
+ // translation unit, so that GDB won't pick up any alternate
+ // std::string notion that might be present in libstdc++.so.
+ std::string bah = "hi";
+ (void)bah;
+
string_view str = "string";
// { dg-final { note-test str "\"string\"" } }
optional<int> o;
-// { dg-final { note-test o {std::experimental::optional<int> [no contained value]} } }
+// { dg-final { note-test o {std::experimental::optional [no contained value]} } }
optional<bool> ob{false};
-// { dg-final { note-test ob {std::experimental::optional<bool> = {[contained value] = false}} } }
+// { dg-final { note-test ob {std::experimental::optional = {[contained value] = false}} } }
optional<int> oi{5};
-// { dg-final { note-test oi {std::experimental::optional<int> = {[contained value] = 5}} } }
+// { dg-final { note-test oi {std::experimental::optional = {[contained value] = 5}} } }
optional<void*> op{nullptr};
-// { dg-final { note-test op {std::experimental::optional<void *> = {[contained value] = 0x0}} } }
+// { dg-final { note-test op {std::experimental::optional = {[contained value] = 0x0}} } }
optional<std::map<int, double>> om;
om = std::map<int, double>{ {1, 2.}, {3, 4.}, {5, 6.} };
-// { dg-final { regexp-test om {std::experimental::optional<std::(__debug::)?map<int, double>> containing std::(__debug::)?map with 3 elements = {\[1\] = 2, \[3\] = 4, \[5\] = 6}} } }
+// { dg-final { regexp-test om {std::experimental::optional containing std::(__debug::)?map with 3 elements = {\[1\] = 2, \[3\] = 4, \[5\] = 6}} } }
optional<std::string> os{ "stringy" };
-// { dg-final { note-test os {std::experimental::optional<std::string> = {[contained value] = "stringy"}} { xfail { c++20 || debug_mode } } } }
+// { dg-final { note-test os {std::experimental::optional = {[contained value] = "stringy"}} } }
any a;
// { dg-final { note-test a {std::experimental::any [no contained value]} } }
@@ -61,7 +64,7 @@ main()
any ap = (void*)nullptr;
// { dg-final { note-test ap {std::experimental::any containing void * = {[contained value] = 0x0}} } }
any as = *os;
-// { dg-final { note-test as {std::experimental::any containing std::string = {[contained value] = "stringy"}} { xfail { c++20 || debug_mode } } } }
+// { dg-final { note-test as {std::experimental::any containing std::string = {[contained value] = "stringy"}} } }
any as2("stringiest");
// { dg-final { regexp-test as2 {std::experimental::any containing const char \* = {\[contained value\] = 0x[[:xdigit:]]+ "stringiest"}} } }
any am = *om;

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,75 @@
#!/bin/bash
if [ "x$1" != "x" ] && ! [ -d "$1" ]; then
echo "Usage: $0 [git_reference_dir_to_speed_up]"
exit 1
fi
# Variables to set up for a new GTS update.
# The latest GTS supported on this branch.
gts_major=15
# Tests that need to be synced in for this change. These are required to sync
# in adjustments to tests due to changes to pretty printer output.
# Occasionally, a test adjustment may be due to an ABI change, in which case
# the test may fail with the system gcc, since we do not backport ABI changes.
# This is expected, in which case we adjust back the expected output for the
# test to match the system libstdc++ ABI in a subsequent, hand-written patch to
# the tests.
tests="
filesystem-ts.cc
compat.cc
cxx11.cc
cxx17.cc
libfundts.cc
"
system_major=`sed -n 's/^%global gcc_major //p' gcc.spec`
systemrev=`sed -n 's/^%global gitrev //p' gcc.spec`
if [ $gts_major -eq $system_major ]; then echo "GTS same version as system, nothing to do."; exit 1; fi
if ! [ -f gcc.spec ]; then echo Must be run in the directory with gcc.spec file.; exit 1; fi
branch=`git branch --show-current`
if ! [[ $branch =~ ^c[0-9]+s$ ]]; then echo "Must be run on a valid centos stream branch, not '$branch'"; exit 1; fi
gtsrev=`curl -s https://gitlab.com/redhat/centos-stream/rpms/gcc-toolset-$gts_major-gcc/-/raw/$(git branch --show-current)/gcc-toolset-15-gcc.spec?ref_type=heads | sed -n 's/^%global gitrev //p'`
echo "system at $systemrev and GTS at $gtsrev on the vendor branch"
cwd=$PWD
cleanup() {
rm -rf $cwd/gcc-dir.tmp
}
trap cleanup EXIT
# Get vendor branch contents from upstream. git-fetch doesn't have the
# --reference feature, so do a full clone referencing a local upstream repo if
# present. Otherwise fetch only those specific refs.
url=https://gcc.gnu.org/git/gcc.git
echo -n "Getting sources from $url"
if [ "$#" -eq 1 ]; then
echo " (using $1 as cache)"
git clone -q --dissociate --reference $1 $url gcc-dir.tmp
pushd gcc-dir.tmp
else
echo
mkdir gcc-dir.tmp
pushd gcc-dir.tmp
git init -q
git remote add origin $url
fi
pp_patchfile=gcc$system_major-libstdc++-prettyprinter-update-$gts_major.patch
tests_patchfile=gcc$system_major-libstdc++-prettyprinter-update-$gts_major-tests.patch
git fetch -q origin $systemrev $gtsrev
# We limit the update to just the printer, retain the system gcc hook and
# make-foo.
git diff --stat --patch $systemrev..$gtsrev -- libstdc++-v3/python/libstdcxx > ../$pp_patchfile
echo "Updated $pp_patchfile"
testfiles=$(echo "$tests" | awk '/.+/{printf "libstdc++-v3/testsuite/libstdc++-prettyprinters/%s ", $1}')
git diff --stat --patch $systemrev..$gtsrev -- $testfiles > ../$tests_patchfile
echo "Updated $tests_patchfile"
popd