From 2e55df49929a515b05f3af89b47a13357eccd9d0 Mon Sep 17 00:00:00 2001 From: Hal Finkel Date: Thu, 8 Dec 2011 05:50:03 +0000 Subject: [PATCH] Allow clang to find gcc libs on suse ppc64 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146142 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Driver/ToolChains.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp index 29559a6ae2..e1731b8e91 100644 --- a/lib/Driver/ToolChains.cpp +++ b/lib/Driver/ToolChains.cpp @@ -1256,7 +1256,8 @@ Generic_GCC::GCCInstallationDetector::GCCInstallationDetector(const Driver &D) static const char *const PPCLibDirs[] = { "/lib32", "/lib" }; static const char *const PPCTriples[] = { "powerpc-linux-gnu", - "powerpc-unknown-linux-gnu" + "powerpc-unknown-linux-gnu", + "powerpc-suse-linux" }; LibDirs.append(PPCLibDirs, PPCLibDirs + llvm::array_lengthof(PPCLibDirs)); Triples.append(PPCTriples, PPCTriples + llvm::array_lengthof(PPCTriples)); @@ -1264,6 +1265,7 @@ Generic_GCC::GCCInstallationDetector::GCCInstallationDetector(const Driver &D) static const char *const PPC64LibDirs[] = { "/lib64", "/lib" }; static const char *const PPC64Triples[] = { "powerpc64-unknown-linux-gnu", + "powerpc64-suse-linux", "ppc64-redhat-linux" }; LibDirs.append(PPC64LibDirs, @@ -1309,6 +1311,16 @@ void Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple( continue; if (CandidateVersion <= Version) continue; + + // Some versions of SUSE and Fedora on ppc64 put 32-bit libs + // in what would normally be GccInstallPath and put the 64-bit + // libs in a subdirectory named 64. We need the 64-bit libs + // for linking. + bool UseSlash64 = false; + if (HostArch == llvm::Triple::ppc64 && + llvm::sys::fs::exists(LI->path() + "/64/crtbegin.o")) + UseSlash64 = true; + if (!llvm::sys::fs::exists(LI->path() + "/crtbegin.o")) continue; @@ -1319,6 +1331,7 @@ void Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple( // Linux. GccInstallPath = LibDir + Suffixes[i] + "/" + VersionText.str(); GccParentLibPath = GccInstallPath + InstallSuffixes[i]; + if (UseSlash64) GccInstallPath = GccInstallPath + "/64"; IsValid = true; } } -- 2.40.0