libstdc++: Fix up abi.exp FAILs on powerpc64le-linux

Message ID ZFKtuNYTXlDlSBYC@tucnak
State Unresolved
Headers
Series libstdc++: Fix up abi.exp FAILs on powerpc64le-linux |

Checks

Context Check Description
snail/gcc-patch-check warning Git am fail log

Commit Message

Jakub Jelinek May 3, 2023, 6:53 p.m. UTC
  Hi!

This is an ABI problem on powerpc64le-linux, introduced in 13.1.
When libstdc++ is configured against old glibc, the
_ZSt10from_charsPKcS0_RDF128_St12chars_format@@GLIBCXX_3.4.31
_ZSt8to_charsPcS_DF128_@@GLIBCXX_3.4.31
_ZSt8to_charsPcS_DF128_St12chars_format@@GLIBCXX_3.4.31
_ZSt8to_charsPcS_DF128_St12chars_formati@@GLIBCXX_3.4.31
symbols are exported from the library, while when it is configured against
new enough glibc, those symbols aren't exported and we export instead
_ZSt10from_charsPKcS0_Ru9__ieee128St12chars_format@@GLIBCXX_IEEE128_3.4.29
_ZSt8to_charsPcS_u9__ieee128@@GLIBCXX_IEEE128_3.4.29
_ZSt8to_charsPcS_u9__ieee128St12chars_format@@GLIBCXX_IEEE128_3.4.29
_ZSt8to_charsPcS_u9__ieee128St12chars_formati@@GLIBCXX_IEEE128_3.4.29
together with various other @@GLIBCXX_IEEE128_3.4.{29,30,31} and
@@CXXABI_IEEE128_1.3.13 symbols.  The idea was that those *IEEE128* symbol
versions (similarly to *LDBL* symbol versions) are optional (but if it
appears, all symbols from it up to the version of the library appears),
but the base appears always.
My _Float128 from_chars/to_chars changes unfortunately broke this.
I believe nothing really uses those symbols if libstdc++ has been
configured against old glibc, so if 13.1 wasn't already released, it might
be best to make sure they aren't exported on powerpc64le-linux.
But as they were exported, I think the best resolution for this ABI
difference is to add those 4 symbols as aliases to the
GLIBCXX_IEEE128_3.4.29 *u9__ieee128* symbols, which the following patch
does.

Tested on powerpc64le-linux (both configured against glibc 2.36 and 2.17)
and powerpc64-linux (configured against glibc 2.17), ok for trunk?

2023-05-03  Jakub Jelinek  <jakub@redhat.com>

	* src/c++17/floating_from_chars.cc
	(_ZSt10from_charsPKcS0_RDF128_St12chars_format): New alias to
	_ZSt10from_charsPKcS0_Ru9__ieee128St12chars_format.
	* src/c++17/floating_to_chars.cc (_ZSt8to_charsPcS_DF128_): New alias to
	_ZSt8to_charsPcS_u9__ieee128.
	(_ZSt8to_charsPcS_DF128_St12chars_format): New alias to
	_ZSt8to_charsPcS_u9__ieee128St12chars_format.
	(_ZSt8to_charsPcS_DF128_St12chars_formati): New alias to
	_ZSt8to_charsPcS_u9__ieee128St12chars_formati.
	* config/abi/post/powerpc64le-linux-gnu/baseline_symbols.txt: Updated.


	Jakub
  

Comments

Jonathan Wakely May 3, 2023, 7:56 p.m. UTC | #1
On Wed, 3 May 2023 at 19:55, Jakub Jelinek via Libstdc++
<libstdc++@gcc.gnu.org> wrote:
>
> Hi!
>
> This is an ABI problem on powerpc64le-linux, introduced in 13.1.
> When libstdc++ is configured against old glibc, the
> _ZSt10from_charsPKcS0_RDF128_St12chars_format@@GLIBCXX_3.4.31
> _ZSt8to_charsPcS_DF128_@@GLIBCXX_3.4.31
> _ZSt8to_charsPcS_DF128_St12chars_format@@GLIBCXX_3.4.31
> _ZSt8to_charsPcS_DF128_St12chars_formati@@GLIBCXX_3.4.31
> symbols are exported from the library, while when it is configured against
> new enough glibc, those symbols aren't exported and we export instead
> _ZSt10from_charsPKcS0_Ru9__ieee128St12chars_format@@GLIBCXX_IEEE128_3.4.29
> _ZSt8to_charsPcS_u9__ieee128@@GLIBCXX_IEEE128_3.4.29
> _ZSt8to_charsPcS_u9__ieee128St12chars_format@@GLIBCXX_IEEE128_3.4.29
> _ZSt8to_charsPcS_u9__ieee128St12chars_formati@@GLIBCXX_IEEE128_3.4.29
> together with various other @@GLIBCXX_IEEE128_3.4.{29,30,31} and
> @@CXXABI_IEEE128_1.3.13 symbols.  The idea was that those *IEEE128* symbol
> versions (similarly to *LDBL* symbol versions) are optional (but if it
> appears, all symbols from it up to the version of the library appears),
> but the base appears always.
> My _Float128 from_chars/to_chars changes unfortunately broke this.
> I believe nothing really uses those symbols if libstdc++ has been
> configured against old glibc, so if 13.1 wasn't already released, it might
> be best to make sure they aren't exported on powerpc64le-linux.
> But as they were exported, I think the best resolution for this ABI
> difference is to add those 4 symbols as aliases to the
> GLIBCXX_IEEE128_3.4.29 *u9__ieee128* symbols, which the following patch
> does.
>
> Tested on powerpc64le-linux (both configured against glibc 2.36 and 2.17)
> and powerpc64-linux (configured against glibc 2.17), ok for trunk?

Do we want a #pragma to suppress -Wattribute-alias here?


>
> 2023-05-03  Jakub Jelinek  <jakub@redhat.com>
>
>         * src/c++17/floating_from_chars.cc
>         (_ZSt10from_charsPKcS0_RDF128_St12chars_format): New alias to
>         _ZSt10from_charsPKcS0_Ru9__ieee128St12chars_format.
>         * src/c++17/floating_to_chars.cc (_ZSt8to_charsPcS_DF128_): New alias to
>         _ZSt8to_charsPcS_u9__ieee128.
>         (_ZSt8to_charsPcS_DF128_St12chars_format): New alias to
>         _ZSt8to_charsPcS_u9__ieee128St12chars_format.
>         (_ZSt8to_charsPcS_DF128_St12chars_formati): New alias to
>         _ZSt8to_charsPcS_u9__ieee128St12chars_formati.
>         * config/abi/post/powerpc64le-linux-gnu/baseline_symbols.txt: Updated.
>
> --- libstdc++-v3/src/c++17/floating_from_chars.cc.jj    2023-04-13 23:00:36.125459347 +0200
> +++ libstdc++-v3/src/c++17/floating_from_chars.cc       2023-05-03 17:24:45.121600206 +0200
> @@ -1272,6 +1272,13 @@ from_chars(const char* first, const char
>    // fast_float doesn't support IEEE binary128 format, but we can use strtold.
>    return from_chars_strtod(first, last, value, fmt);
>  }
> +
> +extern "C" from_chars_result
> +_ZSt10from_charsPKcS0_RDF128_St12chars_format(const char* first,
> +                                             const char* last,
> +                                             __ieee128& value,
> +                                             chars_format fmt) noexcept
> +__attribute__((alias ("_ZSt10from_charsPKcS0_Ru9__ieee128St12chars_format")));
>  #elif defined(USE_STRTOF128_FOR_FROM_CHARS)
>  from_chars_result
>  from_chars(const char* first, const char* last, _Float128& value,
> --- libstdc++-v3/src/c++17/floating_to_chars.cc.jj      2023-01-16 23:19:06.284716774 +0100
> +++ libstdc++-v3/src/c++17/floating_to_chars.cc 2023-05-03 17:12:16.766877278 +0200
> @@ -1851,6 +1851,23 @@ to_chars(char* first, char* last, __floa
>  {
>    return __floating_to_chars_precision(first, last, value, fmt, precision);
>  }
> +
> +extern "C" to_chars_result
> +_ZSt8to_charsPcS_DF128_(char* first, char* last, __float128 value) noexcept
> +  __attribute__((alias ("_ZSt8to_charsPcS_u9__ieee128")));
> +
> +extern "C" to_chars_result
> +_ZSt8to_charsPcS_DF128_St12chars_format(char* first, char* last,
> +                                       __float128 value,
> +                                       chars_format fmt) noexcept
> +  __attribute__((alias ("_ZSt8to_charsPcS_u9__ieee128St12chars_format")));
> +
> +extern "C" to_chars_result
> +_ZSt8to_charsPcS_DF128_St12chars_formati(char* first, char* last,
> +                                        __float128 value,
> +                                        chars_format fmt,
> +                                        int precision) noexcept
> +  __attribute__((alias ("_ZSt8to_charsPcS_u9__ieee128St12chars_formati")));
>  #else
>  to_chars_result
>  to_chars(char* first, char* last, _Float128 value) noexcept
> --- libstdc++-v3/config/abi/post/powerpc64le-linux-gnu/baseline_symbols.txt.jj  2023-05-02 19:27:47.538504941 +0200
> +++ libstdc++-v3/config/abi/post/powerpc64le-linux-gnu/baseline_symbols.txt     2023-05-03 19:06:33.389469841 +0200
> @@ -4491,6 +4491,7 @@ FUNC:_ZNSt9type_infoD1Ev@@GLIBCXX_3.4
>  FUNC:_ZNSt9type_infoD2Ev@@GLIBCXX_3.4
>  FUNC:_ZNVSt9__atomic011atomic_flag12test_and_setESt12memory_order@@GLIBCXX_3.4.11
>  FUNC:_ZNVSt9__atomic011atomic_flag5clearESt12memory_order@@GLIBCXX_3.4.11
> +FUNC:_ZSt10from_charsPKcS0_RDF128_St12chars_format@@GLIBCXX_3.4.31
>  FUNC:_ZSt10from_charsPKcS0_RdSt12chars_format@@GLIBCXX_3.4.29
>  FUNC:_ZSt10from_charsPKcS0_ReSt12chars_format@@GLIBCXX_3.4.29
>  FUNC:_ZSt10from_charsPKcS0_RfSt12chars_format@@GLIBCXX_3.4.29
> @@ -4641,6 +4642,9 @@ FUNC:_ZSt7getlineIwSt11char_traitsIwESaI
>  FUNC:_ZSt7getlineIwSt11char_traitsIwESaIwEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EES4_@@GLIBCXX_3.4.21
>  FUNC:_ZSt7getlineIwSt11char_traitsIwESaIwEERSt13basic_istreamIT_T0_ES7_RSbIS4_S5_T1_E@@GLIBCXX_3.4
>  FUNC:_ZSt7getlineIwSt11char_traitsIwESaIwEERSt13basic_istreamIT_T0_ES7_RSbIS4_S5_T1_ES4_@@GLIBCXX_3.4
> +FUNC:_ZSt8to_charsPcS_DF128_@@GLIBCXX_3.4.31
> +FUNC:_ZSt8to_charsPcS_DF128_St12chars_format@@GLIBCXX_3.4.31
> +FUNC:_ZSt8to_charsPcS_DF128_St12chars_formati@@GLIBCXX_3.4.31
>  FUNC:_ZSt8to_charsPcS_d@@GLIBCXX_3.4.29
>  FUNC:_ZSt8to_charsPcS_dSt12chars_format@@GLIBCXX_3.4.29
>  FUNC:_ZSt8to_charsPcS_dSt12chars_formati@@GLIBCXX_3.4.29
>
>         Jakub
>
  
Jakub Jelinek May 3, 2023, 8:06 p.m. UTC | #2
On Wed, May 03, 2023 at 08:56:40PM +0100, Jonathan Wakely wrote:
> Do we want a #pragma to suppress -Wattribute-alias here?

I think that isn't needed, as the aliases use the same argument types
as the functions they are aliasing (did that because other
aliases in those files do it that way as well).
Other possibility would be
#pragma GCC diagnostic ignored "-Wattribute-alias"
from_chars_result
from_chars(const char* first, const char* last, _Float128& value,
	   chars_format fmt) noexcept
__attribute__((alias ("_ZSt10from_charsPKcS0_Ru9__ieee128St12chars_format")));
instead of the below snippet etc. (but as I said, I went for consistency).

> > --- libstdc++-v3/src/c++17/floating_from_chars.cc.jj    2023-04-13 23:00:36.125459347 +0200
> > +++ libstdc++-v3/src/c++17/floating_from_chars.cc       2023-05-03 17:24:45.121600206 +0200
> > @@ -1272,6 +1272,13 @@ from_chars(const char* first, const char
> >    // fast_float doesn't support IEEE binary128 format, but we can use strtold.
> >    return from_chars_strtod(first, last, value, fmt);
> >  }
> > +
> > +extern "C" from_chars_result
> > +_ZSt10from_charsPKcS0_RDF128_St12chars_format(const char* first,
> > +                                             const char* last,
> > +                                             __ieee128& value,
> > +                                             chars_format fmt) noexcept
> > +__attribute__((alias ("_ZSt10from_charsPKcS0_Ru9__ieee128St12chars_format")));
> >  #elif defined(USE_STRTOF128_FOR_FROM_CHARS)
> >  from_chars_result
> >  from_chars(const char* first, const char* last, _Float128& value,

	Jakub
  
Jonathan Wakely May 3, 2023, 8:14 p.m. UTC | #3
On Wed, 3 May 2023 at 21:06, Jakub Jelinek <jakub@redhat.com> wrote:
>
> On Wed, May 03, 2023 at 08:56:40PM +0100, Jonathan Wakely wrote:
> > Do we want a #pragma to suppress -Wattribute-alias here?
>
> I think that isn't needed, as the aliases use the same argument types
> as the functions they are aliasing (did that because other
> aliases in those files do it that way as well).
> Other possibility would be
> #pragma GCC diagnostic ignored "-Wattribute-alias"
> from_chars_result
> from_chars(const char* first, const char* last, _Float128& value,
>            chars_format fmt) noexcept
> __attribute__((alias ("_ZSt10from_charsPKcS0_Ru9__ieee128St12chars_format")));
> instead of the below snippet etc. (but as I said, I went for consistency).

Oh yes, they're the same type.

OK for trunk then, thanks!
  

Patch

--- libstdc++-v3/src/c++17/floating_from_chars.cc.jj	2023-04-13 23:00:36.125459347 +0200
+++ libstdc++-v3/src/c++17/floating_from_chars.cc	2023-05-03 17:24:45.121600206 +0200
@@ -1272,6 +1272,13 @@  from_chars(const char* first, const char
   // fast_float doesn't support IEEE binary128 format, but we can use strtold.
   return from_chars_strtod(first, last, value, fmt);
 }
+
+extern "C" from_chars_result
+_ZSt10from_charsPKcS0_RDF128_St12chars_format(const char* first,
+					      const char* last,
+					      __ieee128& value,
+					      chars_format fmt) noexcept
+__attribute__((alias ("_ZSt10from_charsPKcS0_Ru9__ieee128St12chars_format")));
 #elif defined(USE_STRTOF128_FOR_FROM_CHARS)
 from_chars_result
 from_chars(const char* first, const char* last, _Float128& value,
--- libstdc++-v3/src/c++17/floating_to_chars.cc.jj	2023-01-16 23:19:06.284716774 +0100
+++ libstdc++-v3/src/c++17/floating_to_chars.cc	2023-05-03 17:12:16.766877278 +0200
@@ -1851,6 +1851,23 @@  to_chars(char* first, char* last, __floa
 {
   return __floating_to_chars_precision(first, last, value, fmt, precision);
 }
+
+extern "C" to_chars_result
+_ZSt8to_charsPcS_DF128_(char* first, char* last, __float128 value) noexcept
+  __attribute__((alias ("_ZSt8to_charsPcS_u9__ieee128")));
+
+extern "C" to_chars_result
+_ZSt8to_charsPcS_DF128_St12chars_format(char* first, char* last,
+					__float128 value,
+					chars_format fmt) noexcept
+  __attribute__((alias ("_ZSt8to_charsPcS_u9__ieee128St12chars_format")));
+
+extern "C" to_chars_result
+_ZSt8to_charsPcS_DF128_St12chars_formati(char* first, char* last,
+					 __float128 value,
+					 chars_format fmt,
+					 int precision) noexcept
+  __attribute__((alias ("_ZSt8to_charsPcS_u9__ieee128St12chars_formati")));
 #else
 to_chars_result
 to_chars(char* first, char* last, _Float128 value) noexcept
--- libstdc++-v3/config/abi/post/powerpc64le-linux-gnu/baseline_symbols.txt.jj	2023-05-02 19:27:47.538504941 +0200
+++ libstdc++-v3/config/abi/post/powerpc64le-linux-gnu/baseline_symbols.txt	2023-05-03 19:06:33.389469841 +0200
@@ -4491,6 +4491,7 @@  FUNC:_ZNSt9type_infoD1Ev@@GLIBCXX_3.4
 FUNC:_ZNSt9type_infoD2Ev@@GLIBCXX_3.4
 FUNC:_ZNVSt9__atomic011atomic_flag12test_and_setESt12memory_order@@GLIBCXX_3.4.11
 FUNC:_ZNVSt9__atomic011atomic_flag5clearESt12memory_order@@GLIBCXX_3.4.11
+FUNC:_ZSt10from_charsPKcS0_RDF128_St12chars_format@@GLIBCXX_3.4.31
 FUNC:_ZSt10from_charsPKcS0_RdSt12chars_format@@GLIBCXX_3.4.29
 FUNC:_ZSt10from_charsPKcS0_ReSt12chars_format@@GLIBCXX_3.4.29
 FUNC:_ZSt10from_charsPKcS0_RfSt12chars_format@@GLIBCXX_3.4.29
@@ -4641,6 +4642,9 @@  FUNC:_ZSt7getlineIwSt11char_traitsIwESaI
 FUNC:_ZSt7getlineIwSt11char_traitsIwESaIwEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EES4_@@GLIBCXX_3.4.21
 FUNC:_ZSt7getlineIwSt11char_traitsIwESaIwEERSt13basic_istreamIT_T0_ES7_RSbIS4_S5_T1_E@@GLIBCXX_3.4
 FUNC:_ZSt7getlineIwSt11char_traitsIwESaIwEERSt13basic_istreamIT_T0_ES7_RSbIS4_S5_T1_ES4_@@GLIBCXX_3.4
+FUNC:_ZSt8to_charsPcS_DF128_@@GLIBCXX_3.4.31
+FUNC:_ZSt8to_charsPcS_DF128_St12chars_format@@GLIBCXX_3.4.31
+FUNC:_ZSt8to_charsPcS_DF128_St12chars_formati@@GLIBCXX_3.4.31
 FUNC:_ZSt8to_charsPcS_d@@GLIBCXX_3.4.29
 FUNC:_ZSt8to_charsPcS_dSt12chars_format@@GLIBCXX_3.4.29
 FUNC:_ZSt8to_charsPcS_dSt12chars_formati@@GLIBCXX_3.4.29