This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: Fix weak handling with GCC 3.4+
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Richard Henderson <rth at twiddle dot net>
- Cc: Ulrich Drepper <drepper at redhat dot com>, Andreas Jaeger <aj at suse dot de>, libc-alpha at sources dot redhat dot com
- Date: Fri, 3 Jan 2003 23:59:03 +0100
- Subject: Re: Fix weak handling with GCC 3.4+
- References: <u84r8qtski.fsf@gromit.moeb> <3E16100A.4070406@redhat.com> <20030103144123.D31274@twiddle.net>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Fri, Jan 03, 2003 at 02:41:23PM -0800, Richard Henderson wrote:
> On Fri, Jan 03, 2003 at 02:34:50PM -0800, Ulrich Drepper wrote:
> > __thread int foo = 0;
> > extern __typeof (foo) foo __attribute ((weak));
> >
> >
> > __typeof() apparently does not include the __thread information. I'd
> > call it a gcc bug.
>
> Why do you say that? __thread is a storage class specifier, not a
> type specifier. It would be just as incorrect if __typeof somehow
> copied "static" or "extern".
>
> IMO this idiom is simply incorrect wrt __thread.
>
> It would work if you used
>
> extern __thread __typeof(foo) foo __attribute((weak));
>
> or just
>
> #pragma weak foo
Then
#define __weak_extern_1(x) #symbol
#define weak_extern(symbol) _Pragma(__weak_extern_1(weak symbol)
should work.
Dunno if this is exactly what Andreas was testing, but at least
the snipped he posted was different:
#define __pragma_weak(expr) _Pragma(#expr)
#define _weak_extern(symbol) __pragma_weak("weak " #symbol)
Jakub