This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[4.1 PATCH] Fix pthread linking issues on Tru64


On Sun, 19 Feb 2006, Mark Mitchell wrote:
> This is OK for mainline.  If it is applied to mainline, and if you get a
> 4.1 backport working, and if there is a 4.1 RC2, then it is OK for 4.1
> RC2; otherwise, it is OK for 4.1 after the 4.1 release.

For the record, here's the gcc-4_1-branch backport of the patch to fix
the pthread weak reference issues on Tru64, which is already on mainline.
This resolves 1236 unexpected failures for g++, 4906 for gfortran, 578
for objc, 1149 for libstdc++, 79 for libffi and 297 for libjava.

Having this posted, enables Mark to apply it to RC2 himself, or for
Tru64 users to find it somewhere should it not make it into 4.1.0.
Giving release managers more options is always a good thing.

The following patch has been tested against the gcc-4_1-branch with a
full "make bootstrap" on alphaev67-dec-osf5.1, all default languages,
and regression tested with a top-level "make -k check" with no new
failures but significant improvements.  The only difference between
the patch below and the one applied to mainline is that the keyword
"extern" below is now "static" on mainline.  Alas this prevented the
original mainline patch from applying cleanly.

Many thanks again,



2006-02-20  Roger Sayle  <roger@eyesopen.com>

	* gthr-posix.h: On Tru64, map __gthr_foo as a weak reference to
	__foo and not foo when _PTHREAD_USE_MANGLED_NAMES_ is defined.


Index: gthr-posix.h
===================================================================
*** gthr-posix.h	(revision 111294)
--- gthr-posix.h	(working copy)
***************
*** 1,6 ****
  /* Threads compatibility routines for libgcc2 and libobjc.  */
  /* Compile this one with gcc.  */
! /* Copyright (C) 1997, 1999, 2000, 2001, 2002, 2003, 2004, 2005
     Free Software Foundation, Inc.

  This file is part of GCC.
--- 1,6 ----
  /* Threads compatibility routines for libgcc2 and libobjc.  */
  /* Compile this one with gcc.  */
! /* Copyright (C) 1997, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
     Free Software Foundation, Inc.

  This file is part of GCC.
*************** typedef pthread_mutex_t __gthread_recurs
*** 59,91 ****
  #endif

  #if SUPPORTS_WEAK && GTHREAD_USE_WEAK
! # define __gthrw(name) \
!   extern __typeof(name) __gthrw_ ## name __attribute__ ((__weakref__(#name)));
  # define __gthrw_(name) __gthrw_ ## name
  #else
! # define __gthrw(name)
  # define __gthrw_(name) name
  #endif

  __gthrw(pthread_once)
- __gthrw(pthread_key_create)
- __gthrw(pthread_key_delete)
  __gthrw(pthread_getspecific)
  __gthrw(pthread_setspecific)
  __gthrw(pthread_create)
  __gthrw(pthread_cancel)
-
  __gthrw(pthread_mutex_lock)
  __gthrw(pthread_mutex_trylock)
  __gthrw(pthread_mutex_unlock)
  __gthrw(pthread_mutexattr_init)
  __gthrw(pthread_mutexattr_settype)
  __gthrw(pthread_mutexattr_destroy)

- __gthrw(pthread_mutex_init)

  #if defined(_LIBOBJC) || defined(_LIBOBJC_WEAK)
  /* Objective-C.  */
  __gthrw(pthread_cond_broadcast)
  __gthrw(pthread_cond_destroy)
  __gthrw(pthread_cond_init)
--- 59,119 ----
  #endif

  #if SUPPORTS_WEAK && GTHREAD_USE_WEAK
! # define __gthrw2(name,name2) \
!   extern __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 refernce 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)
  __gthrw(pthread_setspecific)
  __gthrw(pthread_create)
  __gthrw(pthread_cancel)
  __gthrw(pthread_mutex_lock)
  __gthrw(pthread_mutex_trylock)
  __gthrw(pthread_mutex_unlock)
+ __gthrw(pthread_mutex_init)
+ #endif
+
+ __gthrw(pthread_key_create)
+ __gthrw(pthread_key_delete)
  __gthrw(pthread_mutexattr_init)
  __gthrw(pthread_mutexattr_settype)
  __gthrw(pthread_mutexattr_destroy)


  #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)
  __gthrw(pthread_cond_init)
*************** __gthrw(pthread_cond_wait)
*** 94,99 ****
--- 122,128 ----
  __gthrw(pthread_exit)
  __gthrw(pthread_mutex_destroy)
  __gthrw(pthread_self)
+ #endif /* __osf__ && _PTHREAD_USE_MANGLED_NAMES_ */
  #ifdef _POSIX_PRIORITY_SCHEDULING
  #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
  __gthrw(sched_get_priority_max)


Roger
--


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]