[driver][mips] Check both `gnuabi64` and `gnu` suffixes in `getMultiarchTriple`

In case of N64 ABI toolchain paths migth have `mips-linux-gnuabi64`
or `mips-linux-gnu` directory regardless of selected environment.
Check both variants while detecting a multiarch triple.

Fix for the bug https://bugs.llvm.org/show_bug.cgi?id=41204

llvm-svn: 357506
This commit is contained in:
Simon Atanasyan 2019-04-02 18:03:31 +00:00
parent 27c0f204d7
commit 751510cd78
2 changed files with 29 additions and 14 deletions

View File

@ -44,6 +44,7 @@ static std::string getMultiarchTriple(const Driver &D,
TargetTriple.getEnvironment();
bool IsAndroid = TargetTriple.isAndroid();
bool IsMipsR6 = TargetTriple.getSubArch() == llvm::Triple::MipsSubArch_r6;
bool IsMipsN32Abi = TargetTriple.getEnvironment() == llvm::Triple::GNUABIN32;
// For most architectures, just use whatever we have rather than trying to be
// clever.
@ -102,33 +103,37 @@ static std::string getMultiarchTriple(const Driver &D,
return "aarch64_be-linux-gnu";
break;
case llvm::Triple::mips: {
std::string Arch = IsMipsR6 ? "mipsisa32r6" : "mips";
if (D.getVFS().exists(SysRoot + "/lib/" + Arch + "-linux-gnu"))
return Arch + "-linux-gnu";
std::string MT = IsMipsR6 ? "mipsisa32r6-linux-gnu" : "mips-linux-gnu";
if (D.getVFS().exists(SysRoot + "/lib/" + MT))
return MT;
break;
}
case llvm::Triple::mipsel: {
if (IsAndroid)
return "mipsel-linux-android";
std::string Arch = IsMipsR6 ? "mipsisa32r6el" : "mipsel";
if (D.getVFS().exists(SysRoot + "/lib/" + Arch + "-linux-gnu"))
return Arch + "-linux-gnu";
std::string MT = IsMipsR6 ? "mipsisa32r6el-linux-gnu" : "mipsel-linux-gnu";
if (D.getVFS().exists(SysRoot + "/lib/" + MT))
return MT;
break;
}
case llvm::Triple::mips64: {
std::string Arch = IsMipsR6 ? "mipsisa64r6" : "mips64";
std::string ABI = llvm::Triple::getEnvironmentTypeName(TargetEnvironment);
if (D.getVFS().exists(SysRoot + "/lib/" + Arch + "-linux-" + ABI))
return Arch + "-linux-" + ABI;
std::string MT = std::string(IsMipsR6 ? "mipsisa64r6" : "mips64") +
"-linux-" + (IsMipsN32Abi ? "gnuabin32" : "gnuabi64");
if (D.getVFS().exists(SysRoot + "/lib/" + MT))
return MT;
if (D.getVFS().exists(SysRoot + "/lib/mips64-linux-gnu"))
return "mips64-linux-gnu";
break;
}
case llvm::Triple::mips64el: {
if (IsAndroid)
return "mips64el-linux-android";
std::string Arch = IsMipsR6 ? "mipsisa64r6el" : "mips64el";
std::string ABI = llvm::Triple::getEnvironmentTypeName(TargetEnvironment);
if (D.getVFS().exists(SysRoot + "/lib/" + Arch + "-linux-" + ABI))
return Arch + "-linux-" + ABI;
std::string MT = std::string(IsMipsR6 ? "mipsisa64r6el" : "mips64el") +
"-linux-" + (IsMipsN32Abi ? "gnuabin32" : "gnuabi64");
if (D.getVFS().exists(SysRoot + "/lib/" + MT))
return MT;
if (D.getVFS().exists(SysRoot + "/lib/mips64el-linux-gnu"))
return "mips64el-linux-gnu";
break;
}
case llvm::Triple::ppc:

View File

@ -1660,6 +1660,11 @@
// CHECK-DEBIAN-ML-MIPS64EL-N32: "-L[[SYSROOT]]/usr/lib"
//
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
// RUN: --target=mips64-unknown-linux-gnu \
// RUN: --gcc-toolchain="" \
// RUN: --sysroot=%S/Inputs/debian_6_mips64_tree \
// RUN: | FileCheck --check-prefix=CHECK-DEBIAN-ML-MIPS64-GNUABI %s
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
// RUN: --target=mips64-linux-gnuabi64 -mabi=n64 \
// RUN: --gcc-toolchain="" \
// RUN: --sysroot=%S/Inputs/debian_6_mips64_tree \
@ -1680,6 +1685,11 @@
// CHECK-DEBIAN-ML-MIPS64-GNUABI: "{{.*}}/usr/lib/gcc/mips64-linux-gnuabi64/4.9/../../../mips64-linux-gnuabi64{{/|\\\\}}crtn.o"
//
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
// RUN: --target=mips64el-unknown-linux-gnu \
// RUN: --gcc-toolchain="" \
// RUN: --sysroot=%S/Inputs/debian_6_mips64_tree \
// RUN: | FileCheck --check-prefix=CHECK-DEBIAN-ML-MIPS64EL-GNUABI %s
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
// RUN: --target=mips64el-linux-gnuabi64 -mabi=n64 \
// RUN: --gcc-toolchain="" \
// RUN: --sysroot=%S/Inputs/debian_6_mips64_tree \