In the documentation for GCC (6.2.0), it is treated as a platform-specific option. For RS6000 and PowerPC, it says:
-pthread
.
Adds support for multithreading with the pthreads library. This option sets flags for both the preprocessor and linker.
For Solaris 2, it says:
-pthreads
.
Add support for multithreading using the POSIX threads library. This option sets flags for both the preprocessor and linker. This option does not affect the thread safety of object code produced by the compiler or that of libraries supplied with it.
-pthread
.
This is a synonym for -pthreads
.
The common 'thread' (sorry — couldn't resist) is that it ensures that the code is compiled and linked with options that ensure that the POSIX threads library is used. The same will be true on other platforms where the option works (Linux, macOS Sierra, Mac OS X before it, …) it will link with the right library and enable any relevant preprocessor options.
You could compare the output of:
gcc -v -pthread -o x1 pthread-prog.c
gcc -v. -o x2 pthread-prog.c
to see what differences the -pthread
option makes. On macOS Sierra, it adds -D_REENTRANT
to the cc1
phase, and -pthread
to the 'COLLECT_GCC_OPTIONS' setting.