diff options
author | Khem Raj <raj.khem@gmail.com> | 2016-03-31 04:41:00 +0000 |
---|---|---|
committer | Khem Raj <raj.khem@gmail.com> | 2016-03-31 04:41:00 +0000 |
commit | 66a59fa0b5677130ef96cea7a6c8139f22a03ccf (patch) | |
tree | 1d9fb114f8b55d0b88039a19f528b4c303351ab3 | |
parent | bef9311982e38876497c731a1d6726efcdd4aca9 (diff) | |
download | meta-clang-66a59fa0b5677130ef96cea7a6c8139f22a03ccf.tar.gz |
clang: Emit correct ldso name on musl targets
Signed-off-by: Khem Raj <raj.khem@gmail.com>
3 files changed, 181 insertions, 0 deletions
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 @@ | |||
1 | From 8fddf3128d740d2e8831367c827fa1b747364563 Mon Sep 17 00:00:00 2001 | ||
2 | From: Khem Raj <raj.khem@gmail.com> | ||
3 | Date: Wed, 30 Mar 2016 19:56:10 -0700 | ||
4 | Subject: [PATCH] driver: Add musl ldso support | ||
5 | |||
6 | Linux/musl libc implementation has different ldso | ||
7 | this needs to take effect when target arch is detected | ||
8 | as a musl based Linux platform | ||
9 | |||
10 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
11 | --- | ||
12 | lib/Driver/Tools.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ | ||
13 | 1 file changed, 40 insertions(+) | ||
14 | |||
15 | diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp | ||
16 | index e72e4bd..968542c 100644 | ||
17 | --- a/lib/Driver/Tools.cpp | ||
18 | +++ b/lib/Driver/Tools.cpp | ||
19 | @@ -8240,6 +8240,46 @@ static std::string getLinuxDynamicLinker(const ArgList &Args, | ||
20 | return "/system/bin/linker64"; | ||
21 | else | ||
22 | return "/system/bin/linker"; | ||
23 | + } else if (ToolChain.getTriple().isLinuxMuslEnvironment()) { | ||
24 | + switch (Arch) { | ||
25 | + case llvm::Triple::x86: | ||
26 | + return "/lib/ld-musl-i386.so.1"; | ||
27 | + case llvm::Triple::x86_64: | ||
28 | + if (ToolChain.getTriple().getEnvironment() == llvm::Triple::MUSLX32) | ||
29 | + return "/lib/ld-musl-x32.so.1"; | ||
30 | + else | ||
31 | + return "/lib/ld-musl-x86_64.so.1"; | ||
32 | + case llvm::Triple::aarch64: | ||
33 | + return "/lib/ld-musl-aarch64.so.1"; | ||
34 | + case llvm::Triple::aarch64_be: | ||
35 | + return "/lib/ld-musl-aarch64_be.so.1"; | ||
36 | + case llvm::Triple::ppc: | ||
37 | + return "/lib/ld-musl-powerpc.so.1"; | ||
38 | + case llvm::Triple::ppc64: | ||
39 | + return "/lib/ld-musl-powerpc64.so.1"; | ||
40 | + case llvm::Triple::arm: | ||
41 | + case llvm::Triple::thumb: | ||
42 | + if(arm::getARMFloatABI(ToolChain, Args) == arm::FloatABI::Hard) | ||
43 | + return "/lib/ld-musl-armhf.so.1"; | ||
44 | + else | ||
45 | + return "/lib/ld-musl-arm.so.1"; | ||
46 | + case llvm::Triple::armeb: | ||
47 | + case llvm::Triple::thumbeb: | ||
48 | + if(arm::getARMFloatABI(ToolChain, Args) == arm::FloatABI::Hard) | ||
49 | + return "/lib/ld-musl-armebhf.so.1"; | ||
50 | + else | ||
51 | + return "/lib/ld-musl-armeb.so.1"; | ||
52 | + case llvm::Triple::mips: | ||
53 | + return "/lib/ld-musl-mips.so.1"; | ||
54 | + case llvm::Triple::mipsel: | ||
55 | + return "/lib/ld-musl-mipsel.so.1"; | ||
56 | + case llvm::Triple::mips64: | ||
57 | + return "/lib/ld-musl-mips64.so.1"; | ||
58 | + case llvm::Triple::mips64el: | ||
59 | + return "/lib/ld-musl-mipsel64el.so.1"; | ||
60 | + default: | ||
61 | + break; | ||
62 | + } | ||
63 | } else if (Arch == llvm::Triple::x86 || Arch == llvm::Triple::sparc || | ||
64 | Arch == llvm::Triple::sparcel) | ||
65 | return "/lib/ld-linux.so.2"; | ||
66 | -- | ||
67 | 2.7.4 | ||
68 | |||
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 @@ | |||
1 | From 31a62e652efc8e582e3febda0a300fd3f345e260 Mon Sep 17 00:00:00 2001 | ||
2 | From: Khem Raj <raj.khem@gmail.com> | ||
3 | Date: Wed, 30 Mar 2016 19:55:41 -0700 | ||
4 | Subject: [PATCH] triplet: Add musl support | ||
5 | |||
6 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
7 | --- | ||
8 | include/llvm/ADT/Triple.h | 13 +++++++++++++ | ||
9 | lib/Support/Triple.cpp | 10 +++++++++- | ||
10 | lib/Target/ARM/ARMSubtarget.h | 3 +++ | ||
11 | lib/Target/ARM/ARMTargetMachine.cpp | 2 ++ | ||
12 | 4 files changed, 27 insertions(+), 1 deletion(-) | ||
13 | |||
14 | diff --git a/include/llvm/ADT/Triple.h b/include/llvm/ADT/Triple.h | ||
15 | index d163ac7..a4ffc55 100644 | ||
16 | --- a/include/llvm/ADT/Triple.h | ||
17 | +++ b/include/llvm/ADT/Triple.h | ||
18 | @@ -175,6 +175,10 @@ public: | ||
19 | GNUEABI, | ||
20 | GNUEABIHF, | ||
21 | GNUX32, | ||
22 | + MUSL, | ||
23 | + MUSLEABI, | ||
24 | + MUSLEABIHF, | ||
25 | + MUSLX32, | ||
26 | CODE16, | ||
27 | EABI, | ||
28 | EABIHF, | ||
29 | @@ -497,6 +501,15 @@ public: | ||
30 | return getOS() == Triple::Win32 && getEnvironment() == Triple::GNU; | ||
31 | } | ||
32 | |||
33 | + /// Checks if the environment is Linux with musl | ||
34 | + bool isLinuxMuslEnvironment() const { | ||
35 | + return getOS() == Triple::Linux && | ||
36 | + (getEnvironment() == Triple::MUSL || | ||
37 | + getEnvironment() == Triple::MUSLX32 || | ||
38 | + getEnvironment() == Triple::MUSLEABI || | ||
39 | + getEnvironment() == Triple::MUSLEABIHF); | ||
40 | + } | ||
41 | + | ||
42 | /// Tests for either Cygwin or MinGW OS | ||
43 | bool isOSCygMing() const { | ||
44 | return isWindowsCygwinEnvironment() || isWindowsGNUEnvironment(); | ||
45 | diff --git a/lib/Support/Triple.cpp b/lib/Support/Triple.cpp | ||
46 | index 1967fac..146ed82 100644 | ||
47 | --- a/lib/Support/Triple.cpp | ||
48 | +++ b/lib/Support/Triple.cpp | ||
49 | @@ -201,6 +201,10 @@ const char *Triple::getEnvironmentTypeName(EnvironmentType Kind) { | ||
50 | case GNUEABIHF: return "gnueabihf"; | ||
51 | case GNUEABI: return "gnueabi"; | ||
52 | case GNUX32: return "gnux32"; | ||
53 | + case MUSL: return "musl"; | ||
54 | + case MUSLEABIHF: return "musleabihf"; | ||
55 | + case MUSLEABI: return "musleabi"; | ||
56 | + case MUSLX32: return "muslx32"; | ||
57 | case CODE16: return "code16"; | ||
58 | case EABI: return "eabi"; | ||
59 | case EABIHF: return "eabihf"; | ||
60 | @@ -460,7 +464,11 @@ static Triple::EnvironmentType parseEnvironment(StringRef EnvironmentName) { | ||
61 | .StartsWith("eabi", Triple::EABI) | ||
62 | .StartsWith("gnueabihf", Triple::GNUEABIHF) | ||
63 | .StartsWith("gnueabi", Triple::GNUEABI) | ||
64 | - .StartsWith("gnux32", Triple::GNUX32) | ||
65 | + .StartsWith("musl", Triple::MUSL) | ||
66 | + .StartsWith("gnux32", Triple::MUSLX32) | ||
67 | + .StartsWith("musleabihf", Triple::MUSLEABIHF) | ||
68 | + .StartsWith("musleabi", Triple::MUSLEABI) | ||
69 | + .StartsWith("muslx32", Triple::GNUX32) | ||
70 | .StartsWith("code16", Triple::CODE16) | ||
71 | .StartsWith("gnu", Triple::GNU) | ||
72 | .StartsWith("android", Triple::Android) | ||
73 | diff --git a/lib/Target/ARM/ARMSubtarget.h b/lib/Target/ARM/ARMSubtarget.h | ||
74 | index ec1212d..902ce4a 100644 | ||
75 | --- a/lib/Target/ARM/ARMSubtarget.h | ||
76 | +++ b/lib/Target/ARM/ARMSubtarget.h | ||
77 | @@ -424,8 +424,10 @@ public: | ||
78 | bool isTargetEHABICompatible() const { | ||
79 | return (TargetTriple.getEnvironment() == Triple::EABI || | ||
80 | TargetTriple.getEnvironment() == Triple::GNUEABI || | ||
81 | + TargetTriple.getEnvironment() == Triple::MUSLEABI || | ||
82 | TargetTriple.getEnvironment() == Triple::EABIHF || | ||
83 | TargetTriple.getEnvironment() == Triple::GNUEABIHF || | ||
84 | + TargetTriple.getEnvironment() == Triple::MUSLEABIHF || | ||
85 | isTargetAndroid()) && | ||
86 | !isTargetDarwin() && !isTargetWindows(); | ||
87 | } | ||
88 | @@ -433,6 +435,7 @@ public: | ||
89 | bool isTargetHardFloat() const { | ||
90 | // FIXME: this is invalid for WindowsCE | ||
91 | return TargetTriple.getEnvironment() == Triple::GNUEABIHF || | ||
92 | + TargetTriple.getEnvironment() == Triple::MUSLEABIHF || | ||
93 | TargetTriple.getEnvironment() == Triple::EABIHF || | ||
94 | isTargetWindows() || isAAPCS16_ABI(); | ||
95 | } | ||
96 | diff --git a/lib/Target/ARM/ARMTargetMachine.cpp b/lib/Target/ARM/ARMTargetMachine.cpp | ||
97 | index 390b39c..9840c11 100644 | ||
98 | --- a/lib/Target/ARM/ARMTargetMachine.cpp | ||
99 | +++ b/lib/Target/ARM/ARMTargetMachine.cpp | ||
100 | @@ -99,6 +99,8 @@ computeTargetABI(const Triple &TT, StringRef CPU, | ||
101 | case llvm::Triple::Android: | ||
102 | case llvm::Triple::GNUEABI: | ||
103 | case llvm::Triple::GNUEABIHF: | ||
104 | + case llvm::Triple::MUSLEABI: | ||
105 | + case llvm::Triple::MUSLEABIHF: | ||
106 | case llvm::Triple::EABIHF: | ||
107 | case llvm::Triple::EABI: | ||
108 | TargetABI = ARMBaseTargetMachine::ARM_ABI_AAPCS; | ||
109 | -- | ||
110 | 2.7.4 | ||
111 | |||
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 | |||
17 | ${LLVM_GIT}/clang.git;protocol=${LLVM_GIT_PROTOCOL};branch=${BRANCH};destsuffix=git/tools/clang;name=clang \ | 17 | ${LLVM_GIT}/clang.git;protocol=${LLVM_GIT_PROTOCOL};branch=${BRANCH};destsuffix=git/tools/clang;name=clang \ |
18 | file://0001-Remove-CMAKE_CROSSCOMPILING-so-it-can-cross-compile.patch \ | 18 | file://0001-Remove-CMAKE_CROSSCOMPILING-so-it-can-cross-compile.patch \ |
19 | file://0002-Do-not-assume-linux-glibc.patch \ | 19 | file://0002-Do-not-assume-linux-glibc.patch \ |
20 | file://0001-triplet-Add-musl-support.patch \ | ||
21 | file://0001-driver-Add-musl-ldso-support.patch;patchdir=tools/clang \ | ||
20 | " | 22 | " |
21 | 23 | ||
22 | SRC_URI_append_libc-musl_class-target = " file://0001-remove-fopen64-fseeko64-ftello64-tmpfile64-on-musl.patch " | 24 | SRC_URI_append_libc-musl_class-target = " file://0001-remove-fopen64-fseeko64-ftello64-tmpfile64-on-musl.patch " |