OSDN Git Service

LibDriver: Allow resource files to be archive members.
authorPeter Collingbourne <peter@pcc.me.uk>
Thu, 15 Dec 2016 19:37:46 +0000 (19:37 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Thu, 15 Dec 2016 19:37:46 +0000 (19:37 +0000)
It seems pointless to add a resource to an archive because it won't have
any symbols to link against (and link.exe doesn't have an equivalent of
--whole-archive), but lib.exe allows it for some reason.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@289859 91177308-0d34-0410-b5e6-96231b3b80d8

lib/LibDriver/LibDriver.cpp
test/LibDriver/Inputs/resource.res [new file with mode: 0644]
test/LibDriver/invalid.test
test/LibDriver/resource.test [new file with mode: 0644]

index fa9f02c..bcdec4f 100644 (file)
@@ -146,8 +146,10 @@ int llvm::libDriverMain(llvm::ArrayRef<const char*> ArgsArr) {
     sys::fs::file_magic Magic =
         sys::fs::identify_magic(MOrErr->Buf->getBuffer());
     if (Magic != sys::fs::file_magic::coff_object &&
-        Magic != sys::fs::file_magic::bitcode) {
-      llvm::errs() << Arg->getValue() << ": not a COFF object or bitcode file\n";
+        Magic != sys::fs::file_magic::bitcode &&
+        Magic != sys::fs::file_magic::windows_resource) {
+      llvm::errs() << Arg->getValue()
+                   << ": not a COFF object, bitcode or resource file\n";
       return 1;
     }
     Members.emplace_back(std::move(*MOrErr));
diff --git a/test/LibDriver/Inputs/resource.res b/test/LibDriver/Inputs/resource.res
new file mode 100644 (file)
index 0000000..f1c799f
Binary files /dev/null and b/test/LibDriver/Inputs/resource.res differ
index 2a8b68c..2978177 100644 (file)
@@ -1,2 +1,2 @@
 RUN: not llvm-lib %S/Inputs/cl-gl.obj 2>&1 | FileCheck %s
-CHECK: not a COFF object or bitcode file
+CHECK: not a COFF object, bitcode or resource file
diff --git a/test/LibDriver/resource.test b/test/LibDriver/resource.test
new file mode 100644 (file)
index 0000000..6c3dad5
--- /dev/null
@@ -0,0 +1,3 @@
+RUN: llvm-lib /out:%t %S/Inputs/resource.res
+RUN: llvm-ar t %t | FileCheck %s
+CHECK: resource.res