<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Thread-local storage is unsupported for the current target (iOS)"
   href="http://llvm.org/bugs/show_bug.cgi?id=19232">19232</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Thread-local storage is unsupported for the current target (iOS)
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++11
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>engineering@wukix.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Hello,

When targeting iOS with clang using the _Thread_local or __thread declarations
I get the error "Thread-local storage is unsupported for the current target".
It works fine when targeting OS X.

Example code:
(in foo.c)
#include <stdio.h>

__thread int foo;

Having this would be very valuable for mocl (<a href="https://wukix.com/mocl">https://wukix.com/mocl</a>) and I
suspect other languages targeting iOS as well. e.g.
<a href="http://forum.dlang.org/thread/m2d2k79zsl.fsf@comcast.net?page=3">http://forum.dlang.org/thread/m2d2k79zsl.fsf@comcast.net?page=3</a>
"D (also the runtime) relies fairly heavily on thread-local storage
support. LLVM provides an easy way of creating TLS variables via the
thread_local attribute, but support for that is not available on all
target platforms – and it seems that Darwin/ARM is one of them (they
work on Linux resp. glibc)."

I could go down the road of using the pthread functions for TLS, but this would
involve a lot of re-engineering. Having a simple declaration like __thread
allows me to port global variables designed for a single thread into a
multi-threaded context without causing a lot of breakage.

Curious what can be done to get this working on iOS? Willing to put in some
(limited) effort if you can point me in the right direction.

Wes Henderson
Wukix, Inc.
<a href="https://wukix.com">https://wukix.com</a></pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>