forked from OSchip/llvm-project
Make -fuse-ld=lld work properly on Windows.
Using lld on Windows requires calling link-lld.exe instead of lld.exe. This patch puts this knowledge into clang so that when using the GCC style clang driver, it can properly delegate to lld. Differential Revision: http://reviews.llvm.org/D6428 Reviewed by: Reid Kleckner, Rui Ueyama llvm-svn: 223086
This commit is contained in:
parent
0365f1a376
commit
719f58c228
|
@ -43,6 +43,9 @@ using namespace llvm::opt;
|
||||||
MSVCToolChain::MSVCToolChain(const Driver &D, const llvm::Triple& Triple,
|
MSVCToolChain::MSVCToolChain(const Driver &D, const llvm::Triple& Triple,
|
||||||
const ArgList &Args)
|
const ArgList &Args)
|
||||||
: ToolChain(D, Triple, Args) {
|
: ToolChain(D, Triple, Args) {
|
||||||
|
getProgramPaths().push_back(getDriver().getInstalledDir());
|
||||||
|
if (getDriver().getInstalledDir() != getDriver().Dir)
|
||||||
|
getProgramPaths().push_back(getDriver().Dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
Tool *MSVCToolChain::buildLinker() const {
|
Tool *MSVCToolChain::buildLinker() const {
|
||||||
|
|
|
@ -7982,10 +7982,26 @@ void visualstudio::Link::ConstructJob(Compilation &C, const JobAction &JA,
|
||||||
A.renderAsInput(Args, CmdArgs);
|
A.renderAsInput(Args, CmdArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
// It's not sufficient to just use link from the program PATH, because other
|
// We need to special case some linker paths. In the case of lld, we need to
|
||||||
// environments like GnuWin32 install their own link.exe which may come first.
|
// translate 'lld' into 'lld-link', and in the case of the regular msvc
|
||||||
llvm::SmallString<128> linkPath(FindVisualStudioExecutable(
|
// linker, we need to use a special search algorithm.
|
||||||
getToolChain(), "link.exe", C.getDriver().getClangProgramPath()));
|
llvm::SmallString<128> linkPath;
|
||||||
|
StringRef Linker = Args.getLastArgValue(options::OPT_fuse_ld_EQ, "link");
|
||||||
|
if (Linker.equals_lower("lld"))
|
||||||
|
Linker = "lld-link";
|
||||||
|
|
||||||
|
if (Linker.equals_lower("link")) {
|
||||||
|
// If we're using the MSVC linker, it's not sufficient to just use link
|
||||||
|
// from the program PATH, because other environments like GnuWin32 install
|
||||||
|
// their own link.exe which may come first.
|
||||||
|
linkPath = FindVisualStudioExecutable(getToolChain(), "link.exe",
|
||||||
|
C.getDriver().getClangProgramPath());
|
||||||
|
} else {
|
||||||
|
linkPath = Linker;
|
||||||
|
llvm::sys::path::replace_extension(linkPath, "exe");
|
||||||
|
linkPath = getToolChain().GetProgramPath(linkPath.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
const char *Exec = Args.MakeArgString(linkPath);
|
const char *Exec = Args.MakeArgString(linkPath);
|
||||||
C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs));
|
C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue