dmantipov updated this revision to Diff 294625. dmantipov added a comment. Initialize GCCDirExists and GCCCrossDirExists before calling ScanLibDirForGCCTriple().
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 @@ -1935,6 +1935,10 @@ return; } + // These should be set before calling ScanLibDirForGCCTriple(). + GCCDirExists = false; + GCCCrossDirExists = false; + // Loop over the various components which exist and select the best GCC // installation available. GCC installs are ranked by version number. Version = GCCVersion::Parse("0.0.0"); @@ -1945,6 +1949,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 +2470,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 @@ -1935,6 +1935,10 @@ return; } + // These should be set before calling ScanLibDirForGCCTriple(). + GCCDirExists = false; + GCCCrossDirExists = false; + // Loop over the various components which exist and select the best GCC // installation available. GCC installs are ranked by version number. Version = GCCVersion::Parse("0.0.0"); @@ -1945,6 +1949,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 +2470,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