Index: clang/lib/Driver/ToolChains/Linux.cpp =================================================================== --- clang/lib/Driver/ToolChains/Linux.cpp +++ clang/lib/Driver/ToolChains/Linux.cpp @@ -355,40 +355,31 @@ return AndroidSysRootPath; } - if (getTriple().isCSKY()) { - // CSKY toolchains use different names for sysroot folder. - if (!GCCInstallation.isValid()) - return std::string(); - // GCCInstallation.getInstallPath() = - // $GCCToolchainPath/lib/gcc/csky-linux-gnuabiv2/6.3.0 - // Path = $GCCToolchainPath/csky-linux-gnuabiv2/libc - std::string Path = (GCCInstallation.getInstallPath() + "/../../../../" + - GCCInstallation.getTriple().str() + "/libc") - .str(); - if (getVFS().exists(Path)) - return Path; - return std::string(); - } - - if (!GCCInstallation.isValid() || !getTriple().isMIPS()) + if (!GCCInstallation.isValid()) return std::string(); - // Standalone MIPS toolchains use different names for sysroot folder - // and put it into different places. Here we try to check some known - // variants. - const StringRef InstallDir = GCCInstallation.getInstallPath(); const StringRef TripleStr = GCCInstallation.getTriple().str(); - const Multilib &Multilib = GCCInstallation.getMultilib(); + std::string Path = (InstallDir + "/../../../../" + TripleStr).str(); - std::string Path = - (InstallDir + "/../../../../" + TripleStr + "/libc" + Multilib.osSuffix()) - .str(); + // CSKY toolchains use different names for sysroot folder. + // GCCInstallation.getInstallPath() = + // $GCCToolchainPath/lib/gcc/csky-linux-gnuabiv2/6.3.0 + // Path = $GCCToolchainPath/csky-linux-gnuabiv2/libc + if (getTriple().isCSKY()) + Path += "/libc"; - if (getVFS().exists(Path)) - return Path; + // Standalone MIPS toolchains use different names for sysroot folder + // and put it into different places. Here check the two known variants. + else if (getTriple().isMIPS()) { + const std::string &OSSuffix = GCCInstallation.getMultilib().osSuffix(); - Path = (InstallDir + "/../../../../sysroot" + Multilib.osSuffix()).str(); + Path += "/libc" + OSSuffix; + if (getVFS().exists(Path)) + return Path; + + Path = (InstallDir + "/../../../../sysroot" + OSSuffix).str(); + } if (getVFS().exists(Path)) return Path;