<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - regression: unable to link thread local variable expected R_X86_64_PLT32 or R_X86_64_GOTPCRELX after R_X86_64_TLSLD"
   href="https://bugs.llvm.org/show_bug.cgi?id=40652">40652</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>regression: unable to link thread local variable expected R_X86_64_PLT32 or R_X86_64_GOTPCRELX after R_X86_64_TLSLD
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>lld
          </td>
        </tr>

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

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>release blocker
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>ELF
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>andrew@ziglang.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, peter.smith@linaro.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=21446" name="attach_21446" title="test.ll">attachment 21446</a> <a href="attachment.cgi?id=21446&action=edit" title="test.ll">[details]</a></span>
test.ll

Zig frontend code:

threadlocal var x: i32 = 1234;
pub fn main() void {
    x += 1;
}


With LLVM 7.0.0 and LLD 7.0.0, works correctly. With LLVM 8.0.0rc2 and LLD
8.0.0rc2, gives this error:

ld.lld: error: test:(.rodata+0xED): expected R_X86_64_PLT32 or
R_X86_64_GOTPCRELX after R_X86_64_TLSLD

Repro:

clang-8 -o test test.ll -nostdlib memcpy.c -fuse-ld=lld

memcpy.c:
void *memcpy(char *dest, char *src, unsigned n) {
    for (unsigned i = 0; i < n; i += 1) {
        dest[i] = src[i];
    }
    return dest;
}</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>