This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Threadiing Problems on AIX 4.3.3 ML-11 with gcc 3.2.3 (g++)
- From: David Edelsohn <dje at watson dot ibm dot com>
- To: Markus dot Schaeffer at np-gmbh dot com
- Cc: gcc-help at gcc dot gnu dot org
- Date: Tue, 05 Aug 2003 13:41:08 -0400
- Subject: Re: Threadiing Problems on AIX 4.3.3 ML-11 with gcc 3.2.3 (g++)
- References: <OF885E6FC2.B3AA53C7-ONC1256D79.0055B728@np-gmbh.com>
>>>>> Markus writes:
> I guess the linking options are wrong (too much!?).
> LDFLAGS= -Wl,-brtl \
> -Wl,-bnoipath \
> -Wl,-bnoquiet \
> -Wl,-bh:5 \
> -pthread \
> ${XERCESC_LDFLAGS} \
> -lc_r -lC_r -lm_r -lpthreads -lpthreads_compat \
> -lgcc -lstdc++ -lstdc++ \
> -ldl -lnsl -lintl
> SHARED_LDFLAGS= -Wl,-brtl \
> -Wl,-bE:symbols.exp \
> -Wl,-binitfini:init:fini:1 \
> -Wl,-bM:SRE \
> -Wl,-bdynamic \
> -Wl,-bnoquiet \
> -Wl,-bh:5 \
> -Wl,-bbigtoc \
> -nostartfiles \
> -pthread \
> ${XERCESC_LDFLAGS} \
> -lc_r -lC_r -lm_r -lpthreads -lpthreads_compat \
> -lgcc -lstdc++ -lstdc++ \
> -ldl -lnsl -lintl
These options contain both "-Wl," to pass options through g++ to
the linker and libraries automatically linked by g++ like "-lc_r". This
does not make any sense. And "-lC_r" is the AIX VisualAge C++ library
that is completely incompatible with G++.
Similarly the CXXFLAGS define too much.
The only CXXFLAGS you should need to compile the source code for a
pthread application are
CXXFLAGS= -pthread
"-D_THREAD_SAFE" is defined implicitly by the -pthread commandline option,
"-D_REENTRANT" and "-D_LIBC_REENTRANT" do not have any meaning on AIX. If
your application needs "-D_POSIX_SOURCE", that is your own issue.
The only LDFLAGS you should need to link a shared object are
LDFLAGS= -pthread -shared -Wl,-bE:symbols.exp ${XERCESC_LDFLAGS}
and use "g++" to perform the link.
If you need System V-style runtime linking, you can add "-Wl,-G".
"-Wl,-brtl" is used in the application link step, not the shared libary
link step.
If you need the "-ldl -lnsl -lintl" libraries, that is your own issue, but
the rest of the libraries are redundant or wrong.
Only use "-Wl,-binitfini:init:fini:1" if you really have your own
initialization method that needs to be run at load-time. The priority (1)
may conflict with G++ constructor priorities, if you are using G++
services in your initialization.
Only use "-Wl,-bbigtoc" if your shared library overflows the TOC. And it
would be better to recompile the source code with the -mminimal-toc option
instead of using the bigtoc linker option.
David