dmantipov updated this revision to Diff 293955. dmantipov added a comment. Prefer a bit more meaningful variable names.
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D87901/new/ https://reviews.llvm.org/D87901 Files: clang/lib/Driver/ToolChains/Gnu.cpp clang/lib/Driver/ToolChains/Gnu.h Index: clang/lib/Driver/ToolChains/Gnu.h =================================================================== --- clang/lib/Driver/ToolChains/Gnu.h +++ clang/lib/Driver/ToolChains/Gnu.h @@ -215,6 +215,10 @@ // Gentoo-specific toolchain configurations are stored here. const std::string GentooConfigDir = "/etc/env.d/gcc"; + // Internal flags used to filter out <libdir>/gcc and <libdir>/gcc-cross. + bool GCCDirExists; + bool GCCCrossDirExists; + public: explicit GCCInstallationDetector(const Driver &D) : IsValid(false), D(D) {} void init(const llvm::Triple &TargetTriple, const llvm::opt::ArgList &Args, Index: clang/lib/Driver/ToolChains/Gnu.cpp =================================================================== --- clang/lib/Driver/ToolChains/Gnu.cpp +++ clang/lib/Driver/ToolChains/Gnu.cpp @@ -1945,6 +1945,9 @@ const std::string LibDir = Prefix + Suffix.str(); if (!D.getVFS().exists(LibDir)) continue; + // Maybe filter out <libdir>/gcc and <libdir>/gcc-cross. + GCCDirExists = D.getVFS().exists(LibDir + "/gcc"); + GCCCrossDirExists = D.getVFS().exists(LibDir + "/gcc-cross"); // Try to match the exact target triple first. ScanLibDirForGCCTriple(TargetTriple, Args, LibDir, TargetTriple.str()); // Try rest of possible triples. @@ -2463,12 +2466,13 @@ // Whether this library suffix is relevant for the triple. bool Active; } Suffixes[] = { - // This is the normal place. - {"gcc/" + CandidateTriple.str(), "../..", true}, + // This is the normal place if Clang is installed alongside with GCC, + // probably with the same prefix. But it's likely does not exists in + // case of standalone Clang install. + {"gcc/" + CandidateTriple.str(), "../..", GCCDirExists}, // Debian puts cross-compilers in gcc-cross. - {"gcc-cross/" + CandidateTriple.str(), "../..", - TargetTriple.getOS() != llvm::Triple::Solaris}, + {"gcc-cross/" + CandidateTriple.str(), "../..", GCCCrossDirExists}, // The Freescale PPC SDK has the gcc libraries in // <sysroot>/usr/lib/<triple>/x.y.z so have a look there as well. Only do
Index: clang/lib/Driver/ToolChains/Gnu.h =================================================================== --- clang/lib/Driver/ToolChains/Gnu.h +++ clang/lib/Driver/ToolChains/Gnu.h @@ -215,6 +215,10 @@ // Gentoo-specific toolchain configurations are stored here. const std::string GentooConfigDir = "/etc/env.d/gcc"; + // Internal flags used to filter out <libdir>/gcc and <libdir>/gcc-cross. + bool GCCDirExists; + bool GCCCrossDirExists; + public: explicit GCCInstallationDetector(const Driver &D) : IsValid(false), D(D) {} void init(const llvm::Triple &TargetTriple, const llvm::opt::ArgList &Args, Index: clang/lib/Driver/ToolChains/Gnu.cpp =================================================================== --- clang/lib/Driver/ToolChains/Gnu.cpp +++ clang/lib/Driver/ToolChains/Gnu.cpp @@ -1945,6 +1945,9 @@ const std::string LibDir = Prefix + Suffix.str(); if (!D.getVFS().exists(LibDir)) continue; + // Maybe filter out <libdir>/gcc and <libdir>/gcc-cross. + GCCDirExists = D.getVFS().exists(LibDir + "/gcc"); + GCCCrossDirExists = D.getVFS().exists(LibDir + "/gcc-cross"); // Try to match the exact target triple first. ScanLibDirForGCCTriple(TargetTriple, Args, LibDir, TargetTriple.str()); // Try rest of possible triples. @@ -2463,12 +2466,13 @@ // Whether this library suffix is relevant for the triple. bool Active; } Suffixes[] = { - // This is the normal place. - {"gcc/" + CandidateTriple.str(), "../..", true}, + // This is the normal place if Clang is installed alongside with GCC, + // probably with the same prefix. But it's likely does not exists in + // case of standalone Clang install. + {"gcc/" + CandidateTriple.str(), "../..", GCCDirExists}, // Debian puts cross-compilers in gcc-cross. - {"gcc-cross/" + CandidateTriple.str(), "../..", - TargetTriple.getOS() != llvm::Triple::Solaris}, + {"gcc-cross/" + CandidateTriple.str(), "../..", GCCCrossDirExists}, // The Freescale PPC SDK has the gcc libraries in // <sysroot>/usr/lib/<triple>/x.y.z so have a look there as well. Only do
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits