[LLD][COFF] Convert file name to lowercase when inserting it into visitedLibs

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
This commit is contained in:
Pengxuan Zheng 2022-06-13 19:22:14 -07:00
parent ac2ad3b7bb
commit 9db61c3fe1
2 changed files with 11 additions and 1 deletions

View 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;
}

View File

@ -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'