Is gcc and libgcc_s.a thread-safe ?
Wed Jan 21 14:18:00 GMT 2009
On Mon, 2009-01-19 at 17:08 -0800, Ian Lance Taylor wrote:
> biju64 <email@example.com> writes:
> > What about the libgcc_s.a library that we have to link in if using gcc ? Do
> > I need to worry about this ?
> > On google I see something called libgcc_s_pthread.a - What does this do ? Do
> > I need this ?
> gcc's supporting libraries are all thread-safe.
> I don't know what libgcc_s_pthread.a is--it's not part of a regular
> gcc distribution.
Err - it is not part of a _recent_ (>= gcc-4) on *AIX* any more, but up
to gcc-3.4, these libgcc_s* were provided by gcc on AIX:
$ cd /prefix/of/gcc-3.x
$ find . -name 'libgcc_s*
and theses were the libstdc++* ones:
$ find . -name '*.la' -prune -o -name 'libstdc++*' -print
Note: These are the _shared_ libraries on AIX.
I've always tried hard to _not_ have pthread- and non-pthread-variants
of both libgcc_s (distinguished by filename) and libstdc++
(distinguished by path) as runtime dependencies of my shared libraries
In the end, I patched the gcc source (specs) to always behave as if
'-pthread' was passed on the commandline, but it also should work to
have a wrapper-script that always passes '-pthread'.
Even if I did not necessarily use pthreads in my application, I could
not be sure that each required library was built without -pthread. So I
built each library where I have sourcecode for using that patched gcc.
Having pthreads enabled always does not really hurt, even when not used.
Since gcc-4.1 (haven't tried gcc-4.0), the pthread-specific libs are
gone, but I still patch gcc-source to enable pthreads always. I'm not
sure if it is really necessary any more, but it still works.
More information about the Gcc-help