<html>
<head>
<base href="https://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 --- - Clang forms weak external COFF aliases to base class destructors which fail to link"
href="https://llvm.org/bugs/show_bug.cgi?id=25477">25477</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Clang forms weak external COFF aliases to base class destructors which fail to link
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</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>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>LLVM Codegen
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>rnk@google.com
</td>
</tr>
<tr>
<th>CC</th>
<td>david.majnemer@gmail.com, llvm-bugs@lists.llvm.org, rafael.espindola@gmail.com
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Consider:
$ cat t.cpp
struct A {
virtual ~A();
};
template <typename T> struct B : A {
virtual ~B() {}
};
#ifdef CONFIG1
A::~A() {}
template struct B<int>;
#else
extern template struct B<int>;
int main() { B<int> b; }
#endif
$ clang-cl -O1 t.cpp -DCONFIG1 -c -Fot1.obj
$ clang-cl t.cpp -Fot2.obj -c
$ link t1.obj t2.obj -out:t.exe
Microsoft (R) Incremental Linker Version 12.00.31101.0
Copyright (C) Microsoft Corporation. All rights reserved.
t1.obj : error LNK2001: unresolved external symbol "public: virtual __cdecl
B<int>::~B<int>(void)" (??1?$B@H@@UEAA@XZ)
t2.obj : error LNK2001: unresolved external symbol "public: virtual __cdecl
B<int>::~B<int>(void)" (??1?$B@H@@UEAA@XZ)
t.exe : fatal error LNK1120: 1 unresolved externals
So, the Microsoft linker does not appear to work the way we think it does with
regard to weak externals. I reduced this from STLPort, which uses extern
template instantiations like these for basic_ios.
I guess I'll change this stuff that looks for dllexport to look for COFF
instead:
// Don't create a weak alias for a dllexport'd symbol.
if (AliasDecl.getDecl()->hasAttr<DLLExportAttr>() &&
llvm::GlobalValue::isWeakForLinker(Linkage))
return true;</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>