summaryrefslogtreecommitdiffstats
path: root/contrib/llvm/tools/clang/lib/Driver/ToolChain.cpp
diff options
context:
space:
mode:
authoremaste <emaste@FreeBSD.org>2015-02-25 22:32:32 +0000
committeremaste <emaste@FreeBSD.org>2015-02-25 22:32:32 +0000
commitc01620e95226f709ada46f702fc18f0efbde253d (patch)
tree9bcf4353dc620447ca7cbce552fc58d26b5fcc76 /contrib/llvm/tools/clang/lib/Driver/ToolChain.cpp
parenta98c93ae725cddb4e66eb395835b27bc9f2587e5 (diff)
downloadFreeBSD-src-c01620e95226f709ada46f702fc18f0efbde253d.zip
FreeBSD-src-c01620e95226f709ada46f702fc18f0efbde253d.tar.gz
Implement the -fuse-ld= option.
Merge upstream Clang revision 211785: This commit implements the -fuse-ld= option, so that the user can specify -fuse-ld=bfd to use ld.bfd. This commit re-applies r194328 with some test case changes. It seems that r194328 was breaking macosx or mingw build because clang can't find ld.bfd or ld.gold in the given sysroot. We should use -B to specify the executable search path instead. Patch originally by David Chisnall. This is a direct commit to stable/10 as this is change is already included in Clang 3.5 in HEAD. The patch is also reworked slightly for Clang 3.4.1. Reviewed by: dim Sponsored by: The FreeBSD Foundation
Diffstat (limited to 'contrib/llvm/tools/clang/lib/Driver/ToolChain.cpp')
-rw-r--r--contrib/llvm/tools/clang/lib/Driver/ToolChain.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/contrib/llvm/tools/clang/lib/Driver/ToolChain.cpp b/contrib/llvm/tools/clang/lib/Driver/ToolChain.cpp
index 69b642e..003a362 100644
--- a/contrib/llvm/tools/clang/lib/Driver/ToolChain.cpp
+++ b/contrib/llvm/tools/clang/lib/Driver/ToolChain.cpp
@@ -15,6 +15,7 @@
#include "clang/Driver/Options.h"
#include "clang/Driver/SanitizerArgs.h"
#include "clang/Driver/ToolChain.h"
+#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Option/Arg.h"
#include "llvm/Option/ArgList.h"
@@ -146,6 +147,30 @@ std::string ToolChain::GetProgramPath(const char *Name) const {
return D.GetProgramPath(Name, *this);
}
+std::string ToolChain::GetLinkerPath() const {
+ if (Arg *A = Args.getLastArg(options::OPT_fuse_ld_EQ)) {
+ StringRef Suffix = A->getValue();
+
+ // If we're passed -fuse-ld= with no argument, or with the argument ld,
+ // then use whatever the default system linker is.
+ if (Suffix.empty() || Suffix == "ld")
+ return GetProgramPath("ld");
+
+ llvm::SmallString<8> LinkerName("ld.");
+ LinkerName.append(Suffix);
+
+ std::string LinkerPath(GetProgramPath(LinkerName.c_str()));
+ if (llvm::sys::fs::exists(LinkerPath))
+ return LinkerPath;
+
+ getDriver().Diag(diag::err_drv_invalid_linker_name) << A->getAsString(Args);
+ return "";
+ }
+
+ return GetProgramPath("ld");
+}
+
+
types::ID ToolChain::LookupTypeForExtension(const char *Ext) const {
return types::lookupTypeForExtension(Ext);
}
OpenPOWER on IntegriCloud