- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm trying to compile some C code which makes use of the __thread keyword, to indicate thread-local storage, but on OS X (Mavericks) I get the following error:
./tls.c(6): error #1781: thread-local storage is not supported in this environment
static long __thread x[MAX_SLOTS];
Whilst investigating the error, I've found that although Mach-O object files don't provide a dedicated area for thread-local storage variables (like ELF object files apparently do) other OS X compilers (e.g. clang 5.0 and gcc-4.8) do recognise and compile files containing __thread.
I did find some Intel documentation regarding the __thread keyword, which suggests using the compile argument -gcc-version=XXX, but this just prints out a deprecation warning and still results in the above error. (I tried adding a hyperlink to the page I found, but this triggers the spam filter)
I attach a fairly simple MWE in C99, which creates some threads that access TLS. The pthreads workaround (using pthread_key_create, pthread_setspecific, pthread_getspecific and pthread_key_delete) adds a lot of code bloat that would be desirable to avoid.
Compile command used:-
[compiler] ./tls.c -o tls -std=c99 -Wall
where compiler was one of gcc-4.8, clang or icc
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi albl500,
Unfortunately, Intel C++ compiler currently does not support TLS. Sorry about that -- we intend to introduce TLS support in 15.0, but please don't consider this to be an official "promise" (the only thing I can guarantee is that we are working on this).
Andrey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've added your request to our database. when the feature is available, we will let you know.
Thanks,
Jennifer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The TLS support for Mac has been added into 15.0 compiler. FYI.
Thanks.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page