[cfe-dev] __thread support in Clang
Jean-Daniel Dupas
devlists at shadowlab.org
Wed Mar 2 00:37:36 PST 2011
Le 2 mars 2011 à 08:07, Anatol Pomozov a écrit :
> Hi
>
> On Tue, Mar 1, 2011 at 10:19 PM, Eric Christopher <echristo at apple.com> wrote:
>>
>> On Mar 1, 2011, at 10:11 PM, Anatol Pomozov wrote:
>>
>>> Hi,
>>>
>>> I am trying to port a program from Linux to macosx. The program uses
>>> several features one of them is Thread-Local Storage. It uses __thread
>>> GCC attribute for this.
>>>
>>> The program compiles fine on Linux i386 but fails on macosx
>>> 10.6.4/clang2.8 with following error: "error: thread-local storage is
>>> unsupported for the current target"
>>>
>>> My question is: what is the status of this feature?
>>
>> It depends on the OS, it isn't a clang specific feature.
>
> Is it spcific to OS or binary format? I have following simple program
>
> __thread int a = 0;
> void main() {
> a = 2;
> }
>
> that is fails to compile with gcc-4.2 and clang-2.8 but compiles fine
> with gcc-4.5 from macports. I believe that gcc-4.5 has support of this
> feature on macosx. The binary produced by gcc-4.5 is Mach-O file.
> $ file ./a.out
> ./a.out: Mach-O 64-bit executable x86_64
>
> I also googled following ticket that requests __thread "support on
> macosx" http://openradar.appspot.com/6850750 . It is closed as
> duplicated of an internal issue. The reporter claims "suggests that
> the specification of thread-local storage (tls) is ELF specific, it
> really isn't. In fact the document referred to by the gcc page
> referenced in "SUMMARY:" describes the required implementation details
> and they are easily implemented on Darwin/Mac OS X without any need
> for ELF."
>
There is nothing official here, but we can hope to see __thread support in the future on OS X.
Mach-O TSL generation was added to llvm so times ago, and clang accept to compile it if target is darwin 11 ;-)
-- Jean-Daniel
More information about the cfe-dev
mailing list