<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 --- - Clang fails to link program with extern address-taken initial-exec thread-local variable"
   href="http://llvm.org/bugs/show_bug.cgi?id=22083">22083</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Clang fails to link program with extern address-taken initial-exec thread-local variable
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>Linux
          </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>-New Bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>vonosmas@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>$ cat tmp/a.h 
__attribute__((tls_model("initial-exec")))
extern __thread unsigned long a;

$ cat tmp/a.cc 
#include "a.h"
int main() {
  return (unsigned long)(&a) % sizeof(a);
}

$ cat tmp/b.cc 
#include "a.h"
__thread unsigned long a;

$ ./bin/clang++ tmp/a.cc -c -o a.o ; ./bin/clang++ tmp/b.cc -c -o b.o ;
./bin/clang++ a.o b.o -o a.out ; ./a.out ; echo $?
/usr/bin/ld: a.o: TLS transition from R_X86_64_GOTTPOFF to R_X86_64_TPOFF32
against `a' at 0xd in section `.text' failed
/usr/bin/ld: final link failed: Bad value

Note that this example links and runs successfully if I use GCC or Clang 3.5</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>