void-packages/srcpkgs/llvm12/patches/clang-002-add-musl-triples.patch

110 lines
5.6 KiB
Diff

--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2086,7 +2086,8 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
static const char *const ARMHFTriples[] = {"arm-linux-gnueabihf",
"armv7hl-redhat-linux-gnueabi",
"armv6hl-suse-linux-gnueabi",
- "armv7hl-suse-linux-gnueabi"};
+ "armv7hl-suse-linux-gnueabi",
+ "armv7l-linux-gnueabihf"};
static const char *const ARMebLibDirs[] = {"/lib"};
static const char *const ARMebTriples[] = {"armeb-linux-gnueabi",
"armeb-linux-androideabi"};
@@ -2153,8 +2154,7 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
"powerpc64-suse-linux", "powerpc-montavista-linuxspe"};
static const char *const PPCLELibDirs[] = {"/lib32", "/lib"};
static const char *const PPCLETriples[] = {"powerpcle-linux-gnu",
- "powerpcle-unknown-linux-gnu",
- "powerpcle-linux-musl"};
+ "powerpcle-unknown-linux-gnu"};
static const char *const PPC64LibDirs[] = {"/lib64", "/lib"};
static const char *const PPC64Triples[] = {
@@ -2235,6 +2235,87 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
return;
}
+ if (TargetTriple.isMusl()) {
+ static const char *const AArch64MuslTriples[] = {"aarch64-linux-musl"};
+ static const char *const ARMHFMuslTriples[] = {
+ "arm-linux-musleabihf", "armv7l-linux-musleabihf"
+ };
+ static const char *const ARMMuslTriples[] = {"arm-linux-musleabi"};
+ static const char *const X86_64MuslTriples[] = {"x86_64-linux-musl"};
+ static const char *const X86MuslTriples[] = {"i686-linux-musl"};
+ static const char *const MIPSMuslTriples[] = {
+ "mips-linux-musl", "mipsel-linux-musl",
+ "mipsel-linux-muslhf", "mips-linux-muslhf"
+ };
+ static const char *const PPCMuslTriples[] = {"powerpc-linux-musl"};
+ static const char *const PPCLEMuslTriples[] = {"powerpcle-linux-musl"};
+ static const char *const PPC64MuslTriples[] = {"powerpc64-linux-musl"};
+ static const char *const PPC64LEMuslTriples[] = {"powerpc64le-linux-musl"};
+
+ switch (TargetTriple.getArch()) {
+ case llvm::Triple::aarch64:
+ LibDirs.append(begin(AArch64LibDirs), end(AArch64LibDirs));
+ TripleAliases.append(begin(AArch64MuslTriples), end(AArch64MuslTriples));
+ BiarchLibDirs.append(begin(AArch64LibDirs), end(AArch64LibDirs));
+ BiarchTripleAliases.append(begin(AArch64MuslTriples), end(AArch64MuslTriples));
+ break;
+ case llvm::Triple::arm:
+ LibDirs.append(begin(ARMLibDirs), end(ARMLibDirs));
+ if (TargetTriple.getEnvironment() == llvm::Triple::MuslEABIHF) {
+ TripleAliases.append(begin(ARMHFMuslTriples), end(ARMHFMuslTriples));
+ } else {
+ TripleAliases.append(begin(ARMMuslTriples), end(ARMMuslTriples));
+ }
+ break;
+ case llvm::Triple::x86_64:
+ LibDirs.append(begin(X86_64LibDirs), end(X86_64LibDirs));
+ TripleAliases.append(begin(X86_64MuslTriples), end(X86_64MuslTriples));
+ BiarchLibDirs.append(begin(X86LibDirs), end(X86LibDirs));
+ BiarchTripleAliases.append(begin(X86MuslTriples), end(X86MuslTriples));
+ break;
+ case llvm::Triple::x86:
+ LibDirs.append(begin(X86LibDirs), end(X86LibDirs));
+ TripleAliases.append(begin(X86MuslTriples), end(X86MuslTriples));
+ BiarchLibDirs.append(begin(X86_64LibDirs), end(X86_64LibDirs));
+ BiarchTripleAliases.append(begin(X86_64MuslTriples), end(X86_64MuslTriples));
+ break;
+ case llvm::Triple::mips:
+ LibDirs.append(begin(MIPSLibDirs), end(MIPSLibDirs));
+ TripleAliases.append(begin(MIPSMuslTriples), end(MIPSMuslTriples));
+ break;
+ case llvm::Triple::ppc:
+ LibDirs.append(begin(PPCLibDirs), end(PPCLibDirs));
+ TripleAliases.append(begin(PPCMuslTriples), end(PPCMuslTriples));
+ BiarchLibDirs.append(begin(PPC64LibDirs), end(PPC64LibDirs));
+ BiarchTripleAliases.append(begin(PPC64MuslTriples), end(PPC64MuslTriples));
+ break;
+ case llvm::Triple::ppcle:
+ LibDirs.append(begin(PPCLELibDirs), end(PPCLELibDirs));
+ TripleAliases.append(begin(PPCLEMuslTriples), end(PPCLEMuslTriples));
+ BiarchLibDirs.append(begin(PPC64LELibDirs), end(PPC64LELibDirs));
+ BiarchTripleAliases.append(begin(PPC64LEMuslTriples), end(PPC64LEMuslTriples));
+ break;
+ case llvm::Triple::ppc64:
+ LibDirs.append(begin(PPC64LibDirs), end(PPC64LibDirs));
+ TripleAliases.append(begin(PPC64MuslTriples), end(PPC64MuslTriples));
+ BiarchLibDirs.append(begin(PPCLibDirs), end(PPCLibDirs));
+ BiarchTripleAliases.append(begin(PPCMuslTriples), end(PPCMuslTriples));
+ break;
+ case llvm::Triple::ppc64le:
+ LibDirs.append(begin(PPC64LELibDirs), end(PPC64LELibDirs));
+ TripleAliases.append(begin(PPC64LEMuslTriples), end(PPC64LEMuslTriples));
+ BiarchLibDirs.append(begin(PPCLELibDirs), end(PPCLELibDirs));
+ BiarchTripleAliases.append(begin(PPCLEMuslTriples), end(PPCLEMuslTriples));
+ break;
+ default:
+ break;
+ }
+ TripleAliases.push_back(TargetTriple.str());
+ if (TargetTriple.str() != BiarchTriple.str())
+ BiarchTripleAliases.push_back(BiarchTriple.str());
+ return;
+ }
+
// Android targets should not use GNU/Linux tools or libraries.
if (TargetTriple.isAndroid()) {
static const char *const AArch64AndroidTriples[] = {