James Carlson <[email protected]> writes:
>> I'm not: this only happens if the user links a shared library with
>> -pthread. I'm using this in a couple of places when building GCC
>> runtime libraries: instead of doing the same dance over and over again
>> (link with -lthread on S8/9 if using TLS, adding -L/-R /usr/lib/lwp on
>> S8) just doesn't seem right. For executables, -pthread already handles
>> this just fine. Why should the user need to know tons of Solaris
>> implementation quirks when building shared libraries?
>
> Ah, ok; I'm not too familiar with that part of the gcc runtime. So is
> it the case that you deliberately deliver separate libraries, and the
> compiler (or link editor) automatically choses one or another depending
> on whether a threads library is also linked, at least on S8/9?
No, I'm doing this for the GCC runtime libraries that depend on
threading: libgcj (the Java runtime lib) and libgomp (for GNU OpenMP,
which is inherently threaded). Both of them already link with -lpthread
right now.
> If so, then no problem; it sounds like the right things will happen with
> what you propose.
>
> Having a dependency on the threads library becomes a problem only if
> there's a single library being produced, or if there are multiple
> libraries but there's no good way for the user to select the right one
> to use.
There is a single one each, but both don't make sense without threading,
so the user has (and needs) no choice. You'd of course be right if I'd
force, say, libgcc_s.so, to be linked with -lpthread.
>> Unfortunately not: for thread-local storage, the compiler generates
>> calls to the __tls_get_addr and ___tls_get_addr functions. Before the
>> unified process model in Solaris 10, the implementations only lived in
>> libthread.so, not even in libpthread. So if you want to use TLS, you
>> need to link with -lthread, and I don't think it's appropriate that
>> users have to know this implementation detail. Since TLS only makes
>> sense in multithreaded programs, there's no extra penalty to be paid.
>
> I'd missed that wrinkle. That really sounds like a bug in S8/9 to me,
> because it breaks the intended "thread-aware library" architecture in
> those releases.
Indeed: it took me some time to discover what was going on, especially
in S8 patches. Seems like Sun was late in the TLS area and it took them
until S10 to get this right.
Rainer
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University
_______________________________________________
tools-compilers mailing list
[email protected]