<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 --- - Shared library relocation R_X86_64_TPOFF32 with __thread"
   href="http://llvm.org/bugs/show_bug.cgi?id=17058">17058</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Shared library relocation R_X86_64_TPOFF32 with __thread
          </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>Driver
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>haael@interia.pl
          </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>I don't know if the code is completely correct, but I get the following error
when trying to compile a shared library:

ld: /tmp/tsd-cGUFwW.o: relocation R_X86_64_TPOFF32 against `function.data' can
not be used when making a shared object; recompile with -fPIC

Of course, recompiling with -fPIC gives the same error.

The offending code is:
===========================

int function(void)
{
  static __thread int data __attribute__ ((tls_model ("initial-exec")));
  return data;
}

===========================

I compile it as a shared library:

clang -nostdlib -shared -fPIC file.c

Adding or removing the -fPIC option does nothing. Compiling as a normal
executable works. The code also works when I remove the final return of the
data, possibly because the variable is optimized away.</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>