<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 - thread_local variables are not aligned properly on NetBSD"
   href="https://bugs.llvm.org/show_bug.cgi?id=40120">40120</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>thread_local variables are not aligned properly on NetBSD
          </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>enhancement
          </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>mgorny@gentoo.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Demonstration program:

  #include <cstdio>

  struct alignas(64) a {
    int x;
  };

  void b() {
    thread_local a as_tls;

    printf("as tls: %p\n", &as_tls);
  }

  int main() {
    b();
    return 0;
  }

The result is:

  as tls: 0x7f7ff7efe068

which is clearly not aligned properly.  However, clang/llvm seems to assume the
alignment will take place and generates MOVAPS instructions that segfault due
to wrong alignment.

FWIU, this is a bug in NetBSD ld.so but it's not expected to be fixed anytime
soon.  Is there any chance for a short-term solution that would e.g. add make
LLVM take more TLS space and round the returned address to obtain necessary
alignment?</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>