Please use GitHub pull requests for new patches. Phabricator shutdown timeline
Changeset View
Standalone View
lib/Driver/ToolChain.cpp
Show First 20 Lines • Show All 335 Lines • ▼ Show 20 Lines | std::string ToolChain::GetFilePath(const char *Name) const { | ||||
return D.GetFilePath(Name, *this); | return D.GetFilePath(Name, *this); | ||||
} | } | ||||
std::string ToolChain::GetProgramPath(const char *Name) const { | std::string ToolChain::GetProgramPath(const char *Name) const { | ||||
return D.GetProgramPath(Name, *this); | return D.GetProgramPath(Name, *this); | ||||
} | } | ||||
std::string ToolChain::GetLinkerPath() const { | std::string ToolChain::GetLinkerPath() const { | ||||
if (Arg *A = Args.getLastArg(options::OPT_fuse_ld_EQ)) { | const Arg *A = Args.getLastArg(options::OPT_fuse_ld_EQ); | ||||
StringRef UseLinker = A->getValue(); | StringRef UseLinker = A ? A->getValue() : CLANG_DEFAULT_LINKER; | ||||
if (llvm::sys::path::is_absolute(UseLinker)) { | if (llvm::sys::path::is_absolute(UseLinker)) { | ||||
// If we're passed -fuse-ld= with what looks like an absolute path, | // If we're passed -fuse-ld= with what looks like an absolute path, | ||||
// don't attempt to second-guess that. | // don't attempt to second-guess that. | ||||
if (llvm::sys::fs::exists(UseLinker)) | if (llvm::sys::fs::exists(UseLinker)) | ||||
return UseLinker; | return UseLinker; | ||||
} else { | } else if (A && (UseLinker.empty() || UseLinker == "ld")) { | ||||
Hahnfeld: I wonder whether this is really correct: If `DefaultLinker` is not `ld` (it is `lld` for some… | |||||
I'm wandering whether we shouldn't use "platform" instead of "ld" here to match what we do for -rtlib= and -stdlib=? phosek: I'm wandering whether we shouldn't use `"platform"` instead of `"ld"` here to match what we do… | |||||
I'd say this is fine for compatibility Hahnfeld: I'd say this is fine for compatibility | |||||
// If we're passed -fuse-ld= with no argument, or with the argument ld, | // If we're passed -fuse-ld= with no argument, or with the argument ld, | ||||
// then use whatever the default system linker is. | // then use whatever the default system linker is. | ||||
if (UseLinker.empty() || UseLinker == "ld") | |||||
return GetProgramPath("ld"); | return GetProgramPath("ld"); | ||||
} else if (!UseLinker.empty()) { | |||||
I think this will give an error for -fuse-ld= with no argument. Please revert the condition above to UseLinker.empty() || UseLinker == "ld" to match the current behaviour Hahnfeld: I think this will give an error for `-fuse-ld=` with no argument. Please revert the condition… | |||||
llvm::SmallString<8> LinkerName("ld."); | llvm::SmallString<8> LinkerName("ld."); | ||||
LinkerName.append(UseLinker); | LinkerName.append(UseLinker); | ||||
std::string LinkerPath(GetProgramPath(LinkerName.c_str())); | std::string LinkerPath(GetProgramPath(LinkerName.c_str())); | ||||
if (llvm::sys::fs::exists(LinkerPath)) | if (llvm::sys::fs::exists(LinkerPath)) | ||||
return LinkerPath; | return LinkerPath; | ||||
} | } | ||||
if (A) | |||||
getDriver().Diag(diag::err_drv_invalid_linker_name) << A->getAsString(Args); | getDriver().Diag(diag::err_drv_invalid_linker_name) << A->getAsString(Args); | ||||
return ""; | |||||
You can leave this return because Clang will exit anyway after emitting the error (as I had to learn...) Hahnfeld: You can leave this `return` because Clang will exit anyway after emitting the error (as I had… | |||||
} | |||||
return GetProgramPath(DefaultLinker); | return GetProgramPath(DefaultLinker); | ||||
} | } | ||||
types::ID ToolChain::LookupTypeForExtension(const char *Ext) const { | types::ID ToolChain::LookupTypeForExtension(const char *Ext) const { | ||||
return types::lookupTypeForExtension(Ext); | return types::lookupTypeForExtension(Ext); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 326 Lines • ▼ Show 20 Lines | if (getTriple().getArch() == llvm::Triple::x86 || | ||||
Res |= CFIICall; | Res |= CFIICall; | ||||
return Res; | return Res; | ||||
} | } | ||||
void ToolChain::AddCudaIncludeArgs(const ArgList &DriverArgs, | void ToolChain::AddCudaIncludeArgs(const ArgList &DriverArgs, | ||||
ArgStringList &CC1Args) const {} | ArgStringList &CC1Args) const {} | ||||
void ToolChain::AddIAMCUIncludeArgs(const ArgList &DriverArgs, | void ToolChain::AddIAMCUIncludeArgs(const ArgList &DriverArgs, | ||||
ArgStringList &CC1Args) const {} | ArgStringList &CC1Args) const {} | ||||
I think this could go into the header Hahnfeld: I think this could go into the header | |||||
The CLANG_DEFAULT_LINKER macro is getting defined in "clang/Config/config.h" which isn't meant to be included in other headers. sfertile: The CLANG_DEFAULT_LINKER macro is getting defined in "clang/Config/config.h" which isn't meant… | |||||
Right, that does not work for the current version of the patch. It was meant in conjunction with this comment:
Hahnfeld: Right, that does not work for the current version of the patch.
It was meant in conjunction… |
I wonder whether this is really correct: If DefaultLinker is not ld (it is lld for some ToolChains), -fuse-ld= with an empty argument should probably not use ld but rather whatever DefaultLinker says...