[clang] [Driver] Simply some gcc search logic (PR #72558)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 16 11:27:05 PST 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Tom Stellard (tstellar)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/72558.diff
2 Files Affected:
- (modified) clang/lib/Driver/ToolChains/Gnu.cpp (+7-11)
- (modified) clang/lib/Driver/ToolChains/Gnu.h (-1)
``````````diff
diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp
index 19dff4ec4d45e08..d92c0f7f8984758 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2117,14 +2117,17 @@ void Generic_GCC::GCCInstallationDetector::init(
// The compatible GCC triples for this particular architecture.
SmallVector<StringRef, 16> CandidateTripleAliases;
SmallVector<StringRef, 16> CandidateBiarchTripleAliases;
+ // Add some triples that we want to check first.
+ CandidateTripleAliases.push_back(TargetTriple.str());
+ std::string TripleNoVendor = TargetTriple.getArchName().str() + "-" +
+ TargetTriple.getOSAndEnvironmentName().str();
+ if (TargetTriple.getVendor() == llvm::Triple::UnknownVendor) {
+ CandidateTripleAliases.push_back(TripleNoVendor);
+ }
CollectLibDirsAndTriples(TargetTriple, BiarchVariantTriple, CandidateLibDirs,
CandidateTripleAliases, CandidateBiarchLibDirs,
CandidateBiarchTripleAliases);
- TripleNoVendor = TargetTriple.getArchName().str() + "-" +
- TargetTriple.getOSAndEnvironmentName().str();
- StringRef TripleNoVendorRef(TripleNoVendor);
-
// If --gcc-install-dir= is specified, skip filesystem detection.
if (const Arg *A =
Args.getLastArg(clang::driver::options::OPT_gcc_install_dir_EQ);
@@ -2204,13 +2207,6 @@ void Generic_GCC::GCCInstallationDetector::init(
// Maybe filter out <libdir>/gcc and <libdir>/gcc-cross.
bool GCCDirExists = VFS.exists(LibDir + "/gcc");
bool GCCCrossDirExists = VFS.exists(LibDir + "/gcc-cross");
- // Try to match the exact target triple first.
- ScanLibDirForGCCTriple(TargetTriple, Args, LibDir, TargetTriple.str(),
- false, GCCDirExists, GCCCrossDirExists);
- // If vendor is unknown, let's try triple without vendor.
- if (TargetTriple.getVendor() == llvm::Triple::UnknownVendor)
- ScanLibDirForGCCTriple(TargetTriple, Args, LibDir, TripleNoVendorRef,
- false, GCCDirExists, GCCCrossDirExists);
for (StringRef Candidate : CandidateTripleAliases)
ScanLibDirForGCCTriple(TargetTriple, Args, LibDir, Candidate, false,
GCCDirExists, GCCCrossDirExists);
diff --git a/clang/lib/Driver/ToolChains/Gnu.h b/clang/lib/Driver/ToolChains/Gnu.h
index dcfc6307cac79e5..0b664a182d75e1c 100644
--- a/clang/lib/Driver/ToolChains/Gnu.h
+++ b/clang/lib/Driver/ToolChains/Gnu.h
@@ -249,7 +249,6 @@ class LLVM_LIBRARY_VISIBILITY Generic_GCC : public ToolChain {
void print(raw_ostream &OS) const;
private:
- std::string TripleNoVendor;
static void
CollectLibDirsAndTriples(const llvm::Triple &TargetTriple,
const llvm::Triple &BiarchTriple,
``````````
</details>
https://github.com/llvm/llvm-project/pull/72558
More information about the cfe-commits
mailing list