Re: Threadiing Problems on AIX 4.3.3 ML-11 with gcc 3.2.3 (g++)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>>>>> 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


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux