[lld] 075539d - [LLD] [COFF] Allow invoking lib.exe mode via -lib in addition to /lib

Martin Storsjö via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 24 01:20:42 PST 2021


Author: Martin Storsjö
Date: 2021-02-24T11:16:12+02:00
New Revision: 075539ddf6525f5dac31d9b5506cd58c44108633

URL: https://github.com/llvm/llvm-project/commit/075539ddf6525f5dac31d9b5506cd58c44108633
DIFF: https://github.com/llvm/llvm-project/commit/075539ddf6525f5dac31d9b5506cd58c44108633.diff

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

Remove a stray -lib argument in guardcf-lto.ll; llvm-lib doesn't
support generating import libs from a def file unlike lib.exe.
Previously this worked because the -lib argument was ignored
(printing only a warning).

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

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp
index 07fa7cc14f4c..69ed2922309e 100644
--- a/lld/COFF/Driver.cpp
+++ b/lld/COFF/Driver.cpp
@@ -1244,7 +1244,8 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
 
   // 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;

diff  --git a/lld/test/COFF/driver.test b/lld/test/COFF/driver.test
index 363df6d8fb31..8f58ff44e83e 100644
--- a/lld/test/COFF/driver.test
+++ b/lld/test/COFF/driver.test
@@ -11,6 +11,7 @@ VERSION: {{LLD [0-9]+\.[0-9]+}}
 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

diff  --git a/lld/test/COFF/guardcf-lto.ll b/lld/test/COFF/guardcf-lto.ll
index e3655377a9f6..7811f442ef39 100644
--- a/lld/test/COFF/guardcf-lto.ll
+++ b/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.


        


More information about the llvm-commits mailing list