On Tue, Sep 24, 2013 at 01:34:52PM +0100, Jonathan Wakely wrote: > 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
Ah, then it has to use __gthread_create. > > 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. Grep tells me that other gthr* headers don't define __gthread_create at all. Anyway, either we just declare that people who use --as-needed without thinking about the consequences get what they deserve, or you'd need to keep the current std::thread::_M_start_thread as is in libstdc++.so.6, but in newer headers inline it, perhaps under a different name (using pthread_create rather than the wrapper). I guess for other routines it isn't really needed, thread::join if nobody started a thread doesn't look like a good idea, similarly detach. Jakub