diff options
Diffstat (limited to 'patches/clang_host/clang-0004-Add-musl-targets-and-dynamic-linker.patch')
-rw-r--r-- | patches/clang_host/clang-0004-Add-musl-targets-and-dynamic-linker.patch | 222 |
1 files changed, 222 insertions, 0 deletions
diff --git a/patches/clang_host/clang-0004-Add-musl-targets-and-dynamic-linker.patch b/patches/clang_host/clang-0004-Add-musl-targets-and-dynamic-linker.patch new file mode 100644 index 00000000..6384b088 --- /dev/null +++ b/patches/clang_host/clang-0004-Add-musl-targets-and-dynamic-linker.patch @@ -0,0 +1,222 @@ +From 4777c16fc6e717a852366fa2a447c852cca3b62d Mon Sep 17 00:00:00 2001 +From: Natanael Copa <ncopa@alpinelinux.org> +Date: Fri, 19 Feb 2016 13:35:08 +0100 +Subject: [PATCH 4/7] Add musl targets and dynamic linker + +--- + lib/Basic/Targets.cpp | 2 ++ + lib/CodeGen/TargetInfo.cpp | 6 +++++- + lib/Driver/ToolChains.cpp | 15 ++++++++++----- + lib/Driver/Tools.cpp | 44 +++++++++++++++++++++++++++++++++++++++++++- + 4 files changed, 60 insertions(+), 7 deletions(-) + +diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp +index af8aea0..1e27c7a 100644 +--- a/lib/Basic/Targets.cpp ++++ b/lib/Basic/Targets.cpp +@@ -4513,6 +4513,8 @@ public: + case llvm::Triple::Android: + case llvm::Triple::GNUEABI: + case llvm::Triple::GNUEABIHF: ++ case llvm::Triple::MuslEABI: ++ case llvm::Triple::MuslEABIHF: + setABI("aapcs-linux"); + break; + case llvm::Triple::EABIHF: +diff --git a/lib/CodeGen/TargetInfo.cpp b/lib/CodeGen/TargetInfo.cpp +index 3d1ddef..f6b3474 100644 +--- a/lib/CodeGen/TargetInfo.cpp ++++ b/lib/CodeGen/TargetInfo.cpp +@@ -4757,6 +4757,8 @@ public: + case llvm::Triple::EABIHF: + case llvm::Triple::GNUEABI: + case llvm::Triple::GNUEABIHF: ++ case llvm::Triple::MuslEABI: ++ case llvm::Triple::MuslEABIHF: + return true; + default: + return false; +@@ -4767,6 +4769,7 @@ public: + switch (getTarget().getTriple().getEnvironment()) { + case llvm::Triple::EABIHF: + case llvm::Triple::GNUEABIHF: ++ case llvm::Triple::MuslEABIHF: + return true; + default: + return false; +@@ -7492,7 +7495,8 @@ const TargetCodeGenInfo &CodeGenModule::getTargetCodeGenInfo() { + Kind = ARMABIInfo::AAPCS16_VFP; + else if (CodeGenOpts.FloatABI == "hard" || + (CodeGenOpts.FloatABI != "soft" && +- Triple.getEnvironment() == llvm::Triple::GNUEABIHF)) ++ (Triple.getEnvironment() == llvm::Triple::GNUEABIHF || ++ Triple.getEnvironment() == llvm::Triple::MuslEABIHF))) + Kind = ARMABIInfo::AAPCS_VFP; + + return *(TheTargetCodeGenInfo = new ARMTargetCodeGenInfo(Types, Kind)); +diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp +index 6b0b31d..0db9644 100644 +--- a/lib/Driver/ToolChains.cpp ++++ b/lib/Driver/ToolChains.cpp +@@ -1523,7 +1523,8 @@ bool Generic_GCC::GCCInstallationDetector::getBiarchSibling(Multilib &M) const { + case llvm::Triple::arm: + case llvm::Triple::thumb: + LibDirs.append(begin(ARMLibDirs), end(ARMLibDirs)); +- if (TargetTriple.getEnvironment() == llvm::Triple::GNUEABIHF) { ++ if (TargetTriple.getEnvironment() == llvm::Triple::GNUEABIHF || ++ TargetTriple.getEnvironment() == llvm::Triple::MuslEABIHF) { + TripleAliases.append(begin(ARMHFTriples), end(ARMHFTriples)); + } else { + TripleAliases.append(begin(ARMTriples), end(ARMTriples)); +@@ -1532,7 +1533,8 @@ bool Generic_GCC::GCCInstallationDetector::getBiarchSibling(Multilib &M) const { + case llvm::Triple::armeb: + case llvm::Triple::thumbeb: + LibDirs.append(begin(ARMebLibDirs), end(ARMebLibDirs)); +- if (TargetTriple.getEnvironment() == llvm::Triple::GNUEABIHF) { ++ if (TargetTriple.getEnvironment() == llvm::Triple::GNUEABIHF || ++ TargetTriple.getEnvironment() == llvm::Triple::MuslEABIHF) { + TripleAliases.append(begin(ARMebHFTriples), end(ARMebHFTriples)); + } else { + TripleAliases.append(begin(ARMebTriples), end(ARMebTriples)); +@@ -3528,7 +3530,8 @@ static std::string getMultiarchTriple(const Driver &D, + // regardless of what the actual target triple is. + case llvm::Triple::arm: + case llvm::Triple::thumb: +- if (TargetEnvironment == llvm::Triple::GNUEABIHF) { ++ if (TargetEnvironment == llvm::Triple::GNUEABIHF || ++ TargetEnvironment == llvm::Triple::MuslEABIHF) { + if (D.getVFS().exists(SysRoot + "/lib/arm-linux-gnueabihf")) + return "arm-linux-gnueabihf"; + } else { +@@ -3538,7 +3541,8 @@ static std::string getMultiarchTriple(const Driver &D, + break; + case llvm::Triple::armeb: + case llvm::Triple::thumbeb: +- if (TargetEnvironment == llvm::Triple::GNUEABIHF) { ++ if (TargetEnvironment == llvm::Triple::GNUEABIHF || ++ TargetEnvironment == llvm::Triple::MuslEABIHF) { + if (D.getVFS().exists(SysRoot + "/lib/armeb-linux-gnueabihf")) + return "armeb-linux-gnueabihf"; + } else { +@@ -3969,7 +3973,8 @@ void Linux::AddClangSystemIncludeArgs(const ArgList &DriverArgs, + break; + case llvm::Triple::arm: + case llvm::Triple::thumb: +- if (getTriple().getEnvironment() == llvm::Triple::GNUEABIHF) ++ if (getTriple().getEnvironment() == llvm::Triple::GNUEABIHF || ++ getTriple().getEnvironment() == llvm::Triple::MuslEABIHF) + MultiarchIncludeDirs = ARMHFMultiarchIncludeDirs; + else + MultiarchIncludeDirs = ARMMultiarchIncludeDirs; +diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp +index b7ac24f..ea1ce6f 100644 +--- a/lib/Driver/Tools.cpp ++++ b/lib/Driver/Tools.cpp +@@ -712,6 +712,7 @@ arm::FloatABI arm::getARMFloatABI(const ToolChain &TC, const ArgList &Args) { + case llvm::Triple::FreeBSD: + switch (Triple.getEnvironment()) { + case llvm::Triple::GNUEABIHF: ++ case llvm::Triple::MuslEABIHF: + ABI = FloatABI::Hard; + break; + default: +@@ -725,6 +726,7 @@ arm::FloatABI arm::getARMFloatABI(const ToolChain &TC, const ArgList &Args) { + switch (Triple.getEnvironment()) { + case llvm::Triple::GNUEABIHF: + case llvm::Triple::EABIHF: ++ case llvm::Triple::MuslEABIHF: + ABI = FloatABI::Hard; + break; + case llvm::Triple::GNUEABI: +@@ -968,6 +970,8 @@ void Clang::AddARMTargetArgs(const llvm::Triple &Triple, const ArgList &Args, + case llvm::Triple::Android: + case llvm::Triple::GNUEABI: + case llvm::Triple::GNUEABIHF: ++ case llvm::Triple::MuslEABI: ++ case llvm::Triple::MuslEABIHF: + ABIName = "aapcs-linux"; + break; + case llvm::Triple::EABIHF: +@@ -7857,6 +7861,8 @@ void freebsd::Assembler::ConstructJob(Compilation &C, const JobAction &JA, + switch (getToolChain().getTriple().getEnvironment()) { + case llvm::Triple::GNUEABIHF: + case llvm::Triple::GNUEABI: ++ case llvm::Triple::MuslEABIHF: ++ case llvm::Triple::MuslEABI: + case llvm::Triple::EABI: + CmdArgs.push_back("-meabi=5"); + break; +@@ -8199,10 +8205,12 @@ void netbsd::Linker::ConstructJob(Compilation &C, const JobAction &JA, + switch (getToolChain().getTriple().getEnvironment()) { + case llvm::Triple::EABI: + case llvm::Triple::GNUEABI: ++ case llvm::Triple::MuslEABI: + CmdArgs.push_back("armelf_nbsd_eabi"); + break; + case llvm::Triple::EABIHF: + case llvm::Triple::GNUEABIHF: ++ case llvm::Triple::MuslEABIHF: + CmdArgs.push_back("armelf_nbsd_eabihf"); + break; + default: +@@ -8219,10 +8227,12 @@ void netbsd::Linker::ConstructJob(Compilation &C, const JobAction &JA, + switch (getToolChain().getTriple().getEnvironment()) { + case llvm::Triple::EABI: + case llvm::Triple::GNUEABI: ++ case llvm::Triple::MuslEABI: + CmdArgs.push_back("armelfb_nbsd_eabi"); + break; + case llvm::Triple::EABIHF: + case llvm::Triple::GNUEABIHF: ++ case llvm::Triple::MuslEABIHF: + CmdArgs.push_back("armelfb_nbsd_eabihf"); + break; + default: +@@ -8623,11 +8633,43 @@ static void AddLibgcc(const llvm::Triple &Triple, const Driver &D, + CmdArgs.push_back("-ldl"); + } + ++static std::string getMuslDynamicLinker(const llvm::Triple::ArchType Arch, ++ const llvm::Triple::EnvironmentType Env) { ++ switch (Arch) { ++ case llvm::Triple::arm: ++ case llvm::Triple::thumb: ++ return Env == llvm::Triple::MuslEABIHF ? ++ "/lib/ld-musl-armhf.so.1" : "/lib/ld-musl-arm.so.1"; ++ case llvm::Triple::armeb: ++ case llvm::Triple::thumbeb: ++ return Env == llvm::Triple::MuslEABIHF ? ++ "/lib/ld-musl-armebhf.so.1" : "/lib/ld-musl-armeb.so.1"; ++ case llvm::Triple::aarch64: ++ return "/lib/ld-musl-aarch64.so.1"; ++ case llvm::Triple::aarch64_be: ++ return "/lib/ld-musl-aarch64_be.so.1"; ++ case llvm::Triple::mips: ++ return "/lib/ld-musl-mips.so.1"; ++ case llvm::Triple::mipsel: ++ return "/lib/ld-musl-mipsel.so.1"; ++ case llvm::Triple::ppc: ++ return "/lib/ld-musl-powerpc.so.1"; ++ case llvm::Triple::x86: ++ return "/lib/ld-musl-i386.so.1"; ++//case llvm::Triple::x86_64: ++ default: ++ return "/lib/ld-musl-x86_64.so.1"; ++ } ++ return NULL; ++} ++ + static std::string getLinuxDynamicLinker(const ArgList &Args, + const toolchains::Linux &ToolChain) { + const llvm::Triple::ArchType Arch = ToolChain.getArch(); + +- if (ToolChain.getTriple().isAndroid()) { ++ if (ToolChain.getTriple().isMusl()) { ++ return getMuslDynamicLinker(Arch, ToolChain.getTriple().getEnvironment()); ++ } else if (ToolChain.getTriple().isAndroid()) { + if (ToolChain.getTriple().isArch64Bit()) + return "/system/bin/linker64"; + else +-- +2.7.3 + |