dmantipov updated this revision to Diff 289998. dmantipov added a comment. Add D.SysRoot as suggested during initial review.
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D87143/new/ https://reviews.llvm.org/D87143 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 @@ -212,6 +212,9 @@ /// The set of multilibs that the detected installation supports. MultilibSet Multilibs; + // Gentoo-specific toolchain configurations are stored here. + const std::string GentooConfigDir = "/etc/env.d/gcc"; + 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 @@ -2534,6 +2534,9 @@ const llvm::Triple &TargetTriple, const ArgList &Args, const SmallVectorImpl<StringRef> &CandidateTriples, const SmallVectorImpl<StringRef> &CandidateBiarchTriples) { + if (!D.getVFS().exists(D.SysRoot + GentooConfigDir)) + return false; + for (StringRef CandidateTriple : CandidateTriples) { if (ScanGentooGccConfig(TargetTriple, Args, CandidateTriple)) return true; @@ -2550,8 +2553,8 @@ const llvm::Triple &TargetTriple, const ArgList &Args, StringRef CandidateTriple, bool NeedsBiarchSuffix) { llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> File = - D.getVFS().getBufferForFile(D.SysRoot + "/etc/env.d/gcc/config-" + - CandidateTriple.str()); + D.getVFS().getBufferForFile(D.SysRoot + GentooConfigDir + + "/config-" + CandidateTriple.str()); if (File) { SmallVector<StringRef, 2> Lines; File.get()->getBuffer().split(Lines, "\n"); @@ -2562,8 +2565,8 @@ continue; // Process the config file pointed to by CURRENT. llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> ConfigFile = - D.getVFS().getBufferForFile(D.SysRoot + "/etc/env.d/gcc/" + - Line.str()); + D.getVFS().getBufferForFile(D.SysRoot + GentooConfigDir + + "/" + Line.str()); std::pair<StringRef, StringRef> ActiveVersion = Line.rsplit('-'); // List of paths to scan for libraries. SmallVector<StringRef, 4> GentooScanPaths;
Index: clang/lib/Driver/ToolChains/Gnu.h =================================================================== --- clang/lib/Driver/ToolChains/Gnu.h +++ clang/lib/Driver/ToolChains/Gnu.h @@ -212,6 +212,9 @@ /// The set of multilibs that the detected installation supports. MultilibSet Multilibs; + // Gentoo-specific toolchain configurations are stored here. + const std::string GentooConfigDir = "/etc/env.d/gcc"; + 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 @@ -2534,6 +2534,9 @@ const llvm::Triple &TargetTriple, const ArgList &Args, const SmallVectorImpl<StringRef> &CandidateTriples, const SmallVectorImpl<StringRef> &CandidateBiarchTriples) { + if (!D.getVFS().exists(D.SysRoot + GentooConfigDir)) + return false; + for (StringRef CandidateTriple : CandidateTriples) { if (ScanGentooGccConfig(TargetTriple, Args, CandidateTriple)) return true; @@ -2550,8 +2553,8 @@ const llvm::Triple &TargetTriple, const ArgList &Args, StringRef CandidateTriple, bool NeedsBiarchSuffix) { llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> File = - D.getVFS().getBufferForFile(D.SysRoot + "/etc/env.d/gcc/config-" + - CandidateTriple.str()); + D.getVFS().getBufferForFile(D.SysRoot + GentooConfigDir + + "/config-" + CandidateTriple.str()); if (File) { SmallVector<StringRef, 2> Lines; File.get()->getBuffer().split(Lines, "\n"); @@ -2562,8 +2565,8 @@ continue; // Process the config file pointed to by CURRENT. llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> ConfigFile = - D.getVFS().getBufferForFile(D.SysRoot + "/etc/env.d/gcc/" + - Line.str()); + D.getVFS().getBufferForFile(D.SysRoot + GentooConfigDir + + "/" + Line.str()); std::pair<StringRef, StringRef> ActiveVersion = Line.rsplit('-'); // List of paths to scan for libraries. SmallVector<StringRef, 4> GentooScanPaths;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits