Re: Question about gcc -pthread option

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Paul Joselow <pjoselow@xxxxxxxxxxxxx> writes:

> I work at a company that uses pthreads.  I have some questions about what
> this option actually does during a compile.  There are cases where even
> though a program uses pthreads, the option was omitted from the compile and
> build and the program builds successfully.  So the questions involve what
> things will and will not work when the pthread option is used or omitted.
> This is a question I would like to answer across several architectures,
> specifically Alpha, Intel Linux, and Solaris.
> 
> I have been shown a case where common variables (e.g. errno) that should be
> local to each thread end up being shared across all threads if the pthread
> option is omitted.  What are the problems with always using the pthread
> option on all compiles and links regardless of whether a program uses
> pthreads or not?

In typical cases, the gcc -pthread option does a #define of _REENTRANT
and causes gcc to link against -lpthread.  That's it.

The library header files will typically act slightly different via
#ifdef _REENTRANT.  Changing the declaration of errno is a typical
case.

It's not surprising that some code works if you don't use -pthread.

Ian

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux