Skip to content

Commit

Permalink
[llvm-lib] Support adding short import library objects with llvm-lib
Browse files Browse the repository at this point in the history
This fixes PR 42837.

Differential Revision: https://reviews.llvm.org/D84465
  • Loading branch information
mstorsjo committed Jul 24, 2020
1 parent 9bb6ce7 commit 4d09ed9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
6 changes: 4 additions & 2 deletions llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
Expand Up @@ -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);
}

Expand Down
12 changes: 12 additions & 0 deletions 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
2 changes: 1 addition & 1 deletion 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

0 comments on commit 4d09ed9

Please sign in to comment.