This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Threadiing Problems on AIX 4.3.3 ML-11 with gcc 3.2.3 (g++) - 2nd
- From: Markus dot Schaeffer at np-gmbh dot com
- To: gcc-help at gcc dot gnu dot org
- Date: Thu, 7 Aug 2003 14:59:08 +0200
- Subject: Threadiing Problems on AIX 4.3.3 ML-11 with gcc 3.2.3 (g++) - 2nd
Hello folks,
> I assume you mean that you are using the native AIX linker, but
>invoking "g++" to perform the link, not invoking "ld" directly.
>Otherwise, using "-Wl," in the LDFLAGS could not possibly work.
Yes indeed.
> Why are you adding "-fexceptions"? The GNU C++ Compiler defaults
> to exceptions on. This is CXXFLAGS, not CFLAGS.
At the moment I'am not shure that threads are the trouble makers.
###
Because an ldd gives the following info:
$ ldd ./server
/usr/lib/librtl.a(shr.o)
/usr/lib/libdl.a(shr.o)
/pkg/dev01/tools/compiler/gcc/lib/libgcc_s_pthread.a(shr.o) -> Is this a
static lib? Are there problems with exception handling?
/pkg/dev01/tools/compiler/gcc/lib/libgcc_s.a(shr.o) -> "" ""
Thers's another lib in gcc libgcc_eh.a eh -> exception handling/invoked by
-shared-libgcc
->
http://groups.google.de/groups?q=gcc+3.2+exceptions+Marna+Gilligan&hl=de&lr
=&ie=UTF-8&oe=UTF-8&selm=apsi7j%242h67%241%40FreeBSD.csie.NCTU.edu.tw&rnum=1
-<
/pkg/dev01/tools/compiler/gcc/lib/libstdc++.a(libstdc++.so.5)
/usr/lib/libpthreads.a(shr.o)
/usr/lib/libpthreads_compat.a(shr.o)
/usr/lib/libcrypt.a(shr.o)
/usr/lib/libc.a(shr.o)
/usr/lib/libpthreads.a(shr_comm.o)
/usr/lib/libpthreads.a(shr_xpg5.o)
/tmp/MS/0.07/libbase/aix/xerces/libxerces-c1_6_0.a
./server
$
And ldd of my shared lib gives me the following:
$ ldd ./libserviceconnectorarchive.a
/pkg/dev01/tools/compiler/gcc/lib/libgcc_s_pthread.a(shr.o)
/pkg/dev01/tools/compiler/gcc/lib/libgcc_s.a(shr.o)
/pkg/dev01/tools/compiler/gcc/lib/libstdc++.a(libstdc++.so.5)
/usr/lib/libpthreads.a(shr.o)
/usr/lib/libpthreads_compat.a(shr.o)
/usr/lib/libcrypt.a(shr.o)
/usr/lib/libc.a(shr.o)
/usr/lib/libpthreads.a(shr_comm.o)
/usr/lib/libpthreads.a(shr_xpg5.o)
/tmp/MS/0.07/libbase/aix/xerces/libxerces-c1_6_0.a
./libserviceconnectorarchive.a
$
And at least my xerces build:
$ ldd ./libxerces-c1_6_0.a
/pkg/dev01/tools/compiler/gcc/lib/libgcc_s_pthread.a(shr.o)
/pkg/dev01/tools/compiler/gcc/lib/libgcc_s.a(shr.o)
/pkg/dev01/tools/compiler/gcc/lib/libstdc++.a(libstdc++.so.5)
/usr/lib/libpthreads.a(shr.o)
/usr/lib/libpthreads_compat.a(shr.o)
/usr/lib/libcrypt.a(shr.o)
/usr/lib/libc.a(shr.o)
/usr/lib/libpthreads.a(shr_comm.o)
/usr/lib/libpthreads.a(shr_xpg5.o)
./libxerces-c1_6_0.a
###
> I assume LDFLAGS is for the application and SHARED_LDFLAGS is for
> the shared library.
Yes indeed.
> Why does LDFLAGS contain "-Wl,-brtl", but SHARED_LDFLAGS does not
> contain "-Wl,-G"? Does the application use some other shared library
with
> System-V semantics? Not all shared libraries need to be linked with
> "-Wl,-G", but "-Wl,-brtl" serves no purpose unless the shared library was
> linked with "-Wl,-G". If you are using "-Wl,-brtl" for the linker to
> notice shared libraries with the file suffix ".so", don't do that. AIX
> shared libraries normally are archives (ar command) of shared objects.
> You can use the ".a" suffix directly on the shared object instead of
> creating an archive. Using the ".so" suffix for non-System-V semantics
> shared objects just creates confusion.
Ok, I did my homework after you told me that twice. ( See my makefile below
!)
> Also, I am concerned that you need to add "-Wl,-bh:5" to your link
> line. If you need to change the linker halt level from the default,
> something is wrong.
I get level 4 Warnings of duplicated symbols. (Check my makefile, it
deleted -> you are rigth this is not very clever)
> You have not mentioned what errors are produced by the AIX linker
> requiring raising the halt level and you have not mentioned what
"problem"
> you encounter if your server does many calls.
No linking problems. (Just warnings!)
> While AIX provides a thread-safe C library and GCC libstdc++-v3
> strives to be thread safe, libstdc++-v3 may not interact with AIX libc in
> a thread-safe manner. libstdc++-v3 makes assumptions based on GNU libc
> that are not correct on all platforms. For instance, there are known
> issues with libstdc++-v3 use of setlocale() in I/O functions. Does your
> shared library perform threaded I/O?
Yes...!?
> User-written code interacting with libstdc++-v3 must follow the
> SGI thread-safety rule, which basically says that the direct use of any
> global library object (e.g. std::cout is global) or non-local object
> returned from the library shared amongst user threads, must be protected
> by a mutex or similar by the user.
It's a hard thing but I will check this. I got the job for 2 weeks and this
is a mess anyway.
### MAKEFILE ###
CXXFLAGS= -c -g \
-Wno-deprecated \
-pthread
LDFLAGS= -pthread \
-Wl,-brtl \
-Wl,-bnoquiet \
${XERCESC_LDFLAGS} \
-ldl
SHARED_LDFLAGS= -pthread -shared \
-Wl,-bE:symbols.exp \
-Wl,-binitfini:init:fini:1 \ I've changed that to "0" but
it does ot make any difference
-Wl,-G \
-Wl,-bnoquiet \
${XERCESC_LDFLAGS} \
-ldl
####
Regards
Mattey
P.S.: Thanks for all the good and fast replys David. It's not working yet
but any advice was worth a lot to me.