forked from OSchip/llvm-project
Reword and reformat some of the "Multiarch" code in the toolchain setup.
There are fundamentally two different things that were getting conflated here. 1) A bi-arch GCC toolchain install. This is not a full blown cross compiler, but it supports targetting both 32-bit and 64-bit variants of the same architecture using multilib OS installs and runtimes. 2) A "multiarch" Debian OS/runtime layout that lays out the libraries, headers, etc as-if there were going to be a full blown cross compiler even when in reality it is just a bi-arch GCC targeting two variants. Also, these tend to use oddly "canonicalized" triples without the vendor in them unlike the typical cross compiler runtime library search that vanilla GCC cross compilers perform. Now, when we mean the bi-arch nature of GCC accomplished with just a suffix or tweak to the GCC paths, we say 'Biarch' or something related. When we mean the Debian layout of includes and libraries, we say multiarch or reference the multiarch triple. In the process of reading and often renaming stuff in all these places, also reformat with clang-format. No functionality change should be going on here, this is just tidying up. llvm-svn: 184632
This commit is contained in:
parent
626032f6fc
commit
b427c56399
|
@ -1003,23 +1003,20 @@ static StringRef getGCCToolchainDir(const ArgList &Args) {
|
|||
/// necessary because the driver doesn't store the final version of the target
|
||||
/// triple.
|
||||
Generic_GCC::GCCInstallationDetector::GCCInstallationDetector(
|
||||
const Driver &D,
|
||||
const llvm::Triple &TargetTriple,
|
||||
const ArgList &Args)
|
||||
const Driver &D, const llvm::Triple &TargetTriple, const ArgList &Args)
|
||||
: IsValid(false) {
|
||||
llvm::Triple MultiarchTriple
|
||||
= TargetTriple.isArch32Bit() ? TargetTriple.get64BitArchVariant()
|
||||
llvm::Triple BiarchVariantTriple =
|
||||
TargetTriple.isArch32Bit() ? TargetTriple.get64BitArchVariant()
|
||||
: TargetTriple.get32BitArchVariant();
|
||||
llvm::Triple::ArchType TargetArch = TargetTriple.getArch();
|
||||
// The library directories which may contain GCC installations.
|
||||
SmallVector<StringRef, 4> CandidateLibDirs, CandidateMultiarchLibDirs;
|
||||
SmallVector<StringRef, 4> CandidateLibDirs, CandidateBiarchLibDirs;
|
||||
// The compatible GCC triples for this particular architecture.
|
||||
SmallVector<StringRef, 10> CandidateTripleAliases;
|
||||
SmallVector<StringRef, 10> CandidateMultiarchTripleAliases;
|
||||
CollectLibDirsAndTriples(TargetTriple, MultiarchTriple, CandidateLibDirs,
|
||||
CandidateTripleAliases,
|
||||
CandidateMultiarchLibDirs,
|
||||
CandidateMultiarchTripleAliases);
|
||||
SmallVector<StringRef, 10> CandidateBiarchTripleAliases;
|
||||
CollectLibDirsAndTriples(TargetTriple, BiarchVariantTriple, CandidateLibDirs,
|
||||
CandidateTripleAliases, CandidateBiarchLibDirs,
|
||||
CandidateBiarchTripleAliases);
|
||||
|
||||
// Compute the set of prefixes for our search.
|
||||
SmallVector<std::string, 8> Prefixes(D.PrefixDirs.begin(),
|
||||
|
@ -1051,81 +1048,58 @@ Generic_GCC::GCCInstallationDetector::GCCInstallationDetector(
|
|||
ScanLibDirForGCCTriple(TargetArch, Args, LibDir,
|
||||
CandidateTripleAliases[k]);
|
||||
}
|
||||
for (unsigned j = 0, je = CandidateMultiarchLibDirs.size(); j < je; ++j) {
|
||||
const std::string LibDir
|
||||
= Prefixes[i] + CandidateMultiarchLibDirs[j].str();
|
||||
for (unsigned j = 0, je = CandidateBiarchLibDirs.size(); j < je; ++j) {
|
||||
const std::string LibDir = Prefixes[i] + CandidateBiarchLibDirs[j].str();
|
||||
if (!llvm::sys::fs::exists(LibDir))
|
||||
continue;
|
||||
for (unsigned k = 0, ke = CandidateMultiarchTripleAliases.size(); k < ke;
|
||||
for (unsigned k = 0, ke = CandidateBiarchTripleAliases.size(); k < ke;
|
||||
++k)
|
||||
ScanLibDirForGCCTriple(TargetArch, Args, LibDir,
|
||||
CandidateMultiarchTripleAliases[k],
|
||||
/*NeedsMultiarchSuffix=*/true);
|
||||
CandidateBiarchTripleAliases[k],
|
||||
/*NeedsBiarchSuffix=*/ true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*static*/ void Generic_GCC::GCCInstallationDetector::CollectLibDirsAndTriples(
|
||||
const llvm::Triple &TargetTriple,
|
||||
const llvm::Triple &MultiarchTriple,
|
||||
const llvm::Triple &TargetTriple, const llvm::Triple &BiarchTriple,
|
||||
SmallVectorImpl<StringRef> &LibDirs,
|
||||
SmallVectorImpl<StringRef> &TripleAliases,
|
||||
SmallVectorImpl<StringRef> &MultiarchLibDirs,
|
||||
SmallVectorImpl<StringRef> &MultiarchTripleAliases) {
|
||||
SmallVectorImpl<StringRef> &BiarchLibDirs,
|
||||
SmallVectorImpl<StringRef> &BiarchTripleAliases) {
|
||||
// Declare a bunch of static data sets that we'll select between below. These
|
||||
// are specifically designed to always refer to string literals to avoid any
|
||||
// lifetime or initialization issues.
|
||||
static const char *const AArch64LibDirs[] = { "/lib" };
|
||||
static const char *const AArch64Triples[] = {
|
||||
"aarch64-none-linux-gnu",
|
||||
"aarch64-linux-gnu"
|
||||
};
|
||||
static const char *const AArch64Triples[] = { "aarch64-none-linux-gnu",
|
||||
"aarch64-linux-gnu" };
|
||||
|
||||
static const char *const ARMLibDirs[] = { "/lib" };
|
||||
static const char *const ARMTriples[] = {
|
||||
"arm-linux-gnueabi",
|
||||
"arm-linux-androideabi"
|
||||
};
|
||||
static const char *const ARMHFTriples[] = {
|
||||
"arm-linux-gnueabihf",
|
||||
"armv7hl-redhat-linux-gnueabi"
|
||||
};
|
||||
static const char *const ARMTriples[] = { "arm-linux-gnueabi",
|
||||
"arm-linux-androideabi" };
|
||||
static const char *const ARMHFTriples[] = { "arm-linux-gnueabihf",
|
||||
"armv7hl-redhat-linux-gnueabi" };
|
||||
|
||||
static const char *const X86_64LibDirs[] = { "/lib64", "/lib" };
|
||||
static const char *const X86_64Triples[] = {
|
||||
"x86_64-linux-gnu",
|
||||
"x86_64-unknown-linux-gnu",
|
||||
"x86_64-pc-linux-gnu",
|
||||
"x86_64-redhat-linux6E",
|
||||
"x86_64-redhat-linux",
|
||||
"x86_64-suse-linux",
|
||||
"x86_64-manbo-linux-gnu",
|
||||
"x86_64-linux-gnu",
|
||||
"x86_64-slackware-linux"
|
||||
"x86_64-linux-gnu", "x86_64-unknown-linux-gnu", "x86_64-pc-linux-gnu",
|
||||
"x86_64-redhat-linux6E", "x86_64-redhat-linux", "x86_64-suse-linux",
|
||||
"x86_64-manbo-linux-gnu", "x86_64-linux-gnu", "x86_64-slackware-linux"
|
||||
};
|
||||
static const char *const X86LibDirs[] = { "/lib32", "/lib" };
|
||||
static const char *const X86Triples[] = {
|
||||
"i686-linux-gnu",
|
||||
"i686-pc-linux-gnu",
|
||||
"i486-linux-gnu",
|
||||
"i386-linux-gnu",
|
||||
"i386-redhat-linux6E",
|
||||
"i686-redhat-linux",
|
||||
"i586-redhat-linux",
|
||||
"i386-redhat-linux",
|
||||
"i586-suse-linux",
|
||||
"i486-slackware-linux",
|
||||
"i686-linux-gnu", "i686-pc-linux-gnu", "i486-linux-gnu", "i386-linux-gnu",
|
||||
"i386-redhat-linux6E", "i686-redhat-linux", "i586-redhat-linux",
|
||||
"i386-redhat-linux", "i586-suse-linux", "i486-slackware-linux",
|
||||
"i686-montavista-linux"
|
||||
};
|
||||
|
||||
static const char *const MIPSLibDirs[] = { "/lib" };
|
||||
static const char *const MIPSTriples[] = { "mips-linux-gnu" };
|
||||
static const char *const MIPSELLibDirs[] = { "/lib" };
|
||||
static const char *const MIPSELTriples[] = {
|
||||
"mipsel-linux-gnu",
|
||||
"mipsel-linux-android",
|
||||
"mips-linux-gnu"
|
||||
};
|
||||
static const char *const MIPSELTriples[] = { "mipsel-linux-gnu",
|
||||
"mipsel-linux-android",
|
||||
"mips-linux-gnu" };
|
||||
|
||||
static const char *const MIPS64LibDirs[] = { "/lib64", "/lib" };
|
||||
static const char *const MIPS64Triples[] = { "mips64-linux-gnu" };
|
||||
|
@ -1134,134 +1108,129 @@ Generic_GCC::GCCInstallationDetector::GCCInstallationDetector(
|
|||
|
||||
static const char *const PPCLibDirs[] = { "/lib32", "/lib" };
|
||||
static const char *const PPCTriples[] = {
|
||||
"powerpc-linux-gnu",
|
||||
"powerpc-unknown-linux-gnu",
|
||||
"powerpc-linux-gnuspe",
|
||||
"powerpc-suse-linux",
|
||||
"powerpc-montavista-linuxspe"
|
||||
"powerpc-linux-gnu", "powerpc-unknown-linux-gnu", "powerpc-linux-gnuspe",
|
||||
"powerpc-suse-linux", "powerpc-montavista-linuxspe"
|
||||
};
|
||||
static const char *const PPC64LibDirs[] = { "/lib64", "/lib" };
|
||||
static const char *const PPC64Triples[] = {
|
||||
"powerpc64-linux-gnu",
|
||||
"powerpc64-unknown-linux-gnu",
|
||||
"powerpc64-suse-linux",
|
||||
"ppc64-redhat-linux"
|
||||
};
|
||||
static const char *const PPC64Triples[] = { "powerpc64-linux-gnu",
|
||||
"powerpc64-unknown-linux-gnu",
|
||||
"powerpc64-suse-linux",
|
||||
"ppc64-redhat-linux" };
|
||||
|
||||
static const char *const SystemZLibDirs[] = { "/lib64", "/lib" };
|
||||
static const char *const SystemZTriples[] = {
|
||||
"s390x-linux-gnu",
|
||||
"s390x-unknown-linux-gnu",
|
||||
"s390x-ibm-linux-gnu",
|
||||
"s390x-suse-linux",
|
||||
"s390x-redhat-linux"
|
||||
"s390x-linux-gnu", "s390x-unknown-linux-gnu", "s390x-ibm-linux-gnu",
|
||||
"s390x-suse-linux", "s390x-redhat-linux"
|
||||
};
|
||||
|
||||
switch (TargetTriple.getArch()) {
|
||||
case llvm::Triple::aarch64:
|
||||
LibDirs.append(AArch64LibDirs, AArch64LibDirs
|
||||
+ llvm::array_lengthof(AArch64LibDirs));
|
||||
TripleAliases.append(
|
||||
AArch64Triples, AArch64Triples + llvm::array_lengthof(AArch64Triples));
|
||||
MultiarchLibDirs.append(
|
||||
AArch64LibDirs, AArch64LibDirs + llvm::array_lengthof(AArch64LibDirs));
|
||||
MultiarchTripleAliases.append(
|
||||
AArch64Triples, AArch64Triples + llvm::array_lengthof(AArch64Triples));
|
||||
LibDirs.append(AArch64LibDirs,
|
||||
AArch64LibDirs + llvm::array_lengthof(AArch64LibDirs));
|
||||
TripleAliases.append(AArch64Triples,
|
||||
AArch64Triples + llvm::array_lengthof(AArch64Triples));
|
||||
BiarchLibDirs.append(AArch64LibDirs,
|
||||
AArch64LibDirs + llvm::array_lengthof(AArch64LibDirs));
|
||||
BiarchTripleAliases.append(
|
||||
AArch64Triples, AArch64Triples + llvm::array_lengthof(AArch64Triples));
|
||||
break;
|
||||
case llvm::Triple::arm:
|
||||
case llvm::Triple::thumb:
|
||||
LibDirs.append(ARMLibDirs, ARMLibDirs + llvm::array_lengthof(ARMLibDirs));
|
||||
if (TargetTriple.getEnvironment() == llvm::Triple::GNUEABIHF) {
|
||||
TripleAliases.append(
|
||||
ARMHFTriples, ARMHFTriples + llvm::array_lengthof(ARMHFTriples));
|
||||
TripleAliases.append(ARMHFTriples,
|
||||
ARMHFTriples + llvm::array_lengthof(ARMHFTriples));
|
||||
} else {
|
||||
TripleAliases.append(
|
||||
ARMTriples, ARMTriples + llvm::array_lengthof(ARMTriples));
|
||||
TripleAliases.append(ARMTriples,
|
||||
ARMTriples + llvm::array_lengthof(ARMTriples));
|
||||
}
|
||||
break;
|
||||
case llvm::Triple::x86_64:
|
||||
LibDirs.append(
|
||||
X86_64LibDirs, X86_64LibDirs + llvm::array_lengthof(X86_64LibDirs));
|
||||
TripleAliases.append(
|
||||
X86_64Triples, X86_64Triples + llvm::array_lengthof(X86_64Triples));
|
||||
MultiarchLibDirs.append(
|
||||
X86LibDirs, X86LibDirs + llvm::array_lengthof(X86LibDirs));
|
||||
MultiarchTripleAliases.append(
|
||||
X86Triples, X86Triples + llvm::array_lengthof(X86Triples));
|
||||
LibDirs.append(X86_64LibDirs,
|
||||
X86_64LibDirs + llvm::array_lengthof(X86_64LibDirs));
|
||||
TripleAliases.append(X86_64Triples,
|
||||
X86_64Triples + llvm::array_lengthof(X86_64Triples));
|
||||
BiarchLibDirs.append(X86LibDirs,
|
||||
X86LibDirs + llvm::array_lengthof(X86LibDirs));
|
||||
BiarchTripleAliases.append(X86Triples,
|
||||
X86Triples + llvm::array_lengthof(X86Triples));
|
||||
break;
|
||||
case llvm::Triple::x86:
|
||||
LibDirs.append(X86LibDirs, X86LibDirs + llvm::array_lengthof(X86LibDirs));
|
||||
TripleAliases.append(
|
||||
X86Triples, X86Triples + llvm::array_lengthof(X86Triples));
|
||||
MultiarchLibDirs.append(
|
||||
X86_64LibDirs, X86_64LibDirs + llvm::array_lengthof(X86_64LibDirs));
|
||||
MultiarchTripleAliases.append(
|
||||
X86_64Triples, X86_64Triples + llvm::array_lengthof(X86_64Triples));
|
||||
TripleAliases.append(X86Triples,
|
||||
X86Triples + llvm::array_lengthof(X86Triples));
|
||||
BiarchLibDirs.append(X86_64LibDirs,
|
||||
X86_64LibDirs + llvm::array_lengthof(X86_64LibDirs));
|
||||
BiarchTripleAliases.append(
|
||||
X86_64Triples, X86_64Triples + llvm::array_lengthof(X86_64Triples));
|
||||
break;
|
||||
case llvm::Triple::mips:
|
||||
LibDirs.append(
|
||||
MIPSLibDirs, MIPSLibDirs + llvm::array_lengthof(MIPSLibDirs));
|
||||
TripleAliases.append(
|
||||
MIPSTriples, MIPSTriples + llvm::array_lengthof(MIPSTriples));
|
||||
MultiarchLibDirs.append(
|
||||
MIPS64LibDirs, MIPS64LibDirs + llvm::array_lengthof(MIPS64LibDirs));
|
||||
MultiarchTripleAliases.append(
|
||||
MIPS64Triples, MIPS64Triples + llvm::array_lengthof(MIPS64Triples));
|
||||
LibDirs.append(MIPSLibDirs,
|
||||
MIPSLibDirs + llvm::array_lengthof(MIPSLibDirs));
|
||||
TripleAliases.append(MIPSTriples,
|
||||
MIPSTriples + llvm::array_lengthof(MIPSTriples));
|
||||
BiarchLibDirs.append(MIPS64LibDirs,
|
||||
MIPS64LibDirs + llvm::array_lengthof(MIPS64LibDirs));
|
||||
BiarchTripleAliases.append(
|
||||
MIPS64Triples, MIPS64Triples + llvm::array_lengthof(MIPS64Triples));
|
||||
break;
|
||||
case llvm::Triple::mipsel:
|
||||
LibDirs.append(
|
||||
MIPSELLibDirs, MIPSELLibDirs + llvm::array_lengthof(MIPSELLibDirs));
|
||||
TripleAliases.append(
|
||||
MIPSELTriples, MIPSELTriples + llvm::array_lengthof(MIPSELTriples));
|
||||
MultiarchLibDirs.append(
|
||||
MIPS64ELLibDirs, MIPS64ELLibDirs + llvm::array_lengthof(MIPS64ELLibDirs));
|
||||
MultiarchTripleAliases.append(
|
||||
MIPS64ELTriples, MIPS64ELTriples + llvm::array_lengthof(MIPS64ELTriples));
|
||||
LibDirs.append(MIPSELLibDirs,
|
||||
MIPSELLibDirs + llvm::array_lengthof(MIPSELLibDirs));
|
||||
TripleAliases.append(MIPSELTriples,
|
||||
MIPSELTriples + llvm::array_lengthof(MIPSELTriples));
|
||||
BiarchLibDirs.append(
|
||||
MIPS64ELLibDirs,
|
||||
MIPS64ELLibDirs + llvm::array_lengthof(MIPS64ELLibDirs));
|
||||
BiarchTripleAliases.append(
|
||||
MIPS64ELTriples,
|
||||
MIPS64ELTriples + llvm::array_lengthof(MIPS64ELTriples));
|
||||
break;
|
||||
case llvm::Triple::mips64:
|
||||
LibDirs.append(
|
||||
MIPS64LibDirs, MIPS64LibDirs + llvm::array_lengthof(MIPS64LibDirs));
|
||||
TripleAliases.append(
|
||||
MIPS64Triples, MIPS64Triples + llvm::array_lengthof(MIPS64Triples));
|
||||
MultiarchLibDirs.append(
|
||||
MIPSLibDirs, MIPSLibDirs + llvm::array_lengthof(MIPSLibDirs));
|
||||
MultiarchTripleAliases.append(
|
||||
MIPSTriples, MIPSTriples + llvm::array_lengthof(MIPSTriples));
|
||||
LibDirs.append(MIPS64LibDirs,
|
||||
MIPS64LibDirs + llvm::array_lengthof(MIPS64LibDirs));
|
||||
TripleAliases.append(MIPS64Triples,
|
||||
MIPS64Triples + llvm::array_lengthof(MIPS64Triples));
|
||||
BiarchLibDirs.append(MIPSLibDirs,
|
||||
MIPSLibDirs + llvm::array_lengthof(MIPSLibDirs));
|
||||
BiarchTripleAliases.append(MIPSTriples,
|
||||
MIPSTriples + llvm::array_lengthof(MIPSTriples));
|
||||
break;
|
||||
case llvm::Triple::mips64el:
|
||||
LibDirs.append(
|
||||
MIPS64ELLibDirs, MIPS64ELLibDirs + llvm::array_lengthof(MIPS64ELLibDirs));
|
||||
LibDirs.append(MIPS64ELLibDirs,
|
||||
MIPS64ELLibDirs + llvm::array_lengthof(MIPS64ELLibDirs));
|
||||
TripleAliases.append(
|
||||
MIPS64ELTriples, MIPS64ELTriples + llvm::array_lengthof(MIPS64ELTriples));
|
||||
MultiarchLibDirs.append(
|
||||
MIPSELLibDirs, MIPSELLibDirs + llvm::array_lengthof(MIPSELLibDirs));
|
||||
MultiarchTripleAliases.append(
|
||||
MIPSELTriples, MIPSELTriples + llvm::array_lengthof(MIPSELTriples));
|
||||
MIPS64ELTriples,
|
||||
MIPS64ELTriples + llvm::array_lengthof(MIPS64ELTriples));
|
||||
BiarchLibDirs.append(MIPSELLibDirs,
|
||||
MIPSELLibDirs + llvm::array_lengthof(MIPSELLibDirs));
|
||||
BiarchTripleAliases.append(
|
||||
MIPSELTriples, MIPSELTriples + llvm::array_lengthof(MIPSELTriples));
|
||||
break;
|
||||
case llvm::Triple::ppc:
|
||||
LibDirs.append(PPCLibDirs, PPCLibDirs + llvm::array_lengthof(PPCLibDirs));
|
||||
TripleAliases.append(
|
||||
PPCTriples, PPCTriples + llvm::array_lengthof(PPCTriples));
|
||||
MultiarchLibDirs.append(
|
||||
PPC64LibDirs, PPC64LibDirs + llvm::array_lengthof(PPC64LibDirs));
|
||||
MultiarchTripleAliases.append(
|
||||
PPC64Triples, PPC64Triples + llvm::array_lengthof(PPC64Triples));
|
||||
TripleAliases.append(PPCTriples,
|
||||
PPCTriples + llvm::array_lengthof(PPCTriples));
|
||||
BiarchLibDirs.append(PPC64LibDirs,
|
||||
PPC64LibDirs + llvm::array_lengthof(PPC64LibDirs));
|
||||
BiarchTripleAliases.append(
|
||||
PPC64Triples, PPC64Triples + llvm::array_lengthof(PPC64Triples));
|
||||
break;
|
||||
case llvm::Triple::ppc64:
|
||||
LibDirs.append(
|
||||
PPC64LibDirs, PPC64LibDirs + llvm::array_lengthof(PPC64LibDirs));
|
||||
TripleAliases.append(
|
||||
PPC64Triples, PPC64Triples + llvm::array_lengthof(PPC64Triples));
|
||||
MultiarchLibDirs.append(
|
||||
PPCLibDirs, PPCLibDirs + llvm::array_lengthof(PPCLibDirs));
|
||||
MultiarchTripleAliases.append(
|
||||
PPCTriples, PPCTriples + llvm::array_lengthof(PPCTriples));
|
||||
LibDirs.append(PPC64LibDirs,
|
||||
PPC64LibDirs + llvm::array_lengthof(PPC64LibDirs));
|
||||
TripleAliases.append(PPC64Triples,
|
||||
PPC64Triples + llvm::array_lengthof(PPC64Triples));
|
||||
BiarchLibDirs.append(PPCLibDirs,
|
||||
PPCLibDirs + llvm::array_lengthof(PPCLibDirs));
|
||||
BiarchTripleAliases.append(PPCTriples,
|
||||
PPCTriples + llvm::array_lengthof(PPCTriples));
|
||||
break;
|
||||
case llvm::Triple::systemz:
|
||||
LibDirs.append(
|
||||
SystemZLibDirs, SystemZLibDirs + llvm::array_lengthof(SystemZLibDirs));
|
||||
TripleAliases.append(
|
||||
SystemZTriples, SystemZTriples + llvm::array_lengthof(SystemZTriples));
|
||||
LibDirs.append(SystemZLibDirs,
|
||||
SystemZLibDirs + llvm::array_lengthof(SystemZLibDirs));
|
||||
TripleAliases.append(SystemZTriples,
|
||||
SystemZTriples + llvm::array_lengthof(SystemZTriples));
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -1275,8 +1244,8 @@ Generic_GCC::GCCInstallationDetector::GCCInstallationDetector(
|
|||
TripleAliases.push_back(TargetTriple.str());
|
||||
|
||||
// Also include the multiarch variant if it's different.
|
||||
if (TargetTriple.str() != MultiarchTriple.str())
|
||||
MultiarchTripleAliases.push_back(MultiarchTriple.str());
|
||||
if (TargetTriple.str() != BiarchTriple.str())
|
||||
BiarchTripleAliases.push_back(BiarchTriple.str());
|
||||
}
|
||||
|
||||
static bool isSoftFloatABI(const ArgList &Args) {
|
||||
|
@ -1340,10 +1309,12 @@ static StringRef getMipsTargetABISuffix(llvm::Triple::ArchType TargetArch,
|
|||
return "/32";
|
||||
}
|
||||
|
||||
static bool findTargetMultiarchSuffix(std::string &Suffix,
|
||||
StringRef Path,
|
||||
llvm::Triple::ArchType TargetArch,
|
||||
const ArgList &Args) {
|
||||
static bool findTargetBiarchSuffix(std::string &Suffix, StringRef Path,
|
||||
llvm::Triple::ArchType TargetArch,
|
||||
const ArgList &Args) {
|
||||
// FIXME: This routine was only intended to model bi-arch toolchains which
|
||||
// use -m32 and -m64 to swap between variants of a target. It shouldn't be
|
||||
// doing ABI-based builtin location for MIPS.
|
||||
if (isMipsArch(TargetArch)) {
|
||||
StringRef ABISuffix = getMipsTargetABISuffix(TargetArch, Args);
|
||||
|
||||
|
@ -1377,8 +1348,8 @@ static bool findTargetMultiarchSuffix(std::string &Suffix,
|
|||
|
||||
void Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple(
|
||||
llvm::Triple::ArchType TargetArch, const ArgList &Args,
|
||||
const std::string &LibDir,
|
||||
StringRef CandidateTriple, bool NeedsMultiarchSuffix) {
|
||||
const std::string &LibDir, StringRef CandidateTriple,
|
||||
bool NeedsBiarchSuffix) {
|
||||
// There are various different suffixes involving the triple we
|
||||
// check for. We also record what is necessary to walk from each back
|
||||
// up to the lib directory.
|
||||
|
@ -1396,15 +1367,11 @@ void Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple(
|
|||
// triple.
|
||||
"/i386-linux-gnu/gcc/" + CandidateTriple.str()
|
||||
};
|
||||
const std::string InstallSuffixes[] = {
|
||||
"/../../..",
|
||||
"/../../../..",
|
||||
"/../..",
|
||||
"/../../../.."
|
||||
};
|
||||
const std::string InstallSuffixes[] = { "/../../..", "/../../../..", "/../..",
|
||||
"/../../../.." };
|
||||
// Only look at the final, weird Ubuntu suffix for i386-linux-gnu.
|
||||
const unsigned NumLibSuffixes = (llvm::array_lengthof(LibSuffixes) -
|
||||
(TargetArch != llvm::Triple::x86));
|
||||
const unsigned NumLibSuffixes =
|
||||
(llvm::array_lengthof(LibSuffixes) - (TargetArch != llvm::Triple::x86));
|
||||
for (unsigned i = 0; i < NumLibSuffixes; ++i) {
|
||||
StringRef LibSuffix = LibSuffixes[i];
|
||||
llvm::error_code EC;
|
||||
|
@ -1422,18 +1389,17 @@ void Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple(
|
|||
// in what would normally be GCCInstallPath and put the 64-bit
|
||||
// libs in a subdirectory named 64. The simple logic we follow is that
|
||||
// *if* there is a subdirectory of the right name with crtbegin.o in it,
|
||||
// we use that. If not, and if not a multiarch triple, we look for
|
||||
// we use that. If not, and if not a biarch triple alias, we look for
|
||||
// crtbegin.o without the subdirectory.
|
||||
|
||||
std::string MultiarchSuffix;
|
||||
if (findTargetMultiarchSuffix(MultiarchSuffix,
|
||||
LI->path(), TargetArch, Args)) {
|
||||
GCCMultiarchSuffix = MultiarchSuffix;
|
||||
std::string BiarchSuffix;
|
||||
if (findTargetBiarchSuffix(BiarchSuffix, LI->path(), TargetArch, Args)) {
|
||||
GCCBiarchSuffix = BiarchSuffix;
|
||||
} else {
|
||||
if (NeedsMultiarchSuffix ||
|
||||
if (NeedsBiarchSuffix ||
|
||||
!llvm::sys::fs::exists(LI->path() + "/crtbegin.o"))
|
||||
continue;
|
||||
GCCMultiarchSuffix.clear();
|
||||
GCCBiarchSuffix.clear();
|
||||
}
|
||||
|
||||
Version = CandidateVersion;
|
||||
|
@ -2293,12 +2259,11 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
|
|||
|
||||
if (IsAndroid && isMipsR2Arch(Triple.getArch(), Args))
|
||||
addPathIfExists(GCCInstallation.getInstallPath() +
|
||||
GCCInstallation.getMultiarchSuffix() +
|
||||
"/mips-r2",
|
||||
GCCInstallation.getBiarchSuffix() + "/mips-r2",
|
||||
Paths);
|
||||
else
|
||||
addPathIfExists((GCCInstallation.getInstallPath() +
|
||||
GCCInstallation.getMultiarchSuffix()),
|
||||
GCCInstallation.getBiarchSuffix()),
|
||||
Paths);
|
||||
|
||||
// If the GCC installation we found is inside of the sysroot, we want to
|
||||
|
@ -2334,7 +2299,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
|
|||
addPathIfExists(SysRoot + "/usr/lib/" + MultiarchTriple, Paths);
|
||||
addPathIfExists(SysRoot + "/usr/lib/../" + Multilib, Paths);
|
||||
|
||||
// Try walking via the GCC triple path in case of multiarch GCC
|
||||
// Try walking via the GCC triple path in case of biarch or multiarch GCC
|
||||
// installations with strange symlinks.
|
||||
if (GCCInstallation.isValid())
|
||||
addPathIfExists(SysRoot + "/usr/lib/" + GCCInstallation.getTriple().str() +
|
||||
|
@ -2344,7 +2309,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
|
|||
if (GCCInstallation.isValid()) {
|
||||
const std::string &LibPath = GCCInstallation.getParentLibPath();
|
||||
const llvm::Triple &GCCTriple = GCCInstallation.getTriple();
|
||||
if (!GCCInstallation.getMultiarchSuffix().empty())
|
||||
if (!GCCInstallation.getBiarchSuffix().empty())
|
||||
addPathIfExists(GCCInstallation.getInstallPath(), Paths);
|
||||
|
||||
if (StringRef(LibPath).startswith(SysRoot)) {
|
||||
|
@ -2437,15 +2402,13 @@ void Linux::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
|
|||
// Sourcery CodeBench and modern FSF Mips toolchains put extern C
|
||||
// system includes under three additional directories.
|
||||
if (GCCInstallation.isValid() && isMipsArch(getTriple().getArch())) {
|
||||
addExternCSystemIncludeIfExists(DriverArgs, CC1Args,
|
||||
GCCInstallation.getInstallPath() +
|
||||
"/include");
|
||||
addExternCSystemIncludeIfExists(
|
||||
DriverArgs, CC1Args, GCCInstallation.getInstallPath() + "/include");
|
||||
|
||||
addExternCSystemIncludeIfExists(DriverArgs, CC1Args,
|
||||
GCCInstallation.getInstallPath() +
|
||||
"/../../../../" +
|
||||
GCCInstallation.getTriple().str() +
|
||||
"/libc/usr/include");
|
||||
addExternCSystemIncludeIfExists(
|
||||
DriverArgs, CC1Args,
|
||||
GCCInstallation.getInstallPath() + "/../../../../" +
|
||||
GCCInstallation.getTriple().str() + "/libc/usr/include");
|
||||
}
|
||||
|
||||
// Implement generic Debian multiarch support.
|
||||
|
@ -2455,8 +2418,7 @@ void Linux::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
|
|||
// FIXME: These are older forms of multiarch. It's not clear that they're
|
||||
// in use in any released version of Debian, so we should consider
|
||||
// removing them.
|
||||
"/usr/include/i686-linux-gnu/64",
|
||||
"/usr/include/i486-linux-gnu/64"
|
||||
"/usr/include/i686-linux-gnu/64", "/usr/include/i486-linux-gnu/64"
|
||||
};
|
||||
const StringRef X86MultiarchIncludeDirs[] = {
|
||||
"/usr/include/i386-linux-gnu",
|
||||
|
@ -2464,8 +2426,7 @@ void Linux::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
|
|||
// FIXME: These are older forms of multiarch. It's not clear that they're
|
||||
// in use in any released version of Debian, so we should consider
|
||||
// removing them.
|
||||
"/usr/include/x86_64-linux-gnu/32",
|
||||
"/usr/include/i686-linux-gnu",
|
||||
"/usr/include/x86_64-linux-gnu/32", "/usr/include/i686-linux-gnu",
|
||||
"/usr/include/i486-linux-gnu"
|
||||
};
|
||||
const StringRef AArch64MultiarchIncludeDirs[] = {
|
||||
|
@ -2585,11 +2546,9 @@ void Linux::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
|
|||
StringRef Version = GCCInstallation.getVersion().Text;
|
||||
StringRef TripleStr = GCCInstallation.getTriple().str();
|
||||
|
||||
if (addLibStdCXXIncludePaths(LibDir.str() + "/../include",
|
||||
"/c++/" + Version.str(),
|
||||
TripleStr,
|
||||
GCCInstallation.getMultiarchSuffix(),
|
||||
DriverArgs, CC1Args))
|
||||
if (addLibStdCXXIncludePaths(
|
||||
LibDir.str() + "/../include", "/c++/" + Version.str(), TripleStr,
|
||||
GCCInstallation.getBiarchSuffix(), DriverArgs, CC1Args))
|
||||
return;
|
||||
|
||||
const std::string IncludePathCandidates[] = {
|
||||
|
@ -2604,9 +2563,10 @@ void Linux::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
|
|||
};
|
||||
|
||||
for (unsigned i = 0; i < llvm::array_lengthof(IncludePathCandidates); ++i) {
|
||||
if (addLibStdCXXIncludePaths(IncludePathCandidates[i], (TripleStr +
|
||||
GCCInstallation.getMultiarchSuffix()),
|
||||
DriverArgs, CC1Args))
|
||||
if (addLibStdCXXIncludePaths(
|
||||
IncludePathCandidates[i],
|
||||
(TripleStr + GCCInstallation.getBiarchSuffix()), DriverArgs,
|
||||
CC1Args))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ protected:
|
|||
|
||||
// FIXME: These might be better as path objects.
|
||||
std::string GCCInstallPath;
|
||||
std::string GCCMultiarchSuffix;
|
||||
std::string GCCBiarchSuffix;
|
||||
std::string GCCParentLibPath;
|
||||
|
||||
GCCVersion Version;
|
||||
|
@ -92,8 +92,9 @@ protected:
|
|||
/// \brief Get the detected GCC installation path.
|
||||
StringRef getInstallPath() const { return GCCInstallPath; }
|
||||
|
||||
/// \brief Get the detected GCC installation path suffix for multiarch GCCs.
|
||||
StringRef getMultiarchSuffix() const { return GCCMultiarchSuffix; }
|
||||
/// \brief Get the detected GCC installation path suffix for the bi-arch
|
||||
/// target variant.
|
||||
StringRef getBiarchSuffix() const { return GCCBiarchSuffix; }
|
||||
|
||||
/// \brief Get the detected GCC parent lib path.
|
||||
StringRef getParentLibPath() const { return GCCParentLibPath; }
|
||||
|
@ -102,19 +103,19 @@ protected:
|
|||
const GCCVersion &getVersion() const { return Version; }
|
||||
|
||||
private:
|
||||
static void CollectLibDirsAndTriples(
|
||||
const llvm::Triple &TargetTriple,
|
||||
const llvm::Triple &MultiarchTriple,
|
||||
SmallVectorImpl<StringRef> &LibDirs,
|
||||
SmallVectorImpl<StringRef> &TripleAliases,
|
||||
SmallVectorImpl<StringRef> &MultiarchLibDirs,
|
||||
SmallVectorImpl<StringRef> &MultiarchTripleAliases);
|
||||
static void
|
||||
CollectLibDirsAndTriples(const llvm::Triple &TargetTriple,
|
||||
const llvm::Triple &BiarchTriple,
|
||||
SmallVectorImpl<StringRef> &LibDirs,
|
||||
SmallVectorImpl<StringRef> &TripleAliases,
|
||||
SmallVectorImpl<StringRef> &BiarchLibDirs,
|
||||
SmallVectorImpl<StringRef> &BiarchTripleAliases);
|
||||
|
||||
void ScanLibDirForGCCTriple(llvm::Triple::ArchType TargetArch,
|
||||
const llvm::opt::ArgList &Args,
|
||||
const std::string &LibDir,
|
||||
StringRef CandidateTriple,
|
||||
bool NeedsMultiarchSuffix = false);
|
||||
bool NeedsBiarchSuffix = false);
|
||||
};
|
||||
|
||||
GCCInstallationDetector GCCInstallation;
|
||||
|
|
Loading…
Reference in New Issue