[LLD][COFF] Convert file name to lowercase when inserting it into visitedLibs
authorPengxuan Zheng <pzheng@quicinc.com>
Tue, 14 Jun 2022 02:22:14 +0000 (19:22 -0700)
committerPengxuan Zheng <pzheng@quicinc.com>
Wed, 15 Jun 2022 16:39:35 +0000 (09:39 -0700)
It seems to be a bug in `LinkerDriver::findFile`, the file name is not converted
to lowercase when being inserted into `visitedLibs`. This is the only exception
in the file and all other places always convert file names to lowercase when
inserting them into `visitedLibs` (or `visitedFiles`).

Reviewed By: thieta, hans

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

lld/COFF/Driver.cpp
lld/test/COFF/visitedlibs.test [new file with mode: 0644]

index d1c68d1..2843a9d 100644 (file)
@@ -473,7 +473,7 @@ Optional<StringRef> LinkerDriver::findFile(StringRef filename) {
   }
 
   if (path.endswith_insensitive(".lib"))
-    visitedLibs.insert(std::string(sys::path::filename(path)));
+    visitedLibs.insert(std::string(sys::path::filename(path).lower()));
   return path;
 }
 
diff --git a/lld/test/COFF/visitedlibs.test b/lld/test/COFF/visitedlibs.test
new file mode 100644 (file)
index 0000000..639a465
--- /dev/null
@@ -0,0 +1,10 @@
+# RUN: rm -rf %t && mkdir -p %t
+# RUN: cp %S/Inputs/hello64.obj %t
+# RUN: cp %S/Inputs/std64.lib %t/STD64.lib
+
+# RUN: lld-link %t/STD64.lib /out:%t.exe /entry:main \
+# RUN:   /subsystem:console %t/hello64.obj /defaultlib:STD64.lib \
+# RUN:   /verbose 2>&1 | FileCheck %s
+
+CHECK: Reading {{.*}}/STD64.lib
+CHECK-NOT: could not open 'STD64.lib'