Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 08 Jun 2004 01:39:02 -0400
From:      Joe Marcus Clarke <marcus@FreeBSD.org>
To:        ports@FreeBSD.org
Subject:   RFC: [Long] Change PTHREAD_LIBS to -pthread for -CURRENT
Message-ID:  <1086673141.18374.35.camel@shumai.marcuscom.com>

next in thread | raw e-mail | index | archive | help

--=-kGu/fEh+/dRdDqPHHbJS
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable

I'm not sure how many of you have seen the recent thread (no pun
intended) on either ports@, current@, gnome@, or threads@ about the
problems with linking shared objects with -lpthread on -CURRENT.

Basically, when shared objects are explicitly linked with -lpthread,
they retain a link to the libpthread.  This means that any executable
which links to these libraries must also link to libpthread.  If they do
not, they will most certainly crash or behave erratically (this also
includes any dynamically loadable objects).  Some examples of this
include the gnome-vfs gtk+ file system backend, apache2/php4, nss_ldap,
wine, etc.

Note: if the shared object actually contains pthread symbols, then any
executable that links to it will still have to be linked with -pthread,
but in the examples above, this is not the case.

To get around this, we can use -pthread to link shared objects as well
as executables.  This works exactly the same way as in 4.X.  By using
-pthread, when shared objects are linked, libpthread will only be used
to resolve symbols at link-time, but the resulting shared object will
not retain a link to libpthread.  (One way to test this is to write a
simple helloworld.c, and compile it with ``cc -shared -o helloworld.so
-pthread helloworld.c'' and ``cc -shared -o helloworld.so -lpthread
helloworld.c'', then look at the resulting helloworld.so files with
ldd).

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?

Joe

--=20
Joe Marcus Clarke
FreeBSD GNOME Team	::	gnome@FreeBSD.org
FreeNode / #freebsd-gnome
http://www.FreeBSD.org/gnome

--=-kGu/fEh+/dRdDqPHHbJS
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (FreeBSD)

iD8DBQBAxVD1b2iPiv4Uz4cRAvYHAJ9rXwWUUApGcCnKN/5cmJBBKnKP1QCgq8kV
Hzb72TPy4vH3N+q5ZWk1tD4=
=XyDL
-----END PGP SIGNATURE-----

--=-kGu/fEh+/dRdDqPHHbJS--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1086673141.18374.35.camel>