Skip to content

Commit

Permalink
[Driver] Simply some gcc search logic (#72558)
Browse files Browse the repository at this point in the history
  • Loading branch information
tstellar committed Nov 22, 2023
1 parent 9ceea08 commit 64c0e86
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
18 changes: 7 additions & 11 deletions clang/lib/Driver/ToolChains/Gnu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion clang/lib/Driver/ToolChains/Gnu.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 64c0e86

Please sign in to comment.