[PATCH] libstdc++: Ensure __gthread_self doesn't call undefined weak symbol [PR 95989]

Jakub Jelinek jakub@redhat.com
Wed Nov 11 18:08:22 GMT 2020


On Wed, Nov 11, 2020 at 05:24:42PM +0000, Jonathan Wakely wrote:
> --- a/libgcc/gthr-posix.h
> +++ b/libgcc/gthr-posix.h
> @@ -684,7 +684,14 @@ __gthread_equal (__gthread_t __t1, __gthread_t __t2)
>  static inline __gthread_t
>  __gthread_self (void)
>  {
> +#if __GLIBC_PREREQ(2, 27)

What if it is a non-glibc system where __GLIBC_PREREQ macro isn't defined?
I think you'd get then
error: missing binary operator before token "("
So I think you want
#if defined __GLIBC__ && defined __GLIBC_PREREQ
#if __GLIBC_PREREQ(2, 27)
  return pthread_self ();
#else
  return __gthrw_(pthread_self) ();
#else
  return __gthrw_(pthread_self) ();
#endif
or similar.

	Jakub



More information about the Libstdc++ mailing list