Thanks for your informative response, David!  This is what I really
wanted to know:
> All previous and current releases of GCC do not support
> native TLS on AIX.  GCC 4.8 will provide TLS on AIX, as listed in the
> announcements for the release.
Great! I'll look forward to testing with 4.8 when it becomes GA .
Thanks for comments on configuration options - points noted -  but I
was only copying
the options used for the IBM freeware GCC distribution.

But why didn't the compiler complain that TLS was not supported ?
Shouldn't it be doing so ?  It is definitely not OK in my book for gcc
to finish compilation and linkage with no errors or warnings, when
it has encountered a __thread usage that it must know will have no
effect.

And isn't there an easier way to determine if TLS is enabled or not
than by compiling a test program ?

Thanks & Regards,
Jason

On Mon, Mar 11, 2013 at 10:07 PM, David Edelsohn <dje....@gmail.com> wrote:
> On Mon, Mar 11, 2013 at 3:46 PM, Jason Vas Dias
> <jason.vas.d...@gmail.com> wrote:
>> Hi - I wonder if anyone could please tell me if gcc's thread local
>> storage support is meant to be enabled on AIX or not -
>> I've built gcc-4.7.2 on AIX 6.1 OK,   with "---enable-threads" ,
>> using the AIX system /usr/ccs/bin ld and as ,  both of which
>> claim to provide TLS support , but now this test program is getting
>> the same address for its  __thread variable in different threads -
>>  it is compiled and linked without warnings or error, and prints three
>> different addresses at the end on Linux, Solaris x86 & SPARC, and
>> HP-UX,
>> but not on AIX 6.1 .  This also happens with the IBM freeware
>> gcc-4.4.6.  Yet 4.7.2's libgomp was built OK ... doesn't this depend
>> on TLS?
>>
>> Must I use --enable-tls as well as --enable-threads in configuration
>> options and rebuild GCC ? Is this likely to work ?
>>
>> gcc-4.7.2 is reporting its thread model as 'aix' - shouldn't this be
>> 'posix' ( the system /usr/lib/libpthread.a is installed and the
>> pthread_* headers look POSIX compatible ).
>
>> Shouldn't GCC be terminating compilation with an error if it
>> encounters use of __thread when TLS is not enabled ?
>> Is there an option to enable this / if not , could one be added ?
>> Is there an option to make GCC tell the user if TLS is enabled or not
>> - again, if not, could there be one ?
>>
>> I don't think gcc should be allowing programmers to assume TLS is in
>> use when it is not - this is dangerous!
>>
>> If GCC does not support TLS with AIX 'ld' + 'as' (which seems likely),
>>  could this not be documented somewhere in the installation
>> documentation (it does not appear to be) ?   Any plans to enable it in
>> near future ?
>
> First, because of the way that AIX supports pthreads, GCC requires
> different libraries for pthread and non-pthread code.  GCC -pthread
> links with the pthread version of the libraries.  This is why thread
> model is reported as "aix" and not "posix".
>
> Second, when native TLS is not available, GCC emulates TLS using
> pthread keys.  All previous and current releases of GCC do not support
> native TLS on AIX.  GCC 4.8 will provide TLS on AIX, as listed in the
> announcements for the release.
>
> Third, one should not add configuration options like "--enable-tls" or
> "--enable-threads".  The defaults are correct and will enable the
> appropriate features for the system.  No one chose to implement a
> feature but leave it disabled by default.  No one is hiding features
> and one should not approach the configuration process by trying to
> force override options.
>
> Compiling your example with GCC 4.8 snapshot from last night produces
> the following on AIX 7.1:
>
> $ ./xgcc -B./ -O2 -pthread code.c
> $ ./a.out
> main : 200080d0 20112000 20218000
> $ ./xgcc -B./ -O2 -pthread -maix64 code.c
> $ ./a.out
> main : 11000de20 11011a000 110221000
>
> Thanks, David

Reply via email to