gccaixportingxlc

What is the gcc equivilant for Xlc '-qthreaded' compiler option?


I am currently porting my compiler from AIX XLC compiler to GCC compiler on AIX.

I want to know if there is an GCC equivalent compiler option available for the -qthreaded (XLC).


Solution

  • -pthread is the closest GCC option for use cases where -qthreaded is applied for XL; however, it is not equivalent to the -qthreaded option for IBM XL.

    The GCC documentation for -pthread merely states that it sets macros (http://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html#index-pthread) and modifies the link step (http://gcc.gnu.org/onlinedocs/gcc/Link-Options.html#index-pthread-1). -qthreaded does not cause _THREAD_SAFE to be defined as a macro, nor does it cause -lpthreads to be present in the link step. GCC's -pthread is more like XL's _r invocations (which does set the macro and modify the link step).

    What -qthreaded does is to disable optimizations that are unsafe for multithreaded programs. It appears that, at least historically, -fno-tree-loop-if-convert-stores would at least partially be a GCC equivalent to -qthreaded.