This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix detection of thread support with uClibc in libgcc
- From: Andrew Pinski <pinskia at gmail dot com>
- To: Kwok Cheung Yeung <kcy at codesourcery dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Sat, 11 Oct 2014 09:56:57 -0700
- Subject: Re: [PATCH] Fix detection of thread support with uClibc in libgcc
- Authentication-results: sourceware.org; auth=none
- References: <54395E0A dot 9080703 at codesourcery dot com>
On Sat, Oct 11, 2014 at 9:42 AM, Kwok Cheung Yeung <kcy@codesourcery.com> wrote:
> __gthread_active_p() in libgcc checks for thread support by looking for the
> presence of a symbol from libpthread. With glibc, it looks for
> __pthread_key_create. However, it determines that glibc is being used by
> checking for a definition of __GLIBC__, which is also defined by uClibc (in
> include/features.h), but it does not export __pthread_key_create, causing
> the test to always fail. I've fixed this by extending the test for glibc to
> check that __UCLIBC__ is not defined, causing the default pthread_cancel to
> be tested with uClibc instead.
Why is __GLIBC__ being defined for uclibc? That seems broken. We
complain about __GNUC__ defined for other compilers besides GCC; we
should do the same for defining __GLIBC__ also.
Thanks,
Andrew
>
> This affects anything that uses the C++11 thread library together with the
> uClibc implementation of libpthread. This caused a large number of failed
> tests from the g++, libgomp and libstdc++ testsuites when run on a MIPS
> Linux target with uClibc as the C library.
>
> Kwok
>
>
> 2014-10-11 Kwok Cheung Yeung <kcy@codesourcery.com>
>
> libgcc/
> * gthr-posix.h (GTHR_ACTIVE_PROXY): Check that __UCLIBC__ is
> not defined before defining to __gthrw_(__pthread_key_create).
>
> Index: libgcc/gthr-posix.h
> ===================================================================
> --- libgcc/gthr-posix.h (revision 216119)
> +++ libgcc/gthr-posix.h (working copy)
> @@ -232,7 +232,7 @@
> library does not provide pthread_cancel, so we do use pthread_create
> there (and interceptor libraries lose). */
>
> -#ifdef __GLIBC__
> +#if defined (__GLIBC__) && !defined (__UCLIBC__)
> __gthrw2(__gthrw_(__pthread_key_create),
> __pthread_key_create,
> pthread_key_create)