[llvm-bugs] [Bug 44035] New: dllexported dtor and virtual base lead to undefined symbol in debug build
via llvm-bugs
llvm-bugs at lists.llvm.org
Sun Nov 17 13:59:11 PST 2019
https://bugs.llvm.org/show_bug.cgi?id=44035
Bug ID: 44035
Summary: dllexported dtor and virtual base lead to undefined
symbol in debug build
Product: clang
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: oktal3700 at gmail.com
CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
neeilans at live.com, richard-llvm at metafoo.co.uk
Created attachment 22829
--> https://bugs.llvm.org/attachment.cgi?id=22829&action=edit
repro testcase
When compiling the same code with clang-cl (r375090) and MSVS 2019 (16.3.9),
the LLVM toolchain fails with a linker error, while the Microsoft one does not.
error : undefined symbol: __declspec(dllimport) public: void __thiscall
derived::`vbase dtor'(void)
Full repro below (also in the attachment)
=== lib.h ===
struct base {
virtual LIBRARY_EXPORT ~base();
};
struct derived : public virtual base {
virtual LIBRARY_EXPORT ~derived();
};
=== lib.cpp ===
#define LIBRARY_EXPORT __declspec(dllexport)
#include "lib.h"
LIBRARY_EXPORT base::~base() = default;
LIBRARY_EXPORT derived::~derived() = default;
=== main.cpp ===
#define LIBRARY_EXPORT __declspec(dllimport)
#include "lib.h"
int main() {
derived{};
}
================
LLVM toolchain commands:
> clang-cl /c /Z7 /W3 /WX- /Od /D _WINDLL /D _MBCS /EHsc /MDd /GS /Gd /TP lib.cpp
> lld-link /OUT:"library.dll" /IMPLIB:"library.lib" /DLL lib.obj
> clang-cl /c /Z7 /W3 /WX- /Od /D _MBCS /EHsc /MDd /GS /Gd /TP main.cpp
> lld-link /OUT:"executable.exe" library.lib main.obj
Output:
lld-link : error : undefined symbol: __declspec(dllimport) public: void
__thiscall derived::`vbase dtor'(void)
>>> referenced by D:\Mat\Projects\test\executable\main.cpp:5
>>> Debug\main.obj:(_main)
>>> referenced by D:\Mat\Projects\test\library\lib.h:14
>>> Debug\main.obj:(public: virtual void * __thiscall derived::`scalar deleting dtor'(unsigned int))
The same commands with the Microsoft toolchain, giving no errors:
> cl /c /Z7 /W3 /WX- /Od /D _WINDLL /D _MBCS /EHsc /MDd /GS /Gd /TP lib.cpp
> link /OUT:"library.dll" /IMPLIB:"library.lib" /DLL lib.obj
> cl /c /Z7 /W3 /WX- /Od /D _MBCS /EHsc /MDd /GS /Gd /TP main.cpp
> link /OUT:"executable.exe" library.lib main.obj
I've also tried the release binaries of LLVM 8 and 9 and the same issue is
present.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20191117/1bc48e50/attachment.html>
More information about the llvm-bugs
mailing list