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

Pengxuan Zheng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 8 18:02:44 PDT 2022


pzheng created this revision.
pzheng added reviewers: ruiu, rnk, thieta, thakis, hans, mstorsjo.
Herald added a project: All.
pzheng requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

With D26647 <https://reviews.llvm.org/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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131458

Files:
  lld/COFF/Driver.cpp
  lld/test/COFF/Inputs/cl-gl.lib
  lld/test/COFF/cl-gl.test


Index: lld/test/COFF/cl-gl.test
===================================================================
--- lld/test/COFF/cl-gl.test
+++ lld/test/COFF/cl-gl.test
@@ -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
Index: lld/COFF/Driver.cpp
===================================================================
--- lld/COFF/Driver.cpp
+++ lld/COFF/Driver.cpp
@@ -279,6 +279,9 @@
   } 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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131458.451017.patch
Type: text/x-patch
Size: 999 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220809/6b2ca9eb/attachment.bin>


More information about the llvm-commits mailing list