Specify -xthreadvar to control the implementation of thread local variables. Use this option in conjunction with the __thread declaration specifier to take advantage of the compiler’s thread-local storage facility. After you declare the thread variables with the __thread specifier, specify -xthreadvar to enable the use of thread-local storage with position dependent code (non-PIC code) in dynamic (shared) libraries. For more information on how to use __thread, see 4.2 Thread-Local Storage.
o must be one of the following:
Table A–51 The -xthreadvar Values
Value |
Meaning |
---|---|
[no%]dynamic |
[Do not] Compile variables for dynamic loading. Access to thread variables is significantly faster when -xthreadvar=no%dynamic but you cannot use the object file within a dynamic library. That is, you can only use the object file in an executable file. |
If you do not specify -xthreadvar, the default used by the compiler depends upon whether or not position-independent code is enabled. If position-independent code is enabled, the option is set to -xthreadvar=dynamic. If position-independent code is disabled, the option is set to -xthreadvar=no%dynamic.
If you specify -xthreadvar but do not specify any arguments, the option is set to -xthreadvar=dynamic.
Using thread variables on different versions of Solaris software requires different options on the command line.
On Solaris 8 software, objects that use __thread must be compiled with -mt and must be linked with -mt -L/usr/lib/lwp -R/usr/lib/lwp.
On Solaris 9 software, objects that use __thread must be compiled and linked with -mt.
If there is non-position-independent code within a dynamic library, you must specify -xthreadvar.
The linker cannot support the thread-variable equivalent of non-PIC code in dynamic libraries. Non-PIC thread variables are significantly faster, and hence should be the default for executables.
-xcode, -KPIC, -Kpic