From 67c4418c6ee294552d686c71c9fa2091fde1855a Mon Sep 17 00:00:00 2001 From: Simon Atanasyan Date: Mon, 4 Aug 2014 12:57:52 +0000 Subject: [PATCH] [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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@214712 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Driver/Tools.cpp | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 146976166d..fde63ca201 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -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(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) { -- 2.40.0