[PATCH] D41094: Do not read the same .lib file more than once.

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 11 14:22:44 PST 2017


ruiu created this revision.

In the following command line,

  lld-link foo/bar.lib /defaultlib:bar.lib

"/defaultlib:bar.lib" should be a nop even if a file with the same
name exists in other library search path.

Fixes https://bugs.llvm.org/show_bug.cgi?id=35476


https://reviews.llvm.org/D41094

Files:
  lld/COFF/Driver.cpp
  lld/test/COFF/libpath.test


Index: lld/test/COFF/libpath.test
===================================================================
--- lld/test/COFF/libpath.test
+++ lld/test/COFF/libpath.test
@@ -16,3 +16,11 @@
 # RUN: FileCheck -check-prefix=CHECK2 %s < %t.log
 
 CHECK2: a{{[/\\]}}std64.lib
+
+# RUN: lld-link /out:%t.exe /entry:main /verbose \
+# RUN:   %t/a/std64.lib /subsystem:console %p/Inputs/hello64.obj \
+# RUN:   /libpath:%t/b /verbose > %t.log 2>&1
+# RUN: FileCheck -check-prefix=CHECK3 %s < %t.log
+
+CHECK3:     Reading {{.*}}a/std64.lib
+CHECK3-NOT: Reading {{.*}}b/std64.lib
Index: lld/COFF/Driver.cpp
===================================================================
--- lld/COFF/Driver.cpp
+++ lld/COFF/Driver.cpp
@@ -315,6 +315,8 @@
   bool Seen = !VisitedFiles.insert(Path.lower()).second;
   if (Seen)
     return None;
+  if (Path.endswith_lower(".lib"))
+    VisitedLibs.insert(sys::path::filename(Path));
   return Path;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41094.126446.patch
Type: text/x-patch
Size: 926 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171211/6af27535/attachment.bin>


More information about the llvm-commits mailing list