Index: lib/Driver/ToolChains.cpp =================================================================== --- lib/Driver/ToolChains.cpp +++ lib/Driver/ToolChains.cpp @@ -1353,18 +1353,22 @@ static const char *const MIPSLibDirs[] = { "/lib" }; static const char *const MIPSTriples[] = { "mips-linux-gnu", - "mips-mti-linux-gnu" }; + "mips-mti-linux-gnu", + "mips-img-linux-gnu" }; static const char *const MIPSELLibDirs[] = { "/lib" }; static const char *const MIPSELTriples[] = { "mipsel-linux-gnu", - "mipsel-linux-android" }; + "mipsel-linux-android", + "mips-img-linux-gnu" }; static const char *const MIPS64LibDirs[] = { "/lib64", "/lib" }; static const char *const MIPS64Triples[] = { "mips64-linux-gnu", "mips-mti-linux-gnu", + "mips-img-linux-gnu", "mips64-linux-gnuabi64" }; static const char *const MIPS64ELLibDirs[] = { "/lib64", "/lib" }; static const char *const MIPS64ELTriples[] = { "mips64el-linux-gnu", "mips-mti-linux-gnu", + "mips-img-linux-gnu", "mips64el-linux-android", "mips64el-linux-gnuabi64" }; @@ -1869,6 +1873,33 @@ .FilterOut(NonExistent); } + MultilibSet ImgMultilibs; + { + Multilib Mips64r6 = Multilib() + .gccSuffix("/mips64r6") + .osSuffix("/mips64r6") + .includeSuffix("/mips64r6") + .flag("+m64").flag("-m32"); + + Multilib LittleEndian = Multilib() + .gccSuffix("/el") + .osSuffix("/el") + .includeSuffix("/el") + .flag("+EL").flag("-EB"); + + Multilib MAbi64 = Multilib() + .gccSuffix("/64") + .osSuffix("/64") + .includeSuffix("/64") + .flag("+mabi=64").flag("-mabi=n32").flag("-m32"); + + ImgMultilibs = MultilibSet() + .Maybe(Mips64r6) + .Maybe(MAbi64) + .Maybe(LittleEndian) + .FilterOut(NonExistent); + } + llvm::Triple::ArchType TargetArch = TargetTriple.getArch(); Multilib::flags_list Flags; @@ -1903,6 +1934,21 @@ return false; } + if ((TargetTriple.getArch() == llvm::Triple::mips || + TargetTriple.getArch() == llvm::Triple::mipsel || + TargetTriple.getArch() == llvm::Triple::mips64 || + TargetTriple.getArch() == llvm::Triple::mips64el) && + TargetTriple.getVendor() == llvm::Triple::ImaginationTechnologies && + TargetTriple.getOS() == llvm::Triple::Linux && + TargetTriple.getEnvironment() == llvm::Triple::GNU) { + // Select mips-img-linux-gnu toolchain. + if (ImgMultilibs.select(Flags, Result.SelectedMultilib)) { + Result.Multilibs = ImgMultilibs; + return true; + } + return false; + } + // Sort candidates. Toolchain that best meets the directories goes first. // Then select the first toolchains matches command line flags. MultilibSet *candidates[] = { &DebianMipsMultilibs, &FSFMipsMultilibs, Index: lib/Driver/Tools.cpp =================================================================== --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -7017,11 +7017,21 @@ 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 (ToolChain.getTriple().getVendor() == + llvm::Triple::ImaginationTechnologies && + ToolChain.getTriple().getOS() == llvm::Triple::Linux && + ToolChain.getTriple().getEnvironment() == llvm::Triple::GNU) + return "/lib/ld-linux-mipsn8.so.1"; if (mips::isNaN2008(Args)) return "/lib/ld-linux-mipsn8.so.1"; return "/lib/ld.so.1"; } else if (ToolChain.getArch() == llvm::Triple::mips64 || ToolChain.getArch() == llvm::Triple::mips64el) { + if (ToolChain.getTriple().getVendor() == + llvm::Triple::ImaginationTechnologies && + ToolChain.getTriple().getOS() == llvm::Triple::Linux && + ToolChain.getTriple().getEnvironment() == llvm::Triple::GNU) + return "/lib/ld-linux-mipsn8.so.1"; if (mips::hasMipsAbiArg(Args, "n32")) return mips::isNaN2008(Args) ? "/lib32/ld-linux-mipsn8.so.1" : "/lib32/ld.so.1";