summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2017-12-11 23:09:18 +0000
committerRui Ueyama <ruiu@google.com>2017-12-11 23:09:18 +0000
commitb59ceb106864bf5a777e89413b6140a5a4fc89d0 (patch)
treea12bd3260f541571cff1983f7065b8c5b308dc90
parent9d8ce23c9c3675ad80a78540ae968ef2c154836a (diff)
downloadbcm5719-llvm-b59ceb106864bf5a777e89413b6140a5a4fc89d0.tar.gz
bcm5719-llvm-b59ceb106864bf5a777e89413b6140a5a4fc89d0.zip
Do not read the same .lib file more than once.
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 Differential Revision: https://reviews.llvm.org/D41094 llvm-svn: 320434
-rw-r--r--lld/COFF/Driver.cpp2
-rw-r--r--lld/test/COFF/libpath.test8
2 files changed, 10 insertions, 0 deletions
diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp
index 0855d627af4..835c4b396ef 100644
--- a/lld/COFF/Driver.cpp
+++ b/lld/COFF/Driver.cpp
@@ -315,6 +315,8 @@ Optional<StringRef> LinkerDriver::findFile(StringRef Filename) {
bool Seen = !VisitedFiles.insert(Path.lower()).second;
if (Seen)
return None;
+ if (Path.endswith_lower(".lib"))
+ VisitedLibs.insert(sys::path::filename(Path));
return Path;
}
diff --git a/lld/test/COFF/libpath.test b/lld/test/COFF/libpath.test
index 1e1ce0908e8..77b4c546c99 100644
--- a/lld/test/COFF/libpath.test
+++ b/lld/test/COFF/libpath.test
@@ -16,3 +16,11 @@ CHECK1: b{{[/\\]}}std64.lib
# 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
OpenPOWER on IntegriCloud