[lld] ec1998c - [lld][COFF] Don't handle an input file multiple times when retrying

Arthur Eubanks via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 6 11:09:35 PDT 2023


Author: Arthur Eubanks
Date: 2023-06-06T11:07:00-07:00
New Revision: ec1998cd48b5e4cd7894dd024f990c31ddb58e6d

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

LOG: [lld][COFF] Don't handle an input file multiple times when retrying

Follow up to D151815.

Or else we properly handle the first instance of a file, then error out on the second instance of the same file.

Reviewed By: rnk

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

Added: 
    

Modified: 
    lld/COFF/Driver.cpp
    lld/test/COFF/winsysroot.test

Removed: 
    


################################################################################
diff  --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp
index 9c479709db8aa..d1b28f6716871 100644
--- a/lld/COFF/Driver.cpp
+++ b/lld/COFF/Driver.cpp
@@ -262,6 +262,9 @@ void LinkerDriver::enqueuePath(StringRef path, bool wholeArchive, bool lazy) {
         ec = retryMb.getError();
         if (!ec)
           mb = std::move(*retryMb);
+      } else {
+        // We've already handled this file.
+        return;
       }
     }
     if (ec) {

diff  --git a/lld/test/COFF/winsysroot.test b/lld/test/COFF/winsysroot.test
index 4f5df0bd019a5..29df204fa96e0 100644
--- a/lld/test/COFF/winsysroot.test
+++ b/lld/test/COFF/winsysroot.test
@@ -26,16 +26,27 @@ Check directly passed lib without /machine: (should infer from obj arch)
 # RUN: lld-link %t.obj /winsysroot:%t.dir/sysroot \
 # RUN:          std32.lib /entry:main
 
+Check that passing a lib from /winsysroot twice is ok
+# RUN: lld-link %p/Inputs/hello64.obj /winsysroot:%t.dir/sysroot \
+# RUN:          std64.lib std64.lib /entry:main
+
+Check unknown library
+# RUN: not lld-link %p/Inputs/hello64.obj /winsysroot:%t.dir/sysroot \
+# RUN:          notfound.lib /entry:main 2>&1 | FileCheck --check-prefix=UNKNOWNLIB %s
+UNKNOWNLIB: could not open 'notfound.lib'
+
 If winsysroot lib appears before we can detect arch we don't find it
 # RUN: not lld-link std64.lib %p/Inputs/hello64.obj /winsysroot:%t.dir/sysroot \
-# RUN:          /entry:main
+# RUN:          /entry:main 2>&1 | FileCheck --check-prefix=NO64 %s
 
 Check we don't choose the wrong arch
 # RUN: not lld-link %t.obj /winsysroot:%t.dir/sysroot \
-# RUN:          std64.lib /entry:main
+# RUN:          std64.lib /entry:main 2>&1 | FileCheck --check-prefix=NO64 %s
+NO64: could not open 'std64.lib'
 
 # RUN: not lld-link %p/Inputs/hello64.obj /winsysroot:%t.dir/sysroot \
-# RUN:          std32.lib /entry:main
+# RUN:          std32.lib /entry:main 2>&1 | FileCheck --check-prefix=NO32 %s
+NO32: could not open 'std32.lib'
 
 Check that when /winsysroot is specified, %LIB% is ignored.
 # RUN: env LIB=foo.dir/sysroot/VC/Tools/MSVC/1.1.1.1/lib/x86 not lld-link %t.obj /winsysroot:%t.dir/doesnotexist /defaultlib:std32 2>&1 | FileCheck -check-prefix=LIBIGNORED %s


        


More information about the llvm-commits mailing list