libstdc++: Fix gnu.ver CXXABI_1.3.16 for Solaris [PR118701]

Message ID yddpljxlvwg.fsf@CeBiTec.Uni-Bielefeld.DE
State New
Headers
Series libstdc++: Fix gnu.ver CXXABI_1.3.16 for Solaris [PR118701] |

Checks

Context Check Description
rivoscibot/toolchain-ci-rivos-lint warning Lint failed
rivoscibot/toolchain-ci-rivos-apply-patch success Patch applied
rivoscibot/toolchain-ci-rivos-build--newlib-rv64gcv-lp64d-multilib success Build passed
rivoscibot/toolchain-ci-rivos-build--linux-rv64gcv-lp64d-multilib success Build passed
rivoscibot/toolchain-ci-rivos-build--linux-rv64gc_zba_zbb_zbc_zbs-lp64d-multilib success Build passed
linaro-tcwg-bot/tcwg_gcc_build--master-arm success Build passed
rivoscibot/toolchain-ci-rivos-test success Testing passed
linaro-tcwg-bot/tcwg_gcc_check--master-arm success Test passed
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_gcc_check--master-aarch64 success Test passed

Commit Message

Rainer Orth Feb. 4, 2025, 12:46 p.m. UTC
  This patch

commit c6977f765838a5ca8d321d916221a7368622bdd9
Author: Andreas Schwab <schwab@suse.de>
Date:   Tue Jan 21 23:50:15 2025 +0100

    libstdc++: correct symbol version of typeinfo for bfloat16_t on RISC-V

broke the libstdc++-abi/abi_check test on Solaris: the log shows

1 incompatible symbols
0
Argument "{CXXABI_1.3.15}" isn't numeric in numeric eq (==) at /vol/gcc/src/hg/master/local/libstdc++-v3/scripts/extract_symvers.pl line 129.
version status: incompatible
type: uncategorized
status: added

The problem has two parts:

* The patch above introduced a new version in libstdc++.so,
  CXXABI_1.3.16, which everywhere but on RISC-V contains no symbols (a
  weak version).  This is the first time this happened in libstdc++.

* Solaris uses scripts/extract_symvers.pl to determine the version info.
  The script currently chokes on the pvs output for weak versions:

  libstdc++.so.6.0.34 -	CXXABI_1.3.16 [WEAK]: {CXXABI_1.3.15};

  instead of

  libstdc++.so.6.0.34 -	CXXABI_1.3.16: {CXXABI_1.3.15};

While this patch hardens the script to cope with weak versions, there's
no reason to introduce them in the first place.  So the new version is
only created on __riscv.

Tested on i386-pc-solaris2.11, sparc-sun-solaris2.11, and
x86_64-pc-linux-gnu.

Ok for trunk?

	Rainer
  

Comments

Jonathan Wakely Feb. 4, 2025, 1:08 p.m. UTC | #1
On Tue, 4 Feb 2025 at 12:48, Rainer Orth <ro@cebitec.uni-bielefeld.de> wrote:
>
> This patch
>
> commit c6977f765838a5ca8d321d916221a7368622bdd9
> Author: Andreas Schwab <schwab@suse.de>
> Date:   Tue Jan 21 23:50:15 2025 +0100
>
>     libstdc++: correct symbol version of typeinfo for bfloat16_t on RISC-V
>
> broke the libstdc++-abi/abi_check test on Solaris: the log shows
>
> 1 incompatible symbols
> 0
> Argument "{CXXABI_1.3.15}" isn't numeric in numeric eq (==) at /vol/gcc/src/hg/master/local/libstdc++-v3/scripts/extract_symvers.pl line 129.
> version status: incompatible
> type: uncategorized
> status: added
>
> The problem has two parts:
>
> * The patch above introduced a new version in libstdc++.so,
>   CXXABI_1.3.16, which everywhere but on RISC-V contains no symbols (a
>   weak version).  This is the first time this happened in libstdc++.
>
> * Solaris uses scripts/extract_symvers.pl to determine the version info.
>   The script currently chokes on the pvs output for weak versions:
>
>   libstdc++.so.6.0.34 - CXXABI_1.3.16 [WEAK]: {CXXABI_1.3.15};
>
>   instead of
>
>   libstdc++.so.6.0.34 - CXXABI_1.3.16: {CXXABI_1.3.15};
>
> While this patch hardens the script to cope with weak versions, there's
> no reason to introduce them in the first place.  So the new version is
> only created on __riscv.
>
> Tested on i386-pc-solaris2.11, sparc-sun-solaris2.11, and
> x86_64-pc-linux-gnu.
>
> Ok for trunk?

I think this will cause check-abi failures on risc-v because the new
symbols are added to CXXABI_1.3.16 but the "latest_p" map says that
new symbols (i.e. ones not present in the baseline_symbols.txt file)
should be in CXXABI_1.3.15

So either this needs another change to testsuite_abi.cc (I think I
gave the required change in the bugzilla PR) or somebody needs to
regenerate baseline_symbols.txt for risc-v, so that there are no "new"
symbols.
  
Andreas Schwab Feb. 4, 2025, 2:19 p.m. UTC | #2
On Feb 04 2025, Jonathan Wakely wrote:

> I think this will cause check-abi failures on risc-v because the new
> symbols are added to CXXABI_1.3.16 but the "latest_p" map says that
> new symbols (i.e. ones not present in the baseline_symbols.txt file)
> should be in CXXABI_1.3.15

There is effectively no change for __riscv with this patch.  latestp
already requires that new symbols are added to CXXABI_1.3.16, since
CXXABI_1.3.15 is finalized for gcc 14.

> So either this needs another change to testsuite_abi.cc (I think I
> gave the required change in the bugzilla PR) or somebody needs to
> regenerate baseline_symbols.txt for risc-v, so that there are no "new"
> symbols.

All other new symbols will be in GLIBCXX_3.4.34 (as required by
latestp), not CXXABI_1.3.16.
  
Jonathan Wakely Feb. 4, 2025, 2:24 p.m. UTC | #3
On Tue, 4 Feb 2025 at 14:19, Andreas Schwab <schwab@suse.de> wrote:
>
> On Feb 04 2025, Jonathan Wakely wrote:
>
> > I think this will cause check-abi failures on risc-v because the new
> > symbols are added to CXXABI_1.3.16 but the "latest_p" map says that
> > new symbols (i.e. ones not present in the baseline_symbols.txt file)
> > should be in CXXABI_1.3.15
>
> There is effectively no change for __riscv with this patch.  latestp
> already requires that new symbols are added to CXXABI_1.3.16, since
> CXXABI_1.3.15 is finalized for gcc 14.

Ah yes, of course. The patch is OK for trunk then.

> > So either this needs another change to testsuite_abi.cc (I think I
> > gave the required change in the bugzilla PR) or somebody needs to
> > regenerate baseline_symbols.txt for risc-v, so that there are no "new"
> > symbols.
>
> All other new symbols will be in GLIBCXX_3.4.34 (as required by
> latestp), not CXXABI_1.3.16.
>
> --
> Andreas Schwab, SUSE Labs, schwab@suse.de
> GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
> "And now for something completely different."
>
  

Patch

# HG changeset patch
# Parent  e0fa5f4cec60bf46c3ad06a24736fad729d509e0
libstdc++: Fix gnu.ver CXXABI_1.3.16 for Solaris

diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver
--- a/libstdc++-v3/config/abi/pre/gnu.ver
+++ b/libstdc++-v3/config/abi/pre/gnu.ver
@@ -2874,15 +2874,15 @@  CXXABI_1.3.15 {
 
 } CXXABI_1.3.14;
 
+#ifdef __riscv
 CXXABI_1.3.16 {
 
-#ifdef __riscv
     _ZTIDF16b;
     _ZTIPDF16b;
     _ZTIPKDF16b;
-#endif
 
 } CXXABI_1.3.15;
+#endif
 
 # Symbols in the support library (libsupc++) supporting transactional memory.
 CXXABI_TM_1 {
diff --git a/libstdc++-v3/scripts/extract_symvers.pl b/libstdc++-v3/scripts/extract_symvers.pl
--- a/libstdc++-v3/scripts/extract_symvers.pl
+++ b/libstdc++-v3/scripts/extract_symvers.pl
@@ -34,8 +34,18 @@  while (<PVS>) {
     # Remove trailing semicolon.
     s/;$//;
 
-    # shared object, dash, version, symbol, [size]
-    (undef, undef, $version, $symbol, $size) = split;
+    if (/\[WEAK\]/) {
+	# Allow for weak versions like
+	# libstdc++.so.6.0.34 -	CXXABI_1.3.16 [WEAK]: {CXXABI_1.3.15};
+	#
+	# shared object, dash, version "[WEAK]", symbol, [size]
+	(undef, undef, $version, undef, $symbol, $size) = split;
+    } else {
+	# libstdc++.so.6.0.34 -	CXXABI_1.3.16: {CXXABI_1.3.15};
+	#
+	# shared object, dash, version, symbol, [size]
+	(undef, undef, $version, $symbol, $size) = split;
+    }
 
     # Remove colon separator from version field.
     $version =~ s/:$//;
diff --git a/libstdc++-v3/testsuite/util/testsuite_abi.cc b/libstdc++-v3/testsuite/util/testsuite_abi.cc
--- a/libstdc++-v3/testsuite/util/testsuite_abi.cc
+++ b/libstdc++-v3/testsuite/util/testsuite_abi.cc
@@ -237,7 +237,9 @@  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");
+#ifdef __riscv
       known_versions.push_back("CXXABI_1.3.16");
+#endif
       known_versions.push_back("CXXABI_IEEE128_1.3.13");
       known_versions.push_back("CXXABI_TM_1");
       known_versions.push_back("CXXABI_FLOAT128");