/libpath should take precedence over LIB.
Previously, LIB took precedence over /libpath.
llvm-svn: 240182
}
// Parses LIB environment which contains a list of search paths.
-std::vector<StringRef> LinkerDriver::getSearchPaths() {
- std::vector<StringRef> Ret;
- // Add current directory as first item of the search paths.
- Ret.push_back("");
+void LinkerDriver::addLibSearchPaths() {
Optional<std::string> EnvOpt = Process::GetEnv("LIB");
if (!EnvOpt.hasValue())
- return Ret;
+ return;
StringRef Env = Alloc.save(*EnvOpt);
while (!Env.empty()) {
StringRef Path;
std::tie(Path, Env) = Env.split(';');
- Ret.push_back(Path);
+ SearchPaths.push_back(Path);
}
- return Ret;
}
static WindowsSubsystem inferSubsystem() {
return false;
}
+ // Construct search path list.
+ SearchPaths.push_back("");
+ for (auto *Arg : Args->filtered(OPT_libpath))
+ SearchPaths.push_back(Arg->getValue());
+ addLibSearchPaths();
+
// Handle /out
if (auto *Arg = Args->getLastArg(OPT_out))
Config->OutputFile = Arg->getValue();
}
Config->MachineType = MTOrErr.get();
- // Handle /libpath
- for (auto *Arg : Args->filtered(OPT_libpath))
- SearchPaths.push_back(Arg->getValue());
-
// Handle /nodefaultlib:<filename>
for (auto *Arg : Args->filtered(OPT_nodefaultlib))
Config->NoDefaultLibs.insert(doFindLib(Arg->getValue()));
class LinkerDriver {
public:
- LinkerDriver() : Alloc(AllocAux), SearchPaths(getSearchPaths()) {}
+ LinkerDriver() : Alloc(AllocAux) {}
bool link(int Argc, const char *Argv[]);
// Used by the resolver to parse .drectve section contents.
StringRef doFindLib(StringRef Filename);
// Parses LIB environment which contains a list of search paths.
- // The returned list always contains "." as the first element.
- std::vector<StringRef> getSearchPaths();
+ void addLibSearchPaths();
+ // Library search path. The first element is always "" (current directory).
std::vector<StringRef> SearchPaths;
+
std::set<std::string> VisitedFiles;
// Driver is the owner of all opened files.
-# RUN: mkdir -p %t/a %t/b
+# RUN: mkdir -p %t/a %t/b %t/c
# RUN: cp %p/Inputs/std64.lib %t/a/
# RUN: cp %p/Inputs/std64.lib %t/b/
+# RUN: cp %p/Inputs/std64.lib %t/c/
# 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: std64.lib /subsystem:console %p/Inputs/hello64.obj \
+# RUN: /libpath:%t/b /libpath:%t/c > %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
+CHECK1: b{{[/\\]}}std64.lib
-# 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: lld -flavor link2 /out:%t.exe /entry:main /verbose \
+# RUN: std64.lib /subsystem:console %p/Inputs/hello64.obj \
+# RUN: /libpath:%t/a /libpath:%t/b /libpath:%t/c > %t.log
# RUN: FileCheck -check-prefix=CHECK2 %s < %t.log
-CHECK2: Reading {{.*}}/b/std64.lib
+CHECK2: a{{[/\\]}}std64.lib