threading in FreeBSD (acx_pthreads)
Dag-Erling Smørgrav
des at des.no
Mon Feb 4 09:01:14 PST 2008
"Karl H. Beckers" <karl.h.beckers at gmx.net> writes:
> 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?).
> 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?!?
Sure you can. It explicitly tries -lthr *before* -lpthread, and -lc_r
as a final resort. The AC macro used will try each in sequence until
one works, and stick with that.
If your configure.ac only covers a single multi-threaded program, you
can make do with just the AC_SEARCH_LIBS invocation:
AC_SEARCH_LIBS(pthread_create, [thr pthread c_r])
If your configure.ac covers several programs, some of which are multi-
threaded and some of which aren't, you should use the full block, and
explicitly add ${PTHREAD_LIBS} to foo_LDADD in Makefile.am for the
multi-threaded programs only.
This has been tested on FreeBSD [678], various Linux distributions
(mostly 2.6-based), Mac OS X (10.3 and up) and Solaris 10.
On FreeBSD 7 and 8 and everything else I mentioned, -lpthread is fine,
but on FreeBSD 6, -lpthread will give you libkse which doesn't work,
hence -lthr to force libthr over libkse. IIRC, -lc_r is required for
certain FreeBSD platforms which don't have kernel-assisted threads, but
I'm pretty sure Varnish wouldn't be able to handle any kind of load if
built with libc_r.
DES
--
Dag-Erling Smørgrav - des at des.no
More information about the freebsd-threads
mailing list