@@ -1939,27 +1939,36 @@ void Generic_GCC::GCCInstallationDetector::init(
1939
1939
// installation available. GCC installs are ranked by version number.
1940
1940
Version = GCCVersion::Parse (" 0.0.0" );
1941
1941
for (const std::string &Prefix : Prefixes) {
1942
- if (!D.getVFS ().exists (Prefix))
1942
+ auto &VFS = D.getVFS ();
1943
+ if (!VFS.exists (Prefix))
1943
1944
continue ;
1944
1945
for (StringRef Suffix : CandidateLibDirs) {
1945
1946
const std::string LibDir = Prefix + Suffix.str ();
1946
- if (!D. getVFS () .exists (LibDir))
1947
+ if (!VFS .exists (LibDir))
1947
1948
continue ;
1949
+ // Maybe filter out <libdir>/gcc and <libdir>/gcc-cross.
1950
+ bool GCCDirExists = VFS.exists (LibDir + " /gcc" );
1951
+ bool GCCCrossDirExists = VFS.exists (LibDir + " /gcc-cross" );
1948
1952
// Try to match the exact target triple first.
1949
- ScanLibDirForGCCTriple (TargetTriple, Args, LibDir, TargetTriple.str ());
1953
+ ScanLibDirForGCCTriple (TargetTriple, Args, LibDir, TargetTriple.str (),
1954
+ false , GCCDirExists, GCCCrossDirExists);
1950
1955
// Try rest of possible triples.
1951
1956
for (StringRef Candidate : ExtraTripleAliases) // Try these first.
1952
- ScanLibDirForGCCTriple (TargetTriple, Args, LibDir, Candidate);
1957
+ ScanLibDirForGCCTriple (TargetTriple, Args, LibDir, Candidate, false ,
1958
+ GCCDirExists, GCCCrossDirExists);
1953
1959
for (StringRef Candidate : CandidateTripleAliases)
1954
- ScanLibDirForGCCTriple (TargetTriple, Args, LibDir, Candidate);
1960
+ ScanLibDirForGCCTriple (TargetTriple, Args, LibDir, Candidate, false ,
1961
+ GCCDirExists, GCCCrossDirExists);
1955
1962
}
1956
1963
for (StringRef Suffix : CandidateBiarchLibDirs) {
1957
1964
const std::string LibDir = Prefix + Suffix.str ();
1958
- if (!D. getVFS () .exists (LibDir))
1965
+ if (!VFS .exists (LibDir))
1959
1966
continue ;
1967
+ bool GCCDirExists = VFS.exists (LibDir + " /gcc" );
1968
+ bool GCCCrossDirExists = VFS.exists (LibDir + " /gcc-cross" );
1960
1969
for (StringRef Candidate : CandidateBiarchTripleAliases)
1961
- ScanLibDirForGCCTriple (TargetTriple, Args, LibDir, Candidate,
1962
- /* NeedsBiarchSuffix= */ true );
1970
+ ScanLibDirForGCCTriple (TargetTriple, Args, LibDir, Candidate, true ,
1971
+ GCCDirExists, GCCCrossDirExists );
1963
1972
}
1964
1973
}
1965
1974
}
@@ -2450,7 +2459,7 @@ bool Generic_GCC::GCCInstallationDetector::ScanGCCForMultilibs(
2450
2459
void Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple (
2451
2460
const llvm::Triple &TargetTriple, const ArgList &Args,
2452
2461
const std::string &LibDir, StringRef CandidateTriple,
2453
- bool NeedsBiarchSuffix) {
2462
+ bool NeedsBiarchSuffix, bool GCCDirExists, bool GCCCrossDirExists ) {
2454
2463
llvm::Triple::ArchType TargetArch = TargetTriple.getArch ();
2455
2464
// Locations relative to the system lib directory where GCC's triple-specific
2456
2465
// directories might reside.
@@ -2464,11 +2473,10 @@ void Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple(
2464
2473
bool Active;
2465
2474
} Suffixes[] = {
2466
2475
// This is the normal place.
2467
- {" gcc/" + CandidateTriple.str (), " ../.." , true },
2476
+ {" gcc/" + CandidateTriple.str (), " ../.." , GCCDirExists },
2468
2477
2469
2478
// Debian puts cross-compilers in gcc-cross.
2470
- {" gcc-cross/" + CandidateTriple.str (), " ../.." ,
2471
- TargetTriple.getOS () != llvm::Triple::Solaris},
2479
+ {" gcc-cross/" + CandidateTriple.str (), " ../.." , GCCCrossDirExists},
2472
2480
2473
2481
// The Freescale PPC SDK has the gcc libraries in
2474
2482
// <sysroot>/usr/lib/<triple>/x.y.z so have a look there as well. Only do
0 commit comments