This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] PR other/24689: Fix NetBSD bootstrap failure
- From: Roger Sayle <roger at eyesopen dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Mark Mitchell <mark at codesourcery dot com>
- Date: Wed, 1 Mar 2006 17:48:22 -0700 (MST)
- Subject: [PATCH] PR other/24689: Fix NetBSD bootstrap failure
The following patch should resolve PR other/24689, which is a bootstrap
failure on NetBSD caused by NetBSD's pthread.h using #define to rename/map
pthread_once, pthread_self and other identifiers to alternate libc
symbols. The use of the preprocessor conflicts with gthr-posix.h's
attempts to map __gthrw_pthread_once as a weak reference to pthread_once.
The fix below is to precisely control when these symbols get expanded
by the preprocessor, such that we declare __gthrw_pthread_once to have
the correct type, and alias the expanded symbol. This required a
compensating change to the way that Tru64 maps symbols such as
__gthrw_pthread_once to __pthread_once.
The following code has been tested on alphaev67-dec-osf5.1 with a
full "make bootstrap", all default langauges, and regression tested
with a top-level "make -k check" with no new failures. It's also
been reported by the bug submitter to fix things for him/her.
Now that the window for 4.1.0 has passed, there's no immediate rush
to get this onto the gcc-4_1-branch, so hopefully it'll get some
NetBSD testing on mainline (which has been broken for some time).
Ok for mainline?
2006-03-01 Roger Sayle <roger@eyesopen.com>
PR other/26489
* gthr-posix.h (__gthrw2): Define to take three parameters, the
declared name, the weak reference name, and the typeof name.
(__gthrw): Avoid expanding the declared name suffix.
(__gthrw3): New Tru64 specific macro to simplify the OSF/1 decls.
Index: gthr-posix.h
===================================================================
*** gthr-posix.h (revision 111507)
--- gthr-posix.h (working copy)
*************** typedef pthread_mutex_t __gthread_recurs
*** 59,88 ****
#endif
#if SUPPORTS_WEAK && GTHREAD_USE_WEAK
! # define __gthrw2(name,name2) \
! static __typeof(name) __gthrw_ ## name __attribute__ ((__weakref__(#name2)));
# define __gthrw_(name) __gthrw_ ## name
#else
! # define __gthrw2(name,name2)
# define __gthrw_(name) name
#endif
/* Typically, __gthrw_foo is a weak reference to symbol foo. */
! #define __gthrw(name) __gthrw2(name,name)
/* On Tru64, /usr/include/pthread.h uses #pragma extern_prefix "__" to
map a subset of the POSIX pthread API to mangled versions of their
names. */
#if defined(__osf__) && defined(_PTHREAD_USE_MANGLED_NAMES_)
! __gthrw2(pthread_once,__pthread_once)
! __gthrw2(pthread_getspecific,__pthread_getspecific)
! __gthrw2(pthread_setspecific,__pthread_setspecific)
! __gthrw2(pthread_create,__pthread_create)
! __gthrw2(pthread_cancel,__pthread_cancel)
! __gthrw2(pthread_mutex_lock,__pthread_mutex_lock)
! __gthrw2(pthread_mutex_trylock,__pthread_mutex_trylock)
! __gthrw2(pthread_mutex_unlock,__pthread_mutex_unlock)
! __gthrw2(pthread_mutex_init,__pthread_mutex_init)
#else
__gthrw(pthread_once)
__gthrw(pthread_getspecific)
--- 59,89 ----
#endif
#if SUPPORTS_WEAK && GTHREAD_USE_WEAK
! # define __gthrw2(name,name2,type) \
! static __typeof(type) name __attribute__ ((__weakref__(#name2)));
# define __gthrw_(name) __gthrw_ ## name
#else
! # define __gthrw2(name,name2,type)
# define __gthrw_(name) name
#endif
/* Typically, __gthrw_foo is a weak reference to symbol foo. */
! #define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name)
/* On Tru64, /usr/include/pthread.h uses #pragma extern_prefix "__" to
map a subset of the POSIX pthread API to mangled versions of their
names. */
#if defined(__osf__) && defined(_PTHREAD_USE_MANGLED_NAMES_)
! #define __gthrw3(name) __gthrw2(__gthrw_ ## name, __ ## name, name)
! __gthrw3(pthread_once)
! __gthrw3(pthread_getspecific)
! __gthrw3(pthread_setspecific)
! __gthrw3(pthread_create)
! __gthrw3(pthread_cancel)
! __gthrw3(pthread_mutex_lock)
! __gthrw3(pthread_mutex_trylock)
! __gthrw3(pthread_mutex_unlock)
! __gthrw3(pthread_mutex_init)
#else
__gthrw(pthread_once)
__gthrw(pthread_getspecific)
*************** __gthrw(pthread_mutexattr_destroy)
*** 105,118 ****
#if defined(_LIBOBJC) || defined(_LIBOBJC_WEAK)
/* Objective-C. */
#if defined(__osf__) && defined(_PTHREAD_USE_MANGLED_NAMES_)
! __gthrw2(pthread_cond_broadcast,__pthread_cond_broadcast)
! __gthrw2(pthread_cond_destroy,__pthread_cond_destroy)
! __gthrw2(pthread_cond_init,__pthread_cond_init)
! __gthrw2(pthread_cond_signal,__pthread_cond_signal)
! __gthrw2(pthread_cond_wait,__pthread_cond_wait)
! __gthrw2(pthread_exit,__pthread_exit)
! __gthrw2(pthread_mutex_destroy,__pthread_mutex_destroy)
! __gthrw2(pthread_self,__pthread_self)
#else
__gthrw(pthread_cond_broadcast)
__gthrw(pthread_cond_destroy)
--- 106,119 ----
#if defined(_LIBOBJC) || defined(_LIBOBJC_WEAK)
/* Objective-C. */
#if defined(__osf__) && defined(_PTHREAD_USE_MANGLED_NAMES_)
! __gthrw3(pthread_cond_broadcast)
! __gthrw3(pthread_cond_destroy)
! __gthrw3(pthread_cond_init)
! __gthrw3(pthread_cond_signal)
! __gthrw3(pthread_cond_wait)
! __gthrw3(pthread_exit)
! __gthrw3(pthread_mutex_destroy)
! __gthrw3(pthread_self)
#else
__gthrw(pthread_cond_broadcast)
__gthrw(pthread_cond_destroy)
Roger
--