Hi rnk, ruiu,
http://reviews.llvm.org/D6428
Files:
lib/Driver/MSVCToolChain.cpp
lib/Driver/Tools.cpp
Index: lib/Driver/MSVCToolChain.cpp
===================================================================
--- lib/Driver/MSVCToolChain.cpp
+++ lib/Driver/MSVCToolChain.cpp
@@ -43,6 +43,9 @@
MSVCToolChain::MSVCToolChain(const Driver &D, const llvm::Triple& Triple,
const ArgList &Args)
: ToolChain(D, Triple, Args) {
+ getProgramPaths().push_back(getDriver().getInstalledDir());
+ if (getDriver().getInstalledDir() != getDriver().Dir)
+ getProgramPaths().push_back(getDriver().Dir);
}
Tool *MSVCToolChain::buildLinker() const {
Index: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -7976,10 +7976,31 @@
A.renderAsInput(Args, CmdArgs);
}
- // 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.
- llvm::SmallString<128> linkPath(FindVisualStudioExecutable(
- getToolChain(), "link.exe", C.getDriver().getClangProgramPath()));
+ // We need to special case some linker paths. In the case of lld, we need to
+ // translate 'lld' into 'lld-link', and in the case of the regular msvc
+ // linker, we need to use a special search algorithm.
+ llvm::SmallString<128> linkPath;
+ Arg *A = Args.getLastArg(options::OPT_fuse_ld_EQ);
+ const char *ld_value = nullptr;
+ if (A) {
+ ld_value = A->getValue();
+ if (StringRef(ld_value).equals_lower("lld"))
+ ld_value = "lld-link";
+ } else {
+ ld_value = "link";
+ }
+ if (StringRef(ld_value).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 = ld_value;
+ llvm::sys::path::replace_extension(linkPath, "exe");
+ linkPath = getToolChain().GetProgramPath(linkPath.c_str());
+ }
+
const char *Exec = Args.MakeArgString(linkPath);
C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs));
}
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits