[LLD][COFF] Identify /GL object files which are inside libraries

With D26647, we can already identify input object files compiled by cl.exe with
/GL. It seems to be helpful to do the same and print an error message for those
object files compiled with /GL but are inside libraries/archives too.

Reviewed By: rnk, thieta

Differential Revision: https://reviews.llvm.org/D131458
This commit is contained in:
Pengxuan Zheng 2022-08-08 17:49:08 -07:00
parent 9893b26dfa
commit c951edb7b2
3 changed files with 6 additions and 0 deletions

View File

@ -279,6 +279,10 @@ void LinkerDriver::addArchiveBuffer(MemoryBufferRef mb, StringRef symName,
} else if (magic == file_magic::bitcode) {
obj =
make<BitcodeFile>(ctx, mb, parentName, offsetInArchive, /*lazy=*/false);
} else if (magic == file_magic::coff_cl_gl_object) {
error(mb.getBufferIdentifier() +
": is not a native COFF file. Recompile without /GL?");
return;
} else {
error("unknown file type: " + mb.getBufferIdentifier());
return;

BIN
lld/test/COFF/Inputs/cl-gl.lib Executable file

Binary file not shown.

View File

@ -1,4 +1,6 @@
# RUN: not lld-link /out:%t.exe /entry:main %S/Inputs/cl-gl.obj >& %t.log
# RUN: FileCheck %s < %t.log
# RUN: not lld-link /out:%t.exe /entry:main %S/Inputs/cl-gl.lib >& %t1.log
# RUN: FileCheck %s < %t1.log
# CHECK: is not a native COFF file. Recompile without /GL