[llvm] 4d09ed9 - [llvm-lib] Support adding short import library objects with llvm-lib

Martin Storsjö via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 24 12:15:18 PDT 2020


Author: Martin Storsjö
Date: 2020-07-24T22:15:08+03:00
New Revision: 4d09ed953b5b8c70d9ca0aeaed8f26a237b612c6

URL: https://github.com/llvm/llvm-project/commit/4d09ed953b5b8c70d9ca0aeaed8f26a237b612c6
DIFF: https://github.com/llvm/llvm-project/commit/4d09ed953b5b8c70d9ca0aeaed8f26a237b612c6.diff

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

This fixes PR 42837.

Differential Revision: https://reviews.llvm.org/D84465

Added: 
    llvm/test/tools/llvm-lib/implibs.test

Modified: 
    llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
    llvm/test/tools/llvm-lib/invalid.test

Removed: 
    


################################################################################
diff  --git a/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp b/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
index c40901255424..cd39428b9c38 100644
--- a/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
+++ b/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
@@ -191,9 +191,11 @@ static void appendFile(std::vector<NewArchiveMember> &Members,
   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";
+                 << ": not a COFF object, bitcode, archive, import library or "
+                    "resource file\n";
     exit(1);
   }
 

diff  --git a/llvm/test/tools/llvm-lib/implibs.test b/llvm/test/tools/llvm-lib/implibs.test
new file mode 100644
index 000000000000..ebff4bb4608f
--- /dev/null
+++ b/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

diff  --git a/llvm/test/tools/llvm-lib/invalid.test b/llvm/test/tools/llvm-lib/invalid.test
index 57266400cdc8..a4b06a03358b 100644
--- a/llvm/test/tools/llvm-lib/invalid.test
+++ b/llvm/test/tools/llvm-lib/invalid.test
@@ -1,2 +1,2 @@
 RUN: not llvm-lib %S/Inputs/cl-gl.obj 2>&1 | FileCheck %s
-CHECK: not a COFF object, bitcode, archive or resource file
+CHECK: not a COFF object, bitcode, archive, import library or resource file


        


More information about the llvm-commits mailing list