COFF: Add search paths in the correct order.

Previously, we added search paths in reverse order.

llvm-svn: 240180
This commit is contained in:
Rui Ueyama 2015-06-19 21:44:32 +00:00
parent 7f2a0d2c04
commit 165b254e06
2 changed files with 28 additions and 5 deletions

View File

@ -288,11 +288,8 @@ bool LinkerDriver::link(int Argc, const char *Argv[]) {
Config->MachineType = MTOrErr.get();
// Handle /libpath
for (auto *Arg : Args->filtered(OPT_libpath)) {
// Inserting at front of a vector is okay because it's short.
// +1 because the first entry is always "." (current directory).
SearchPaths.insert(SearchPaths.begin() + 1, Arg->getValue());
}
for (auto *Arg : Args->filtered(OPT_libpath))
SearchPaths.push_back(Arg->getValue());
// Handle /nodefaultlib:<filename>
for (auto *Arg : Args->filtered(OPT_nodefaultlib))

View File

@ -0,0 +1,26 @@
# RUN: mkdir -p %t/a %t/b
# RUN: cp %p/Inputs/std64.lib %t/a/
# RUN: cp %p/Inputs/std64.lib %t/b/
# RUN: env LIB=%t/a lld -flavor link2 /out:%t.exe /entry:main /verbose \
# RUN: std64.lib /subsystem:console \
# RUN: %p/Inputs/hello64.obj /libpath:%t/b >& %t.log
# RUN: FileCheck -check-prefix=CHECK1 %s < %t.log
# RUN: lld -flavor link2 /out:%t.exe /entry:main /verbose std64.lib \
# RUN: /subsystem:console %p/Inputs/hello64.obj \
# RUN: /libpath:%t/a /libpath:%t/b >& %t.log
# RUN: FileCheck -check-prefix=CHECK1 %s < %t.log
CHECK1: Reading {{.*}}/a/std64.lib
# RUN: env LIB=%t/b lld -flavor link2 /out:%t.exe /entry:main /verbose \
# RUN: /subsystem:console std64.lib %p/Inputs/hello64.obj \
# RUN: /libpath:%t/a >& %t.log
# RUN: FileCheck -check-prefix=CHECK2 %s < %t.log
# RUN: lld -flavor link2 /out:%t.exe /entry:main /verbose /subsystem:console \
# RUN: std64.lib %p/Inputs/hello64.obj /libpath:%t/b /libpath:%t/a >& %t.log
# RUN: FileCheck -check-prefix=CHECK2 %s < %t.log
CHECK2: Reading {{.*}}/b/std64.lib