<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 - Recent COFF dso_local changes break Firefox ThinLTO build"
   href="https://bugs.llvm.org/show_bug.cgi?id=36686">36686</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Recent COFF dso_local changes break Firefox ThinLTO build
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

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

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

        <tr>
          <th>OS</th>
          <td>Windows NT
          </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>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>dmajor@mozilla.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, rafael@espindo.la
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Consider a library with a header that looks like this:

```
// MyLibrary.h
#ifdef BUILDING_MY_LIBRARY
#define MYAPI __declspec(dllexport)
#else
#define MYAPI __declspec(dllimport)
#endif
MYAPI MyFunc();
```

...and then in the same DLL where MyLibrary is implemented, there is also a
client of that library, which tries to dllimport MyFunc from its own DLL.

With link.exe we just get a warning LNK4049 and live with it. Same goes for
clang-cl with ThinLTO disabled, but when ThinLTO is enabled the build can't
continue.

------------------- Reproducer

$ cat a.cpp
__declspec(dllimport) int foo();
int main() { return foo(); }

$ cat b.cpp
__declspec(dllexport) int foo() { return 42; }

$ clang-cl -c -flto=thin a.cpp b.cpp
$ lld-link -nodefaultlib -entry:main a.obj b.obj

------------------- Before r325915/r325940:

lld-link: warning: lto.tmp: locally defined symbol imported: ?foo@@YAHXZ
(defined in lto.tmp)

------------------- After r325915/r325940:

GlobalValue with DLLImport Storage is dso_local!
i32 ()* @"\01?foo@@YAHXZ"
LLVM ERROR: Broken module found, compilation aborted!</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>