From c6977f765838a5ca8d321d916221a7368622bdd9 Mon Sep 17 00:00:00 2001
From: Andreas Schwab <schwab@suse.de>
Date: Tue, 21 Jan 2025 23:50:15 +0100
Subject: [PATCH] libstdc++: correct symbol version of typeinfo for bfloat16_t
 on RISC-V

RISC-V only gained support for bfloat16_t after gcc 14.  Passes
libstdc++/check_abi on {x86_64,aarch64,ppc64le,riscv64,s390x}-suse-linux.

	PR libstdc++/118563
	* testsuite/util/testsuite_abi.cc (check_version): Add
	CXXABI_1.3.16.
	* config/abi/pre/gnu.ver (CXXABI_1.3.14) [__riscv]: Exclude
	typeinfo for bfloat16_t.
	(CXXABI_1.3.16) [__riscv]: Add it here.
---
 libstdc++-v3/config/abi/pre/gnu.ver          | 23 ++++++++++++++++----
 libstdc++-v3/testsuite/util/testsuite_abi.cc |  1 +
 2 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver
index f7641974ec4d..84ce874fe036 100644
--- a/libstdc++-v3/config/abi/pre/gnu.ver
+++ b/libstdc++-v3/config/abi/pre/gnu.ver
@@ -2852,10 +2852,15 @@ CXXABI_1.3.13 {
 CXXABI_1.3.14 {
 
     # typeinfo for _Float{16,32,64,128,32x,64x,128x} and
-    # __bf16
-    _ZTIDF[0-9]*[_bx];
-    _ZTIPDF[0-9]*[_bx];
-    _ZTIPKDF[0-9]*[_bx];
+    # __bf16/bfloat16_t
+    _ZTIDF[0-9]*[_x];
+    _ZTIPDF[0-9]*[_x];
+    _ZTIPKDF[0-9]*[_x];
+#ifndef __riscv
+    _ZTIDF16b;
+    _ZTIPDF16b;
+    _ZTIPKDF16b;
+#endif
     _ZTIu6__bf16;
     _ZTIPu6__bf16;
     _ZTIPKu6__bf16;
@@ -2869,6 +2874,16 @@ CXXABI_1.3.15 {
 
 } CXXABI_1.3.14;
 
+CXXABI_1.3.16 {
+
+#ifdef __riscv
+    _ZTIDF16b;
+    _ZTIPDF16b;
+    _ZTIPKDF16b;
+#endif
+
+} CXXABI_1.3.15;
+
 # Symbols in the support library (libsupc++) supporting transactional memory.
 CXXABI_TM_1 {
 
diff --git a/libstdc++-v3/testsuite/util/testsuite_abi.cc b/libstdc++-v3/testsuite/util/testsuite_abi.cc
index dcf5b1a4e0b1..0d6080fb92c0 100644
--- a/libstdc++-v3/testsuite/util/testsuite_abi.cc
+++ b/libstdc++-v3/testsuite/util/testsuite_abi.cc
@@ -237,6 +237,7 @@ check_version(symbol& test, bool added)
       known_versions.push_back("CXXABI_1.3.13");
       known_versions.push_back("CXXABI_1.3.14");
       known_versions.push_back("CXXABI_1.3.15");
+      known_versions.push_back("CXXABI_1.3.16");
       known_versions.push_back("CXXABI_IEEE128_1.3.13");
       known_versions.push_back("CXXABI_TM_1");
       known_versions.push_back("CXXABI_FLOAT128");
-- 
GitLab