This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: g++ -Wl,--as-needed -pthread behaviour
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: Matthias Klose <doko at ubuntu dot com>, gcc Development <gcc at gcc dot gnu dot org>, "libstdc++ at gcc dot gnu dot org" <libstdc++ at gcc dot gnu dot org>
- Date: Tue, 24 Sep 2013 13:34:52 +0100
- Subject: Re: g++ -Wl,--as-needed -pthread behaviour
- Authentication-results: sourceware.org; auth=none
- References: <52402F23 dot 4030206 at ubuntu dot com> <20130924012209 dot GM30130 at bubble dot grove dot modra dot org> <CAH6eHdRRYmG123oMHfD5gzv-iTEQpvUMzDmSWCJTJdq4+_s6Ww at mail dot gmail dot com> <20130924122406 dot GO30970 at tucnak dot zalov dot cz>
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.