thread-local storage not supported for this target

Number:rdar://6850750 Date Originated:02-May-2009 08:11 PM
Status:Duplicate/4966836 Resolved:
Product:Developer Tools Product Version:Any
Classification:Other Bug Reproducible:Always
02-May-2009 08:11 PM Kyle McKay:

The __thread keyword as described in:

does not work.


1. Do the following from a shell prompt:

  echo '__thread int x;' | gcc -c -x c -

2. Notice the error message "thread-local storage not supported for this target"

3. It doesn't matter what "-arch" value is used, any supported "-arch" value or MACOSX_DEPLOYMENT_TARGET value produces the same error message.


Works great on other platforms (especially Linux).  The expectation is that it will work on Darwin/Mac OS X as well.


__thread is a very convenient programming tool when using threads.  Porting applications that make use of __thread to Darwin/Mac OS X is greatly complicated by lack of support for __thread.

Although the following message:

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.  The document is here:

06-May-2009 07:53 AM KIT CHEUNG :
This bug has been closed as Duplicate. We are tracking this known issue under the Bug ID listed above in the bug State (Duplicate/XXXX).


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!