Rainer Orth wrote: > James Carlson <[email protected]> writes: >> You might not want to do that. You'll be forcing single-threaded >> applications on those older OSes to become suddenly and rather >> unexpectedly multi-threaded, regardless of what the application author >> had intended. > > 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? 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. >> As for the rest of what you're saying, I guess I'm just confused. I >> don't see why you'd have to do anything special for those older >> releases. The stubs in libc should take care of it for you and >> shouldn't require any heroics. > > 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. -- James Carlson 42.703N 71.076W <[email protected]> _______________________________________________ tools-compilers mailing list [email protected]
