svn commit: r381955 - head/graphics/gdal

David Chisnall theraven at FreeBSD.org
Mon Mar 23 09:19:37 UTC 2015


On 23 Mar 2015, at 01:58, Alexey Dokuchaev <danfe at FreeBSD.ORG> wrote:
> 
> Is -pthread going away anytime soon?  I'm a bit worried of more alike
> changing one to another; since they're identical right now on FreeBSD,
> I'd rather reduce amount of patching, leaving whatever is picked by
> upstream, unless -lpthread really should be preferred over -pthread
> for some reason I'm unaware of (and ready to learn about).

Tijl's comment on the blog is incomplete.  The history of -pthread goes back to the creation of the POSIX threading standard and predates FreeBSD implementation.  Pthreads were designed to support multiple implementations (N:M with scheduler activations, 1:1 with kernel threads, and N:1 with a modified C library that used timer interrupts and substituted asynchronous system calls for sync ones).  A number of the prototype implementations exposed different things in headers when compiling with pthreads support, hidden behind #ifdef _REENTRANT or #ifdef _MT.  In particular, a number of fast path macros that only worked in the single-threaded case needed removing.  On some systems, you needed a completely different set of libc headers.

The -pthread flag was intended as a compiler and linker flag, providing the correct predefined macros (and alternate include paths) for the system when building with thread support as well as linking the pthread library (if one is required).  Today, -pthread on FreeBSD as a linker flag is identical to -lpthread.  As a compile flag, I believe that -pthread is silently accepted, whereas -lpthread will give a unused argument warning.

The -pthread flag was proposed for inclusion in UNIX98, but was never consistently or widely adopted.  It's basically dead now, though not actively harmful.  There is no particular reason to prefer one form to the other (-pthread is, in theory, more portable, though theory and practice can differ).

David



More information about the svn-ports-head mailing list