RFC: [Long] Change PTHREAD_LIBS to -pthread for -CURRENT

Michael Nottebrock michaelnottebrock at gmx.net
Sun Dec 5 23:14:41 PST 2004


On Tuesday, 8. June 2004 07:39, Joe Marcus Clarke wrote:
> So, I propose changing PTHREAD_LIBS to -pthread for -CURRENT.  This will
> match what we have in 4.X, and will last for the life of 5.X going
> forward.  The threading people tell me this is doable now.  Thoughts?

I'm reviving this thread because KDE has recently started to make use of the 
--as-needed flag of GNU ld in their build system. --as-needed removes 
dependencies on unneeded shared libraries at link time (standard behaviour is 
to just link to everything that's specified on the command line). Now, 
--as-needed doesn't seem to be smart enough to correctly identify 'needed' 
dependencies in some tricky cases, in particular with the threads libraries. 

KDE applications linked with --as-needed will typically not retain a link to 
libpthread, since hardly any KDE application actually needs the pthread 
symbols. However, they all do link to libqt-mt, and libqt-mt does make use of 
threading. Result: Applications randomly break at runtime when Qt wants to 
make use of threading functions. The Linux people just shrug their shoulders 
and say we should link the library against the threads lib instead of the 
applications and say -pthread is bullshit.
They have a point: The above scenario would work, and with --as-needed, a 
whole lot of linkage could be saved on many application binaries and startup 
times would improve.

Is there any way I'm missing to make --as-needed play nicely with -pthread? It 
strikes me as odd that the gcc people favour -pthread and GNU ld sabotages 
it...

-- 
   ,_,   | Michael Nottebrock               | lofi at freebsd.org
 (/^ ^\) | FreeBSD - The Power to Serve     | http://www.freebsd.org
   \u/   | K Desktop Environment on FreeBSD | http://freebsd.kde.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-ports/attachments/20041206/c16d09ad/attachment.bin


More information about the freebsd-ports mailing list