From 66a59fa0b5677130ef96cea7a6c8139f22a03ccf Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Thu, 31 Mar 2016 04:41:00 +0000 Subject: clang: Emit correct ldso name on musl targets Signed-off-by: Khem Raj --- .../clang/0001-driver-Add-musl-ldso-support.patch | 68 +++++++++++++ .../clang/0001-triplet-Add-musl-support.patch | 111 +++++++++++++++++++++ recipes-devtools/clang/clang_git.bb | 2 + 3 files changed, 181 insertions(+) create mode 100644 recipes-devtools/clang/clang/0001-driver-Add-musl-ldso-support.patch create mode 100644 recipes-devtools/clang/clang/0001-triplet-Add-musl-support.patch diff --git a/recipes-devtools/clang/clang/0001-driver-Add-musl-ldso-support.patch b/recipes-devtools/clang/clang/0001-driver-Add-musl-ldso-support.patch new file mode 100644 index 0000000..494a671 --- /dev/null +++ b/recipes-devtools/clang/clang/0001-driver-Add-musl-ldso-support.patch @@ -0,0 +1,68 @@ +From 8fddf3128d740d2e8831367c827fa1b747364563 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Wed, 30 Mar 2016 19:56:10 -0700 +Subject: [PATCH] driver: Add musl ldso support + +Linux/musl libc implementation has different ldso +this needs to take effect when target arch is detected +as a musl based Linux platform + +Signed-off-by: Khem Raj +--- + lib/Driver/Tools.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 40 insertions(+) + +diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp +index e72e4bd..968542c 100644 +--- a/lib/Driver/Tools.cpp ++++ b/lib/Driver/Tools.cpp +@@ -8240,6 +8240,46 @@ static std::string getLinuxDynamicLinker(const ArgList &Args, + return "/system/bin/linker64"; + else + return "/system/bin/linker"; ++ } else if (ToolChain.getTriple().isLinuxMuslEnvironment()) { ++ switch (Arch) { ++ case llvm::Triple::x86: ++ return "/lib/ld-musl-i386.so.1"; ++ case llvm::Triple::x86_64: ++ if (ToolChain.getTriple().getEnvironment() == llvm::Triple::MUSLX32) ++ return "/lib/ld-musl-x32.so.1"; ++ else ++ return "/lib/ld-musl-x86_64.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::ppc: ++ return "/lib/ld-musl-powerpc.so.1"; ++ case llvm::Triple::ppc64: ++ return "/lib/ld-musl-powerpc64.so.1"; ++ case llvm::Triple::arm: ++ case llvm::Triple::thumb: ++ if(arm::getARMFloatABI(ToolChain, Args) == arm::FloatABI::Hard) ++ return "/lib/ld-musl-armhf.so.1"; ++ else ++ return "/lib/ld-musl-arm.so.1"; ++ case llvm::Triple::armeb: ++ case llvm::Triple::thumbeb: ++ if(arm::getARMFloatABI(ToolChain, Args) == arm::FloatABI::Hard) ++ return "/lib/ld-musl-armebhf.so.1"; ++ else ++ return "/lib/ld-musl-armeb.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::mips64: ++ return "/lib/ld-musl-mips64.so.1"; ++ case llvm::Triple::mips64el: ++ return "/lib/ld-musl-mipsel64el.so.1"; ++ default: ++ break; ++ } + } else if (Arch == llvm::Triple::x86 || Arch == llvm::Triple::sparc || + Arch == llvm::Triple::sparcel) + return "/lib/ld-linux.so.2"; +-- +2.7.4 + diff --git a/recipes-devtools/clang/clang/0001-triplet-Add-musl-support.patch b/recipes-devtools/clang/clang/0001-triplet-Add-musl-support.patch new file mode 100644 index 0000000..9888a5d --- /dev/null +++ b/recipes-devtools/clang/clang/0001-triplet-Add-musl-support.patch @@ -0,0 +1,111 @@ +From 31a62e652efc8e582e3febda0a300fd3f345e260 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Wed, 30 Mar 2016 19:55:41 -0700 +Subject: [PATCH] triplet: Add musl support + +Signed-off-by: Khem Raj +--- + include/llvm/ADT/Triple.h | 13 +++++++++++++ + lib/Support/Triple.cpp | 10 +++++++++- + lib/Target/ARM/ARMSubtarget.h | 3 +++ + lib/Target/ARM/ARMTargetMachine.cpp | 2 ++ + 4 files changed, 27 insertions(+), 1 deletion(-) + +diff --git a/include/llvm/ADT/Triple.h b/include/llvm/ADT/Triple.h +index d163ac7..a4ffc55 100644 +--- a/include/llvm/ADT/Triple.h ++++ b/include/llvm/ADT/Triple.h +@@ -175,6 +175,10 @@ public: + GNUEABI, + GNUEABIHF, + GNUX32, ++ MUSL, ++ MUSLEABI, ++ MUSLEABIHF, ++ MUSLX32, + CODE16, + EABI, + EABIHF, +@@ -497,6 +501,15 @@ public: + return getOS() == Triple::Win32 && getEnvironment() == Triple::GNU; + } + ++ /// Checks if the environment is Linux with musl ++ bool isLinuxMuslEnvironment() const { ++ return getOS() == Triple::Linux && ++ (getEnvironment() == Triple::MUSL || ++ getEnvironment() == Triple::MUSLX32 || ++ getEnvironment() == Triple::MUSLEABI || ++ getEnvironment() == Triple::MUSLEABIHF); ++ } ++ + /// Tests for either Cygwin or MinGW OS + bool isOSCygMing() const { + return isWindowsCygwinEnvironment() || isWindowsGNUEnvironment(); +diff --git a/lib/Support/Triple.cpp b/lib/Support/Triple.cpp +index 1967fac..146ed82 100644 +--- a/lib/Support/Triple.cpp ++++ b/lib/Support/Triple.cpp +@@ -201,6 +201,10 @@ const char *Triple::getEnvironmentTypeName(EnvironmentType Kind) { + case GNUEABIHF: return "gnueabihf"; + case GNUEABI: return "gnueabi"; + case GNUX32: return "gnux32"; ++ case MUSL: return "musl"; ++ case MUSLEABIHF: return "musleabihf"; ++ case MUSLEABI: return "musleabi"; ++ case MUSLX32: return "muslx32"; + case CODE16: return "code16"; + case EABI: return "eabi"; + case EABIHF: return "eabihf"; +@@ -460,7 +464,11 @@ static Triple::EnvironmentType parseEnvironment(StringRef EnvironmentName) { + .StartsWith("eabi", Triple::EABI) + .StartsWith("gnueabihf", Triple::GNUEABIHF) + .StartsWith("gnueabi", Triple::GNUEABI) +- .StartsWith("gnux32", Triple::GNUX32) ++ .StartsWith("musl", Triple::MUSL) ++ .StartsWith("gnux32", Triple::MUSLX32) ++ .StartsWith("musleabihf", Triple::MUSLEABIHF) ++ .StartsWith("musleabi", Triple::MUSLEABI) ++ .StartsWith("muslx32", Triple::GNUX32) + .StartsWith("code16", Triple::CODE16) + .StartsWith("gnu", Triple::GNU) + .StartsWith("android", Triple::Android) +diff --git a/lib/Target/ARM/ARMSubtarget.h b/lib/Target/ARM/ARMSubtarget.h +index ec1212d..902ce4a 100644 +--- a/lib/Target/ARM/ARMSubtarget.h ++++ b/lib/Target/ARM/ARMSubtarget.h +@@ -424,8 +424,10 @@ public: + bool isTargetEHABICompatible() const { + return (TargetTriple.getEnvironment() == Triple::EABI || + TargetTriple.getEnvironment() == Triple::GNUEABI || ++ TargetTriple.getEnvironment() == Triple::MUSLEABI || + TargetTriple.getEnvironment() == Triple::EABIHF || + TargetTriple.getEnvironment() == Triple::GNUEABIHF || ++ TargetTriple.getEnvironment() == Triple::MUSLEABIHF || + isTargetAndroid()) && + !isTargetDarwin() && !isTargetWindows(); + } +@@ -433,6 +435,7 @@ public: + bool isTargetHardFloat() const { + // FIXME: this is invalid for WindowsCE + return TargetTriple.getEnvironment() == Triple::GNUEABIHF || ++ TargetTriple.getEnvironment() == Triple::MUSLEABIHF || + TargetTriple.getEnvironment() == Triple::EABIHF || + isTargetWindows() || isAAPCS16_ABI(); + } +diff --git a/lib/Target/ARM/ARMTargetMachine.cpp b/lib/Target/ARM/ARMTargetMachine.cpp +index 390b39c..9840c11 100644 +--- a/lib/Target/ARM/ARMTargetMachine.cpp ++++ b/lib/Target/ARM/ARMTargetMachine.cpp +@@ -99,6 +99,8 @@ computeTargetABI(const Triple &TT, StringRef CPU, + case llvm::Triple::Android: + case llvm::Triple::GNUEABI: + case llvm::Triple::GNUEABIHF: ++ case llvm::Triple::MUSLEABI: ++ case llvm::Triple::MUSLEABIHF: + case llvm::Triple::EABIHF: + case llvm::Triple::EABI: + TargetABI = ARMBaseTargetMachine::ARM_ABI_AAPCS; +-- +2.7.4 + diff --git a/recipes-devtools/clang/clang_git.bb b/recipes-devtools/clang/clang_git.bb index 698c7b4..994d1de 100644 --- a/recipes-devtools/clang/clang_git.bb +++ b/recipes-devtools/clang/clang_git.bb @@ -17,6 +17,8 @@ SRC_URI = "${LLVM_GIT}/llvm.git;protocol=${LLVM_GIT_PROTOCOL};branch=${BRANCH};n ${LLVM_GIT}/clang.git;protocol=${LLVM_GIT_PROTOCOL};branch=${BRANCH};destsuffix=git/tools/clang;name=clang \ file://0001-Remove-CMAKE_CROSSCOMPILING-so-it-can-cross-compile.patch \ file://0002-Do-not-assume-linux-glibc.patch \ + file://0001-triplet-Add-musl-support.patch \ + file://0001-driver-Add-musl-ldso-support.patch;patchdir=tools/clang \ " SRC_URI_append_libc-musl_class-target = " file://0001-remove-fopen64-fseeko64-ftello64-tmpfile64-on-musl.patch " -- cgit v1.2.3-54-g00ecf