[Driver][Mips] Construct dynamic linker path by string concatination.

That reduces a number of `if` operators and prevent a combinatorics explosion
if/when more dynamic linker path variants added.

No functional changes.

llvm-svn: 214712
This commit is contained in:
Simon Atanasyan 2014-08-04 12:57:52 +00:00
parent 522c35eb80
commit 2c590ffa0e
1 changed files with 17 additions and 12 deletions

View File

@ -7217,8 +7217,8 @@ static void AddLibgcc(const llvm::Triple &Triple, const Driver &D,
CmdArgs.push_back("-ldl");
}
static StringRef getLinuxDynamicLinker(const ArgList &Args,
const toolchains::Linux &ToolChain) {
static std::string getLinuxDynamicLinker(const ArgList &Args,
const toolchains::Linux &ToolChain) {
if (ToolChain.getTriple().getEnvironment() == llvm::Triple::Android) {
if (ToolChain.getTriple().isArch64Bit())
return "/system/bin/linker64";
@ -7244,17 +7244,22 @@ static StringRef getLinuxDynamicLinker(const ArgList &Args,
else
return "/lib/ld-linux.so.3"; /* TODO: check which dynamic linker name. */
} else if (ToolChain.getArch() == llvm::Triple::mips ||
ToolChain.getArch() == llvm::Triple::mipsel) {
if (mips::isNaN2008(Args, ToolChain.getTriple()))
return "/lib/ld-linux-mipsn8.so.1";
return "/lib/ld.so.1";
} else if (ToolChain.getArch() == llvm::Triple::mips64 ||
ToolChain.getArch() == llvm::Triple::mipsel ||
ToolChain.getArch() == llvm::Triple::mips64 ||
ToolChain.getArch() == llvm::Triple::mips64el) {
if (mips::hasMipsAbiArg(Args, "n32"))
return mips::isNaN2008(Args, ToolChain.getTriple())
? "/lib32/ld-linux-mipsn8.so.1" : "/lib32/ld.so.1";
return mips::isNaN2008(Args, ToolChain.getTriple())
? "/lib64/ld-linux-mipsn8.so.1" : "/lib64/ld.so.1";
StringRef CPUName;
StringRef ABIName;
mips::getMipsCPUAndABI(Args, ToolChain.getTriple(), CPUName, ABIName);
bool IsNaN2008 = mips::isNaN2008(Args, ToolChain.getTriple());
StringRef LibDir = llvm::StringSwitch<llvm::StringRef>(ABIName)
.Case("o32", "/lib")
.Case("n32", "/lib32")
.Case("n64", "/lib64")
.Default("/lib");
StringRef LibName = IsNaN2008 ? "ld-linux-mipsn8.so.1" : "ld.so.1";
return (LibDir + "/" + LibName).str();
} else if (ToolChain.getArch() == llvm::Triple::ppc)
return "/lib/ld.so.1";
else if (ToolChain.getArch() == llvm::Triple::ppc64) {