[PATCH] D96699: [LLD] [COFF] Allow invoking lib.exe mode via -lib in addition to /lib

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 15 23:00:50 PST 2021


mstorsjo updated this revision to Diff 323890.
mstorsjo added a comment.
Herald added subscribers: steven_wu, hiraditya.

Fixed an issue with a test that only manifests if the test dir is cleaned before running the tests, that had a stray "-lib" argument that only caused warnings before, but now caused the tests to break.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96699/new/

https://reviews.llvm.org/D96699

Files:
  lld/COFF/Driver.cpp
  lld/test/COFF/driver.test
  lld/test/COFF/guardcf-lto.ll


Index: lld/test/COFF/guardcf-lto.ll
===================================================================
--- lld/test/COFF/guardcf-lto.ll
+++ lld/test/COFF/guardcf-lto.ll
@@ -1,7 +1,7 @@
 ; REQUIRES: x86
 ; Set up an import library for a DLL that will do the indirect call.
 ; RUN: echo -e 'LIBRARY library\nEXPORTS\n  do_indirect_call\n' > %t.def
-; RUN: lld-link -lib -def:%t.def -out:%t.lib -machine:x64
+; RUN: lld-link -def:%t.def -out:%t.lib -machine:x64
 
 ; Generate an object that will have the load configuration normally provided by
 ; the CRT.
Index: lld/test/COFF/driver.test
===================================================================
--- lld/test/COFF/driver.test
+++ lld/test/COFF/driver.test
@@ -11,6 +11,7 @@
 BADFILE: bad file type. Did you specify a DLL instead of an import library?
 
 # RUN: lld-link /lib /help | FileCheck -check-prefix=LIBHELP %s
+# RUN: lld-link -lib -help | FileCheck -check-prefix=LIBHELP %s
 LIBHELP: OVERVIEW: LLVM Lib
 
 # RUN: env LLD_IN_TEST=1 not lld-link /WX /lib 2>&1 | FileCheck -check-prefix=LIBBAD %s
Index: lld/COFF/Driver.cpp
===================================================================
--- lld/COFF/Driver.cpp
+++ lld/COFF/Driver.cpp
@@ -1210,7 +1210,8 @@
 
   // If the first command line argument is "/lib", link.exe acts like lib.exe.
   // We call our own implementation of lib.exe that understands bitcode files.
-  if (argsArr.size() > 1 && StringRef(argsArr[1]).equals_lower("/lib")) {
+  if (argsArr.size() > 1 && (StringRef(argsArr[1]).equals_lower("/lib") ||
+                             StringRef(argsArr[1]).equals_lower("-lib"))) {
     if (llvm::libDriverMain(argsArr.slice(1)) != 0)
       fatal("lib failed");
     return;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D96699.323890.patch
Type: text/x-patch
Size: 1712 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210216/fc4a4571/attachment.bin>


More information about the llvm-commits mailing list