This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: g++ -Wl,--as-needed -pthread behaviour


On 24 September 2013 13:24, Jakub Jelinek wrote:
> On Tue, Sep 24, 2013 at 01:13:53PM +0100, Jonathan Wakely wrote:
>> It's the std::thread constructor template that needs pthread_create.
>> std::thread::join() needs pthread_join.
>
> Are any references to that needed in libstdc++.so.6, or just in headers?

It's called from libstdc++-v3/src/c++11/thread.cc which ends up in
libstdc++.so.6

> Having libstdc++.so.6 depend on libpthread.so is not a good idea, the
> latter might be possible by just referencing pthread_* instead of
> __gthread_* where you actually require it.

For targets that don't use gthr-posix.h __gthread_create is not a
wrapper for pthread_create.

>> It's complicated by the fact that the source code doesn't mention
>> pthread_create, it uses __gthread_create instead, which is the weak
>> reference.
>
> If it requires pthread_{create,join} rather then it should be using
> those rather than the wrappers, those are there just to not require
> libpthread and just fail if it is not linked in.

And also to be platform independent, not all targets use pthreads.

>> It has the huge disadvantage of breaking the ABI by removing symbols
>> from libstdc++.so
>
> That is not possible.

Indeed.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]