Index: clang/include/clang/Driver/Distro.h =================================================================== --- clang/include/clang/Driver/Distro.h +++ clang/include/clang/Driver/Distro.h @@ -134,6 +134,8 @@ bool IsGentoo() const { return DistroVal == Gentoo; } + bool IsArchLinux() const { return DistroVal == ArchLinux; } + /// @} }; Index: clang/lib/Driver/ToolChains/Linux.cpp =================================================================== --- clang/lib/Driver/ToolChains/Linux.cpp +++ clang/lib/Driver/ToolChains/Linux.cpp @@ -370,28 +370,30 @@ 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 Distro Distro(getDriver().getVFS(), getTriple()); const StringRef InstallDir = GCCInstallation.getInstallPath(); const StringRef TripleStr = GCCInstallation.getTriple().str(); const Multilib &Multilib = GCCInstallation.getMultilib(); + std::string BasePath = (InstallDir + "/../../../../" + TripleStr).str(); - std::string Path = - (InstallDir + "/../../../../" + TripleStr + "/libc" + Multilib.osSuffix()) - .str(); - - if (getVFS().exists(Path)) - return Path; + if (Distro.IsArchLinux() && getVFS().exists(BasePath)) + return BasePath; - Path = (InstallDir + "/../../../../sysroot" + Multilib.osSuffix()).str(); + // Standalone MIPS toolchains use different names for sysroot folder + // and put it into different places. Here we try to check some known + // variants. + if (getTriple().isMIPS()) { + std::string Path = BasePath + "/libc" + Multilib.osSuffix(); + if (getVFS().exists(Path)) + return Path; - if (getVFS().exists(Path)) - return Path; + Path = (InstallDir + "/../../../../sysroot" + Multilib.osSuffix()).str(); + if (getVFS().exists(Path)) + return Path; + } return std::string(); }