<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 --- - llvm-lib (and `lld-link /lib`) should error out on cl.exe LTCG obj files"
href="https://llvm.org/bugs/show_bug.cgi?id=31372">31372</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>llvm-lib (and `lld-link /lib`) should error out on cl.exe LTCG obj files
</td>
</tr>
<tr>
<th>Product</th>
<td>lld
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</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>COFF
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>nicolasweber@gmx.de
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>In <a href="https://crbug.com/672229">https://crbug.com/672229</a> we accidentally built some of our object files with
cl.exe /GL (which activates their link-time codegen, so .obj files are some
kind of IR, not a real .obj file).
C:\src\llvm-build-2015-mt>type a.cc
void f();
int main() {
f();
}
C:\src\llvm-build-2015-mt>type b.cc
void f() {
}
C:\src\llvm-build-2015-mt>bin\clang-cl.exe /c a.cc
C:\src\llvm-build-2015-mt>cl /c b.cc /GL /nologo
b.cc
In general, lld-link copes well with this:
C:\src\llvm-build-2015-mt>bin\lld-link.exe a.obj b.obj
error: b.obj: is not a native COFF file. Recompile without /GL
C:\src\llvm-build-2015-mt>lib /out:blib.lib b.obj /nologo /ltcg
C:\src\llvm-build-2015-mt>bin\lld-link.exe a.obj blib.lib
error: unknown file type: blib.lib
However, llvm-lib silently produces an empty lib file, which then leads to
confusing error messages with both lld-link.exe and link.exe:
C:\src\llvm-build-2015-mt>lld-link.exe /lib b.obj /out:blib2.lib
C:\src\llvm-build-2015-mt>bin\lld-link.exe a.obj blib2.lib
a.obj: undefined symbol: ?f@@YAXXZ
error: link failed
C:\src\llvm-build-2015-mt>link.exe a.obj blib2.lib /nologo
blib2.lib : warning LNK4003: invalid library format; library ignored
a.obj : error LNK2019: unresolved external symbol "void __cdecl f(void)"
(?f@@YAXXZ) referenced in function main
a.exe : fatal error LNK1120: 1 unresolved externals
llvm-lib should print some error and fail when fed LTCG'd obj files instead of
silently doing the wrong thing.</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>