[PATCH] D84465: [llvm-lib] Support adding short import library objects with llvm-lib

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 23 14:08:58 PDT 2020


mstorsjo created this revision.
mstorsjo added reviewers: hans, smeenai, amccarth.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.

This fixes PR 42837.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84465

Files:
  llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
  llvm/test/tools/llvm-lib/implibs.test


Index: llvm/test/tools/llvm-lib/implibs.test
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-lib/implibs.test
@@ -0,0 +1,12 @@
+Test that import libraries (and the members thereof) can be added to another
+static library.
+
+RUN: rm -rf %t
+RUN: mkdir -p %t
+
+RUN: echo -e "EXPORTS\nMyFunc" > %t/lib.def
+RUN: llvm-dlltool -m i386:x86-64 -l %t/lib.lib -d %t/lib.def -D lib.dll
+RUN: llvm-lib -out:%t/newlib.lib %t/lib.lib
+
+RUN: llvm-ar t %t/newlib.lib | FileCheck %s
+CHECK: lib.dll
Index: llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
===================================================================
--- llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
+++ llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
@@ -191,7 +191,8 @@
   file_magic Magic = identify_magic(MB.getBuffer());
 
   if (Magic != file_magic::coff_object && Magic != file_magic::bitcode &&
-      Magic != file_magic::archive && Magic != file_magic::windows_resource) {
+      Magic != file_magic::archive && Magic != file_magic::windows_resource &&
+      Magic != file_magic::coff_import_library) {
     llvm::errs() << MB.getBufferIdentifier()
                  << ": not a COFF object, bitcode, archive or resource file\n";
     exit(1);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84465.280252.patch
Type: text/x-patch
Size: 1263 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200723/15847c50/attachment.bin>


More information about the llvm-commits mailing list