[clang] [Driver] Simply some gcc search logic (PR #72558)
Tom Stellard via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 21 16:19:30 PST 2023
https://github.com/tstellar updated https://github.com/llvm/llvm-project/pull/72558
>From 3a0896141cf11c604f28326b3a6eee3762b4f79d Mon Sep 17 00:00:00 2001
From: Tom Stellard <tstellar at redhat.com>
Date: Thu, 16 Nov 2023 05:54:29 +0000
Subject: [PATCH 1/2] [Driver] Simply some gcc search logic
---
clang/lib/Driver/ToolChains/Gnu.cpp | 18 +++++++-----------
clang/lib/Driver/ToolChains/Gnu.h | 1 -
2 files changed, 7 insertions(+), 12 deletions(-)
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,
>From 994b7846d73b05ff8f5a41c56535e43e72f90220 Mon Sep 17 00:00:00 2001
From: Tom Stellard <tstellar at redhat.com>
Date: Wed, 22 Nov 2023 00:18:57 +0000
Subject: [PATCH 2/2] Fix formatting
---
clang/lib/Driver/ToolChains/Gnu.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp
index d92c0f7f8984758..0ea2df2ca8d87e2 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2121,9 +2121,9 @@ void Generic_GCC::GCCInstallationDetector::init(
CandidateTripleAliases.push_back(TargetTriple.str());
std::string TripleNoVendor = TargetTriple.getArchName().str() + "-" +
TargetTriple.getOSAndEnvironmentName().str();
- if (TargetTriple.getVendor() == llvm::Triple::UnknownVendor) {
+ if (TargetTriple.getVendor() == llvm::Triple::UnknownVendor)
CandidateTripleAliases.push_back(TripleNoVendor);
- }
+
CollectLibDirsAndTriples(TargetTriple, BiarchVariantTriple, CandidateLibDirs,
CandidateTripleAliases, CandidateBiarchLibDirs,
CandidateBiarchTripleAliases);
More information about the cfe-commits
mailing list