[llvm-bugs] [Bug 31372] New: llvm-lib (and `lld-link /lib`) should error out on cl.exe LTCG obj files
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Dec 14 07:32:28 PST 2016
https://llvm.org/bugs/show_bug.cgi?id=31372
Bug ID: 31372
Summary: llvm-lib (and `lld-link /lib`) should error out on
cl.exe LTCG obj files
Product: lld
Version: unspecified
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: COFF
Assignee: unassignedbugs at nondot.org
Reporter: nicolasweber at gmx.de
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
In https://crbug.com/672229 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.
--
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/20161214/1b452cc5/attachment.html>
More information about the llvm-bugs
mailing list