This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ 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]

Re: GCC-3.0.4 (pre) on AIX requires pthreads


[Copy of message sent to GCC mailinglist.]

>>>>> Michael Veksler writes:

Michael> For some reason, on AIX 4.3.3, g++ requires -lpthreads  while linking
Michael> executables. Is there a way to fix g++ installation/compilation procedures
Michael> to eliminate the need for -lpthreads?

Michael> $ g++ -v
Michael> Reading specs from
Michael> /afs/haifa/proj7/gec/gnu/lib/gcc-lib/powerpc-ibm-aix4.3.3.0/3.0.4/specs
Michael> Configured with: ../gcc/configure --enable-languages=c++
Michael> --prefix=/afs/haifa/proj7/gec/gnu
Michael> Thread model: single
Michael> gcc version 3.0.4 20020215 (prerelease)

Michael> $ g++ t.cc     # adding "-lpthreads", or even "-pthreads" removes this
Michael> error:
Michael> ld: 0711-317 ERROR: Undefined symbol: .pthread_mutex_lock
Michael> ld: 0711-317 ERROR: Undefined symbol: .pthread_mutex_unlock
Michael> ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more
Michael> information.

Michael> This suggests that these symbols are required by the generated
Michael> object file. 

	This is not a problem with g++ or with the libstdc++ library. It
is a problem with single instance of libstdc++ headers serving both
"single" and "pthread" multilibs of AIX without necessary logic in gthr.h.

	AIX does not have weak no-op implementations of the pthread
routines in libc because it does not have weak symbols.  On AIX, pthread
is a multilib.

	Although libstdc++ configuration checks for the thread model and
sees both "single" and "pthread" for each multilib, as appropriate,
gthr-default.h exists meaning bits/c++config.h defines
_GLIBCPP_HAVE_GTHR_DEFAULT.  This causes bits/gthr.h to include
gthr-default.h which references all of the pthread functions.

	Some libstdc++ header files (e.g., STL) make use of
__gthread_mutex_lock and __gthread_mutex_unlock.  Because the libstdc++
headers include gthr-default.h and not gthr-single.h, those get defined
relative to pthread routines, so we get an unwanted dependencies on AIX.
This does not happen with all libstdc++ programs, only those that include
header files which lead to gthr.h.

	There is gcc/gthr-aix.h which is not installed or used by
libstdc++ because it only checks "single" or "pthread".  To fix this,
something needs to be corrected in the gthr.h logic, but I do not know
what the libstdc++ would find palatable.

David


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