Escalated to Bugzilla from IssueTracker
Event posted on 07-21-2010 12:46pm EDT by woodard
Description of problem:
The info page says one thing:
Add support for multithreading using the POSIX threads library.
This option sets flags for both the preprocessor and linker. It
does not affect the thread safety of object code produced by the
compiler or that of libraries supplied with it. These are HP-UX
This email says something else:
It looks like the docs need to be updated a bit.
This issue needs to be cloned for RHEL5 as well. Same problem.
This event sent from IssueTracker by tgummels [LLNL (HPC)]
Email referenced in Comment 1
Magnus Fromreide <email@example.com> writes:
> I recently ended up in a discussion about the -pthread flag at work and
> when looking at the documentation I noticed that it is defined onlt for
> SPARC and RS/6000/PowerPC.
> Additionally -fopenmp and -ftree-parallelize-loops say they are only
> supported on targets where -pthread are available.
> Now, on x86-linux it seems as if -pthread does something but there is no
> documentation of it so I'd like to know
> * What does -pthread do on x86?
On x86 GNU/Linux -pthread defines _REENTRANT for the preprocessor and
links against -lpthread.
> * If I am to compile a threaded program am I then requiered to use
On GNU/Linux, you need to use -pthread or -D_REENTRANT at compilation
time, and you need to use -pthread or -lpthread at link time.
I agree that this really ought to be documented.
-D_REENTRANT has so little effect on Linux that it is IMNSHO not worth mentioning.
It affects only presence of getlogin_r prototype in unistd.h, but that prototype is defined either if _REENTRANT is defined, or if POSIX >= 199506 is requested (the latter is by default, unless you request strict compliance with something older). So, in reality, -pthread is basically ignored during compilation, and during linking it is just equivalent of -lpthread.
Development Management has reviewed and declined this request. You may appeal
this decision by reopening this request.