[clang] 64c0e86 - [Driver] Simply some gcc search logic (#72558)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 22 07:10:45 PST 2023
Author: Tom Stellard
Date: 2023-11-22T07:10:39-08:00
New Revision: 64c0e86c9e07bd65ac7c584ca2e97769852616a5
URL: https://github.com/llvm/llvm-project/commit/64c0e86c9e07bd65ac7c584ca2e97769852616a5
DIFF: https://github.com/llvm/llvm-project/commit/64c0e86c9e07bd65ac7c584ca2e97769852616a5.diff
LOG: [Driver] Simply some gcc search logic (#72558)
Added:
Modified:
clang/lib/Driver/ToolChains/Gnu.cpp
clang/lib/Driver/ToolChains/Gnu.h
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp
index 2b1e8f02cf663885..9fb99145d3b909ee 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2097,14 +2097,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);
@@ -2184,13 +2187,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 dcfc6307cac79e52..0b664a182d75e1c6 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,
More information about the cfe-commits
mailing list