set(ENABLE_X86_RELAX_RELOCATIONS OFF CACHE BOOL
"enable x86 relax relocations by default")
+set(CLANG_DEFAULT_LINKER "" CACHE STRING
+ "Default linker to use (linker name or absolute path, empty for platform default)")
+
set(CLANG_DEFAULT_CXX_STDLIB "" CACHE STRING
"Default C++ stdlib to use (\"libstdc++\" or \"libc++\", empty for platform default")
if (NOT(CLANG_DEFAULT_CXX_STDLIB STREQUAL "" OR
/* Bug report URL. */
#define BUG_REPORT_URL "${BUG_REPORT_URL}"
+/* Default linker to use. */
+#define CLANG_DEFAULT_LINKER "${CLANG_DEFAULT_LINKER}"
+
/* Default C++ stdlib to use. */
#define CLANG_DEFAULT_CXX_STDLIB "${CLANG_DEFAULT_CXX_STDLIB}"
protected:
MultilibSet Multilibs;
- const char *DefaultLinker = "ld";
ToolChain(const Driver &D, const llvm::Triple &T,
const llvm::opt::ArgList &Args);
return 0;
}
+ /// GetDefaultLinker - Get the default linker to use.
+ virtual const char *getDefaultLinker() const {
+ return "ld";
+ }
+
/// GetDefaultRuntimeLibType - Get the default runtime library variant to use.
virtual RuntimeLibType GetDefaultRuntimeLibType() const {
return ToolChain::RLT_Libgcc;
}
std::string ToolChain::GetLinkerPath() const {
- if (Arg *A = Args.getLastArg(options::OPT_fuse_ld_EQ)) {
- StringRef UseLinker = A->getValue();
-
- if (llvm::sys::path::is_absolute(UseLinker)) {
- // If we're passed -fuse-ld= with what looks like an absolute path,
- // don't attempt to second-guess that.
- if (llvm::sys::fs::exists(UseLinker))
- return UseLinker;
- } else {
- // If we're passed -fuse-ld= with no argument, or with the argument ld,
- // then use whatever the default system linker is.
- if (UseLinker.empty() || UseLinker == "ld")
- return GetProgramPath("ld");
-
- llvm::SmallString<8> LinkerName("ld.");
- LinkerName.append(UseLinker);
-
- std::string LinkerPath(GetProgramPath(LinkerName.c_str()));
- if (llvm::sys::fs::exists(LinkerPath))
- return LinkerPath;
- }
+ const Arg* A = Args.getLastArg(options::OPT_fuse_ld_EQ);
+ StringRef UseLinker = A ? A->getValue() : CLANG_DEFAULT_LINKER;
+
+ if (llvm::sys::path::is_absolute(UseLinker)) {
+ // If we're passed what looks like an absolute path, don't attempt to
+ // second-guess that.
+ if (llvm::sys::fs::exists(UseLinker))
+ return UseLinker;
+ } else if (UseLinker.empty() || UseLinker == "ld") {
+ // If we're passed -fuse-ld= with no argument, or with the argument ld,
+ // then use whatever the default system linker is.
+ return GetProgramPath(getDefaultLinker());
+ } else {
+ llvm::SmallString<8> LinkerName("ld.");
+ LinkerName.append(UseLinker);
+
+ std::string LinkerPath(GetProgramPath(LinkerName.c_str()));
+ if (llvm::sys::fs::exists(LinkerPath))
+ return LinkerPath;
+ }
+ if (A)
getDriver().Diag(diag::err_drv_invalid_linker_name) << A->getAsString(Args);
- return "";
- }
- return GetProgramPath(DefaultLinker);
+ return GetProgramPath(getDefaultLinker());
}
types::ID ToolChain::LookupTypeForExtension(StringRef Ext) const {
LibSuffix = tools::mips::getMipsABILibSuffix(Args, Triple);
getFilePaths().clear();
getFilePaths().push_back(computeSysRoot() + "/usr/lib" + LibSuffix);
-
- // Use LLD by default.
- DefaultLinker = "lld";
}
void MipsLLVMToolChain::AddClangSystemIncludeArgs(
getFilePaths().push_back(D.SysRoot + "/lib");
getFilePaths().push_back(D.ResourceDir + "/lib/fuchsia");
-
- // Use LLD by default.
- DefaultLinker = "lld";
}
Tool *Fuchsia::buildAssembler() const {
assert(Triple.isArch32Bit() != Triple.isArch64Bit());
getFilePaths().push_back(
getDriver().SysRoot + "/lib" + (Triple.isArch32Bit() ? "32" : "64"));
-
- // Use LLD by default.
- DefaultLinker = "lld";
}
bool WebAssembly::IsMathErrnoDefault() const { return false; }
: RuntimeLibType::RLT_CompilerRT;
}
+ const char *getDefaultLinker() const override {
+ return "lld";
+ }
+
private:
Multilib SelectedMultilib;
std::string LibSuffix;
void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs) const override;
+ const char *getDefaultLinker() const override {
+ return "lld";
+ }
+
protected:
Tool *buildAssembler() const override;
Tool *buildLinker() const override;
const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const override;
+ const char *getDefaultLinker() const override {
+ return "lld";
+ }
+
Tool *buildLinker() const override;
};