Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 14 Sep 2014 08:19:44 -0400
From:      "Jason E. Hale" <jhale@freebsd.org>
To:        Tijl Coosemans <tijl@freebsd.org>
Cc:        "svn-ports-head@freebsd.org" <svn-ports-head@freebsd.org>, "svn-ports-all@freebsd.org" <svn-ports-all@freebsd.org>, ports-committers <ports-committers@freebsd.org>
Subject:   Re: svn commit: r368130 - in head/devel/bennugd-core: . files
Message-ID:  <CAJE75NG-5d_eWdrzGQwakYf2KohNckepKm%2B_1xi%2B1vX9r9dP4A@mail.gmail.com>
In-Reply-To: <20140914112837.375964ab@kalimero.tijl.coosemans.org>
References:  <201409131920.s8DJKNGP095467@svn.freebsd.org> <CAJE75NEGTy0%2BPNT040Cj7rSinq_DBEDYaJbPzbLTiX=zHp_kEQ@mail.gmail.com> <20140914112837.375964ab@kalimero.tijl.coosemans.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Sep 14, 2014 at 5:28 AM, Tijl Coosemans <tijl@freebsd.org> wrote:
> On Sun, 14 Sep 2014 04:20:34 -0400 "Jason E. Hale" <jhale@freebsd.org> wrote:
>>
>> Should we no longer be patching for -lpthread?  Does
>> https://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/dads-pthread.html
>> no longer apply?
>
> If you ask me it doesn't.  The C compiler automatically links in libc
> and we used to have two, libc (without threading) and libc_r (with
> threading).  The -pthread flag told the compiler which one to use.
> Nowadays we have one libc and libpthread provides threading functions.
> All -pthread does is tell the compiler to link in libpthread, just like
> -lpthread does.  They are the same.
>
> It used to be that this libpthread could only be linked into executables
> and not into libraries.  This meant that if an executable depended on a
> library that used threading, it had to be linked with libpthread even if
> it didn't use threading itself.  This is why several ports still have
> LDFLAGS+=-pthread or similar, just because one of the libraries in the
> dependency chain used threading.  This is no longer necessary.
>
> There's one thing that is still special about libpthread and that is
> that it needs to be loaded into memory before libc because it overrides
> some libc symbols.  So if you mention -lc explicitly on the command
> line (which you normally don't), -lpthread has to appear in front of it.
> And, if an executable dlopen()s a library that uses threading, the
> executable needs to be linked with libpthread even if it doesn't use
> threading itself.

Very interesting.  Thanks for your detailed response, Tijl!



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAJE75NG-5d_eWdrzGQwakYf2KohNckepKm%2B_1xi%2B1vX9r9dP4A>