thread-local storage not supported for this target

Originator:mackyle
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:
SUMMARY:

The __thread keyword as described in:

  http://developer.apple.com/DOCUMENTATION/DeveloperTools/gcc-4.0.1/gcc/Thread_002dLocal.html

does not work.


STEPS TO REPRODUCE:

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.


EXPECTED RESULT:

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


NOTES:

__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:

  http://lists.apple.com/archives/xcode-users/2006/Jun/msg00550.html

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:

  http://people.redhat.com/drepper/tls.pdf

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).

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com 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!