threading in FreeBSD (acx_pthreads)

Daniel Eischen deischen at freebsd.org
Mon Feb 4 08:16:19 PST 2008


On Mon, 4 Feb 2008, Karl H. Beckers wrote:

> Thanks so far,
>
> acx_pthread is this autoconf m4 macro:
> http://ac-archive.sourceforge.net/ac-archive/acx_pthread.html

I don't see anything wrong with that macro.  If I understand it
correctly, it should work on FreeBSD and pick up "-pthread".

> It looks rather promising. And while I might copy it over and fix it
> locally, I would like to escalate this upstream, if the algorithm there is
> wrong.
> Either way, I'd need to know what the correct way is.
> What I understood now is:
> On current versions -lpthread should work. On some older versions I should
> be using -lthr (so not -lc_r, then?).

No, do not use -lpthread.  Refer to John Baldwin's response, -pthread is
what you should be using.  Also, our ports system allows one to override
-pthread (the default) with PTHREAD_LIBS and PTHREAD_CFLAGS.  I suspect
that part of the macro came from us (FreeBSD).  Please do not escalate
anything upstream without checking with our ports team, as it looks like
the m4 macro has already been adjusted for FreeBSD.

> Is there a safe way to check whether we're running a version that needs
> -lthr? In the varnish example you provided, I cannot find a check for
> it?!?

-- 
DE


More information about the freebsd-threads mailing list