From owner-svn-ports-all@FreeBSD.ORG Mon Sep 15 04:29:58 2014 Return-Path: Delivered-To: svn-ports-all@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 1033) id 8FB602C6; Mon, 15 Sep 2014 04:29:58 +0000 (UTC) Date: Mon, 15 Sep 2014 04:29:58 +0000 From: Alexey Dokuchaev To: Tijl Coosemans Subject: Re: svn commit: r368130 - in head/devel/bennugd-core: . files Message-ID: <20140915042958.GB15180@FreeBSD.org> References: <201409131920.s8DJKNGP095467@svn.freebsd.org> <20140914112837.375964ab@kalimero.tijl.coosemans.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20140914112837.375964ab@kalimero.tijl.coosemans.org> User-Agent: Mutt/1.5.23 (2014-03-12) Cc: "svn-ports-head@freebsd.org" , "Jason E. Hale" , "svn-ports-all@freebsd.org" , ports-committers X-BeenThere: svn-ports-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the ports tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Sep 2014 04:29:58 -0000 On Sun, Sep 14, 2014 at 11:28:37AM +0200, Tijl Coosemans wrote: > 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. Such an awesome explanation must find its way into PHB I think! ./danfe (who is also tired of seeing people patch for -pthread in 2014)