https://bugs.llvm.org/show_bug.cgi?id=36686

            Bug ID: 36686
           Summary: Recent COFF dso_local changes break Firefox ThinLTO
                    build
           Product: new-bugs
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedb...@nondot.org
          Reporter: dma...@mozilla.com
                CC: llvm-bugs@lists.llvm.org, raf...@espindo.la

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!

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to