<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 --- - Change introduced in r207451 broke thread_local on Darwin"
   href="http://llvm.org/bugs/show_bug.cgi?id=19989">19989</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Change introduced in r207451 broke thread_local on Darwin
          </td>
        </tr>

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

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

        <tr>
          <th>Hardware</th>
          <td>Macintosh
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>MacOS X
          </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>oneill+llvmbugs@cs.hmc.edu
          </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>In r207451, majnemer moved code related to thread_local on Darwin (originally
written by void in r180941) out of CodeGenModule.cpp and into ASTContext.cpp,
in doing so, it changed the meaning of the code, from controlling the
visibility of the _backing store_ for a thread local variable to making the
entire variable static.

Obviously, this breaks things.

Test case:

Place the following line in defn.cpp

thread_local int perThread;

With a version of clang before this change (I happen to have 199067), we see 

darwin% ~/llvm.199067/bin/clang++ -std=c++11 -stdlib=libc++ -c defn.cpp
darwin% nm -m defn.o
0000000000000048 (__TEXT,__eh_frame) non-external EH_frame0
0000000000000000 (__TEXT,__text) private external __ZTW9perThread
0000000000000060 (__TEXT,__eh_frame) private external __ZTW9perThread.eh
                 (undefined) external __tlv_bootstrap
000000000000000f (__DATA,__thread_vars) non-external _perThread
0000000000000088 (__DATA,__thread_bss) non-external _perThread$tlv$init

In contrast, if we run the current head, we see this

darwin% ~/llvm.210506/bin/clang++ -std=c++11 -stdlib=libc++ -c defn.cpp
darwin% nm -m defn.o
warning:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/nm:
no name list

Oops, it threw everything away because it thought it was an unused static
variable!</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>