r214712 - [Driver][Mips] Construct dynamic linker path by string concatination.
Simon Atanasyan
simon at atanasyan.com
Mon Aug 4 05:57:52 PDT 2014
Author: atanasyan
Date: Mon Aug 4 07:57:52 2014
New Revision: 214712
URL: http://llvm.org/viewvc/llvm-project?rev=214712&view=rev
Log:
[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.
Modified:
cfe/trunk/lib/Driver/Tools.cpp
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=214712&r1=214711&r2=214712&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Mon Aug 4 07:57:52 2014
@@ -7217,8 +7217,8 @@ static void AddLibgcc(const llvm::Triple
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(c
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) {
More information about the cfe-commits
mailing list