------- Comment #13 from craig dot lawson at centrify dot com 2007-03-15 02:02 ------- (reply to comment #11)
Shear luck: Fair enough. I don't claim to understand it all, either, especially how it came to be this way. What appears to be happening on Solaris 10 is that <bits/c++config.h> followed by "/usr/include/locale.h" defines the CPP symbols which select the errno function. That happens in the wrong order in c++locale.cc. In that file, moving <cerrno> to the end of the list fixes the problem, too. In fact, moving it below <cmath> is all that is necessary. And so I thought, <cmath> and <clocale> are configuring the compilation environment for threads and they don't have much to be concerned about ... why isn't <cerrno> doing that -- that's what needs it the most! And what is the down side of <cerrno> including files which may select the errno function? The errno function is always safe, even in single-threaded programs. I'm not aware that there's any more to it than this, though I could be wrong. -pthread vs -pthreads: In the 3.x releases which I use, this is the case. It's -pthread on every system except for Solaris where it's -pthreads. Also except on Irix where gcc doesn't recognize the option at all. But 4.1.2 gcc on Solaris (which I just built) accepts either one interchangably. That's progress. Not sure about 4.1.2 Irix. And there are plenty of other platforms that I don't know about. Testing: After several full builds, I began experimenting with the includes and narrowed my test down to this command taken from my build log: BUILD-ROOT/host-sparc-sun-solaris2.10/gcc/xgcc <options> -c c++locale.cc -E | grep __errno If it displays "extern int *___errno();", then the build will produce a multi-threaded object. If not, single-threaded as it does now. (reply to comment #12) Sane set of headers: Yes, I agree with you. Should not be happening. Perhaps it's better to focus on <cerrno> rather than -pthread. Exactly which CPP symbol: On this platform, to select the errno function, /usr/include/errno.h requires defined(_REENTRANT) || defined(_TS_ERRNO) || _POSIX_C_SOURCE - 0 >= 199506L My guess is most likely _REENTRANT or _POSIX_C_SOURCE. <clocale> -> /usr/include/locale.h -> /usr/include/sys/feature_tests.h, /usr/include/sys/ccompile.h, /usr/include/sys/isa_defs.h, .... Some of these system header files do testing and setting of _REENTRANT and _POSIX_C_SOURCE, but they're difficult to follow. One frustration I have with CPP output is that #defines are not visible. I can see comments (with -CC), but that's not quite good enough. That's as deep as I've dug at this point. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31117