summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools
diff options
context:
space:
mode:
authorKhem Raj <raj.khem@gmail.com>2015-11-18 17:10:48 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-12-12 23:42:54 +0000
commita2ea58bbd7a4cea9670b0a409df3a498ac2395fa (patch)
tree47f057f094c16556fc09e68632f3a5e30ee63268 /meta/recipes-devtools
parent37c74e24202a4e581c49c4b3e1e5facaa5f0c407 (diff)
downloadpoky-a2ea58bbd7a4cea9670b0a409df3a498ac2395fa.tar.gz
gcc: Add support for building musl configuration
Most of these patches are already in gcc 6.0/master but we still need them for older gcc, they have been tested in meta-musl for quite some time (From OE-Core rev: 30a0cc2ef72399b84da4903e697f258f79852fc9) Signed-off-by: Khem Raj <raj.khem@gmail.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools')
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.9.inc4
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.9/0067-gcc-musl-support.patch267
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.9/0068-musl-dynamic-linker.patch205
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.9/0069-musl-no-fixincludes.patch21
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.9/0070-libstdc-musl.patch32
-rw-r--r--meta/recipes-devtools/gcc/gcc-5.2.inc4
-rw-r--r--meta/recipes-devtools/gcc/gcc-5.2/0043-libstdc-musl.patch32
-rw-r--r--meta/recipes-devtools/gcc/gcc-5.2/0044-gcc-musl-support.patch267
-rw-r--r--meta/recipes-devtools/gcc/gcc-5.2/0045-musl-dynamic-linker.patch198
-rw-r--r--meta/recipes-devtools/gcc/gcc-5.2/0046-musl-no-fixincludes.patch22
10 files changed, 1052 insertions, 0 deletions
diff --git a/meta/recipes-devtools/gcc/gcc-4.9.inc b/meta/recipes-devtools/gcc/gcc-4.9.inc
index ee8e53befb..e9dfc504fd 100644
--- a/meta/recipes-devtools/gcc/gcc-4.9.inc
+++ b/meta/recipes-devtools/gcc/gcc-4.9.inc
@@ -83,6 +83,10 @@ SRC_URI = "\
83 file://0065-gcc-483-universal-initializer-no-warning.patch \ 83 file://0065-gcc-483-universal-initializer-no-warning.patch \
84 file://0066-cxxflags-for-build.patch \ 84 file://0066-cxxflags-for-build.patch \
85 file://0067-fix-arm-thumb.patch \ 85 file://0067-fix-arm-thumb.patch \
86 file://0067-gcc-musl-support.patch \
87 file://0068-musl-dynamic-linker.patch \
88 file://0069-musl-no-fixincludes.patch \
89 file://0070-libstdc-musl.patch \
86" 90"
87SRC_URI[md5sum] = "6f831b4d251872736e8e9cc09746f327" 91SRC_URI[md5sum] = "6f831b4d251872736e8e9cc09746f327"
88SRC_URI[sha256sum] = "2332b2a5a321b57508b9031354a8503af6fdfb868b8c1748d33028d100a8b67e" 92SRC_URI[sha256sum] = "2332b2a5a321b57508b9031354a8503af6fdfb868b8c1748d33028d100a8b67e"
diff --git a/meta/recipes-devtools/gcc/gcc-4.9/0067-gcc-musl-support.patch b/meta/recipes-devtools/gcc/gcc-4.9/0067-gcc-musl-support.patch
new file mode 100644
index 0000000000..9a0b5ade4c
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.9/0067-gcc-musl-support.patch
@@ -0,0 +1,267 @@
1# HG changeset patch
2# Parent e5b4564f249f8634194bdabef4b3057d0e54ee97
3Adding -mmusl as a musl libc specifier, and the necessary hacks for it to know how to find musl's dynamic linker.
4Upstream-Status: backport [partial]
5Signed-off-by: Khem Raj <raj.khem@gmail.com>
6
7
8Index: gcc-4.9.0/gcc/config.gcc
9===================================================================
10--- gcc-4.9.0.orig/gcc/config.gcc 2014-04-22 22:44:17.153567150 -0700
11+++ gcc-4.9.0/gcc/config.gcc 2014-04-23 23:54:31.427357051 -0700
12@@ -594,7 +594,7 @@
13 esac
14
15 # Common C libraries.
16-tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3"
17+tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3 LIBC_MUSL=4"
18
19 # 32-bit x86 processors supported by --with-arch=. Each processor
20 # MUST be separated by exactly one space.
21@@ -719,6 +719,9 @@
22 *-*-*uclibc*)
23 tm_defines="$tm_defines DEFAULT_LIBC=LIBC_UCLIBC"
24 ;;
25+ *-*-*musl*)
26+ tm_defines="$tm_defines DEFAULT_LIBC=LIBC_MUSL"
27+ ;;
28 *)
29 tm_defines="$tm_defines DEFAULT_LIBC=LIBC_GLIBC"
30 ;;
31@@ -2328,6 +2331,11 @@
32 powerpc*-*-linux*paired*)
33 tm_file="${tm_file} rs6000/750cl.h" ;;
34 esac
35+ case ${target} in
36+ *-linux*-musl*)
37+ enable_secureplt=yes ;;
38+ esac
39+
40 if test x${enable_secureplt} = xyes; then
41 tm_file="rs6000/secureplt.h ${tm_file}"
42 fi
43Index: gcc-4.9.0/gcc/config/linux.h
44===================================================================
45--- gcc-4.9.0.orig/gcc/config/linux.h 2014-01-02 14:23:26.000000000 -0800
46+++ gcc-4.9.0/gcc/config/linux.h 2014-04-24 00:11:29.034028895 -0700
47@@ -32,10 +32,12 @@
48 #define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC)
49 #define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
50 #define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
51+#define OPTION_MUSL (DEFAULT_LIBC == LIBC_MUSL)
52 #else
53 #define OPTION_GLIBC (linux_libc == LIBC_GLIBC)
54 #define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC)
55 #define OPTION_BIONIC (linux_libc == LIBC_BIONIC)
56+#define OPTION_MUSL (linux_libc == LIBC_MUSL)
57 #endif
58
59 #define GNU_USER_TARGET_OS_CPP_BUILTINS() \
60@@ -53,18 +55,21 @@
61 uClibc or Bionic is the default C library and whether
62 -muclibc or -mglibc or -mbionic has been passed to change the default. */
63
64-#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LD1, LD2, LD3) \
65- "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:" LD1 "}}"
66+#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LIBC4, LD1, LD2, LD3, LD4) \
67+ "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:%{" LIBC4 ":" LD4 ";:" LD1 "}}}"
68
69 #if DEFAULT_LIBC == LIBC_GLIBC
70-#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
71- CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", G, U, B)
72+#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
73+ CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", "mmusl", G, U, B, M)
74 #elif DEFAULT_LIBC == LIBC_UCLIBC
75-#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
76- CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", U, G, B)
77+#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
78+ CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", "mmusl", U, G, B, M)
79 #elif DEFAULT_LIBC == LIBC_BIONIC
80-#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
81- CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", B, G, U)
82+#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
83+ CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", "mmusl", B, G, U, M)
84+#elif DEFAULT_LIBC == LIBC_MUSL
85+#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
86+ CHOOSE_DYNAMIC_LINKER1 ("mmusl", "mglibc", "muclibc", "mbionic", M, G, U, B)
87 #else
88 #error "Unsupported DEFAULT_LIBC"
89 #endif /* DEFAULT_LIBC */
90@@ -84,16 +89,16 @@
91
92 #define GNU_USER_DYNAMIC_LINKER \
93 CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, \
94- BIONIC_DYNAMIC_LINKER)
95+ BIONIC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER)
96 #define GNU_USER_DYNAMIC_LINKER32 \
97 CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, \
98- BIONIC_DYNAMIC_LINKER32)
99+ BIONIC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32)
100 #define GNU_USER_DYNAMIC_LINKER64 \
101 CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, \
102- BIONIC_DYNAMIC_LINKER64)
103+ BIONIC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64)
104 #define GNU_USER_DYNAMIC_LINKERX32 \
105 CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERX32, UCLIBC_DYNAMIC_LINKERX32, \
106- BIONIC_DYNAMIC_LINKERX32)
107+ BIONIC_DYNAMIC_LINKERX32, MUSL_DYNAMIC_LINKERX32)
108
109 /* Whether we have Bionic libc runtime */
110 #undef TARGET_HAS_BIONIC
111@@ -127,3 +132,74 @@
112 # define TARGET_LIBC_HAS_FUNCTION linux_libc_has_function
113
114 #endif
115+
116+/* musl avoids problematic includes by rearranging the include directories.
117+ * Unfortunately, this is mostly duplicated from cppdefault.c */
118+#if DEFAULT_LIBC == LIBC_MUSL
119+#define INCLUDE_DEFAULTS_MUSL_GPP \
120+ { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, \
121+ GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 }, \
122+ { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1, \
123+ GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 1 }, \
124+ { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, \
125+ GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 },
126+
127+#ifdef LOCAL_INCLUDE_DIR
128+#define INCLUDE_DEFAULTS_MUSL_LOCAL \
129+ { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 2 }, \
130+ { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 0 },
131+#else
132+#define INCLUDE_DEFAULTS_MUSL_LOCAL
133+#endif
134+
135+#ifdef PREFIX_INCLUDE_DIR
136+#define INCLUDE_DEFAULTS_MUSL_PREFIX \
137+ { PREFIX_INCLUDE_DIR, 0, 0, 1, 0, 0},
138+#else
139+#define INCLUDE_DEFAULTS_MUSL_PREFIX
140+#endif
141+
142+#ifdef CROSS_INCLUDE_DIR
143+#define INCLUDE_DEFAULTS_MUSL_CROSS \
144+ { CROSS_INCLUDE_DIR, "GCC", 0, 0, 0, 0},
145+#else
146+#define INCLUDE_DEFAULTS_MUSL_CROSS
147+#endif
148+
149+#ifdef TOOL_INCLUDE_DIR
150+#define INCLUDE_DEFAULTS_MUSL_TOOL \
151+ { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1, 0, 0},
152+#else
153+#define INCLUDE_DEFAULTS_MUSL_TOOL
154+#endif
155+
156+#ifdef NATIVE_SYSTEM_HEADER_DIR
157+#define INCLUDE_DEFAULTS_MUSL_NATIVE \
158+ { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 2 }, \
159+ { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 0 },
160+#else
161+#define INCLUDE_DEFAULTS_MUSL_NATIVE
162+#endif
163+
164+#if defined (CROSS_DIRECTORY_STRUCTURE) && !defined (TARGET_SYSTEM_ROOT)
165+# undef INCLUDE_DEFAULTS_MUSL_LOCAL
166+# define INCLUDE_DEFAULTS_MUSL_LOCAL
167+# undef INCLUDE_DEFAULTS_MUSL_NATIVE
168+# define INCLUDE_DEFAULTS_MUSL_NATIVE
169+#else
170+# undef INCLUDE_DEFAULTS_MUSL_CROSS
171+# define INCLUDE_DEFAULTS_MUSL_CROSS
172+#endif
173+
174+#undef INCLUDE_DEFAULTS
175+#define INCLUDE_DEFAULTS \
176+ { \
177+ INCLUDE_DEFAULTS_MUSL_GPP \
178+ INCLUDE_DEFAULTS_MUSL_PREFIX \
179+ INCLUDE_DEFAULTS_MUSL_CROSS \
180+ INCLUDE_DEFAULTS_MUSL_TOOL \
181+ INCLUDE_DEFAULTS_MUSL_NATIVE \
182+ { GCC_INCLUDE_DIR, "GCC", 0, 1, 0, 0 }, \
183+ { 0, 0, 0, 0, 0, 0 } \
184+ }
185+#endif
186Index: gcc-4.9.0/gcc/config/linux.opt
187===================================================================
188--- gcc-4.9.0.orig/gcc/config/linux.opt 2014-01-02 14:23:26.000000000 -0800
189+++ gcc-4.9.0/gcc/config/linux.opt 2014-04-22 22:44:17.280233817 -0700
190@@ -30,3 +30,7 @@
191 muclibc
192 Target Report RejectNegative Var(linux_libc,LIBC_UCLIBC) Negative(mbionic)
193 Use uClibc C library
194+
195+mmusl
196+Target Report RejectNegative Var(linux_libc,LIBC_MUSL) Negative(mglibc)
197+Use musl C library
198Index: gcc-4.9.0/gcc/ginclude/stddef.h
199===================================================================
200--- gcc-4.9.0.orig/gcc/ginclude/stddef.h 2014-01-02 14:23:26.000000000 -0800
201+++ gcc-4.9.0/gcc/ginclude/stddef.h 2014-04-22 22:44:17.280233817 -0700
202@@ -181,6 +181,7 @@
203 #ifndef _GCC_SIZE_T
204 #ifndef _SIZET_
205 #ifndef __size_t
206+#ifndef __DEFINED_size_t /* musl */
207 #define __size_t__ /* BeOS */
208 #define __SIZE_T__ /* Cray Unicos/Mk */
209 #define _SIZE_T
210@@ -197,6 +198,7 @@
211 #define ___int_size_t_h
212 #define _GCC_SIZE_T
213 #define _SIZET_
214+#define __DEFINED_size_t /* musl */
215 #if (defined (__FreeBSD__) && (__FreeBSD__ >= 5)) \
216 || defined(__FreeBSD_kernel__)
217 /* __size_t is a typedef on FreeBSD 5, must not trash it. */
218@@ -214,6 +216,7 @@
219 typedef long ssize_t;
220 #endif /* __BEOS__ */
221 #endif /* !(defined (__GNUG__) && defined (size_t)) */
222+#endif /* __DEFINED_size_t */
223 #endif /* __size_t */
224 #endif /* _SIZET_ */
225 #endif /* _GCC_SIZE_T */
226Index: gcc-4.9.0/gcc/config/rs6000/secureplt.h
227===================================================================
228--- gcc-4.9.0.orig/gcc/config/rs6000/secureplt.h 2014-01-02 14:23:26.000000000 -0800
229+++ gcc-4.9.0/gcc/config/rs6000/secureplt.h 2014-04-23 23:55:15.114024175 -0700
230@@ -18,3 +18,4 @@
231 <http://www.gnu.org/licenses/>. */
232
233 #define CC1_SECURE_PLT_DEFAULT_SPEC "-msecure-plt"
234+#define LINK_SECURE_PLT_DEFAULT_SPEC "--secure-plt"
235Index: gcc-4.9.0/gcc/config/rs6000/sysv4.h
236===================================================================
237--- gcc-4.9.0.orig/gcc/config/rs6000/sysv4.h 2014-04-23 23:52:13.854023015 -0700
238+++ gcc-4.9.0/gcc/config/rs6000/sysv4.h 2014-04-24 00:10:55.550695334 -0700
239@@ -538,6 +538,10 @@
240 #define CC1_SECURE_PLT_DEFAULT_SPEC ""
241 #endif
242
243+#ifndef LINK_SECURE_PLT_DEFAULT_SPEC
244+#define LINK_SECURE_PLT_DEFAULT_SPEC ""
245+#endif
246+
247 /* Pass -G xxx to the compiler. */
248 #define CC1_SPEC "%{G*} %(cc1_cpu)" \
249 "%{meabi: %{!mcall-*: -mcall-sysv }} \
250@@ -585,7 +589,8 @@
251
252 /* Override the default target of the linker. */
253 #define LINK_TARGET_SPEC \
254- ENDIAN_SELECT("", " --oformat elf32-powerpcle", "")
255+ ENDIAN_SELECT("", " --oformat elf32-powerpcle", "") \
256+ "%{!mbss-plt: %{!msecure-plt: %(link_secure_plt_default)}}"
257
258 /* Any specific OS flags. */
259 #define LINK_OS_SPEC "\
260@@ -894,6 +899,7 @@
261 { "link_os_openbsd", LINK_OS_OPENBSD_SPEC }, \
262 { "link_os_default", LINK_OS_DEFAULT_SPEC }, \
263 { "cc1_secure_plt_default", CC1_SECURE_PLT_DEFAULT_SPEC }, \
264+ { "link_secure_plt_default", LINK_SECURE_PLT_DEFAULT_SPEC }, \
265 { "cpp_os_ads", CPP_OS_ADS_SPEC }, \
266 { "cpp_os_yellowknife", CPP_OS_YELLOWKNIFE_SPEC }, \
267 { "cpp_os_mvme", CPP_OS_MVME_SPEC }, \
diff --git a/meta/recipes-devtools/gcc/gcc-4.9/0068-musl-dynamic-linker.patch b/meta/recipes-devtools/gcc/gcc-4.9/0068-musl-dynamic-linker.patch
new file mode 100644
index 0000000000..605ac66758
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.9/0068-musl-dynamic-linker.patch
@@ -0,0 +1,205 @@
1# HG changeset patch
2# Parent 6738fd6f6fcc2a72f2ba527bda3325642af26885
3Support for arm-linux-musl.
4Upstream-Status: Backport [partial]
5Signed-off-by: Khem Raj <raj.khem@gmail.com>
6
7
8Index: gcc-4.9.2/gcc/config/arm/linux-eabi.h
9===================================================================
10--- gcc-4.9.2.orig/gcc/config/arm/linux-eabi.h
11+++ gcc-4.9.2/gcc/config/arm/linux-eabi.h
12@@ -81,6 +81,23 @@
13 #undef TARGET_FIX_V4BX_SPEC
14 #define TARGET_FIX_V4BX_SPEC "%{mcpu=arm8|mcpu=arm810|mcpu=strongarm*|march=armv4: --fix-v4bx}"
15
16+/* For ARM musl currently supports four dynamic linkers:
17+ - ld-musl-arm.so.1 - for the EABI-derived soft-float ABI
18+ - ld-musl-armhf.so.1 - for the EABI-derived hard-float ABI
19+ - ld-musl-armeb.so.1 - for the EABI-derived soft-float ABI, EB
20+ - ld-musl-armebhf.so.1 - for the EABI-derived hard-float ABI, EB
21+ musl does not support the legacy OABI mode.
22+ All the dynamic linkers live in /lib.
23+ We default to soft-float, EL. */
24+#undef MUSL_DYNAMIC_LINKER
25+#if TARGET_BIG_ENDIAN_DEFAULT
26+#define MUSL_DYNAMIC_LINKER_E "%{mlittle-endian:;:eb}"
27+#else
28+#define MUSL_DYNAMIC_LINKER_E "%{mbig-endian:eb}"
29+#endif
30+#define MUSL_DYNAMIC_LINKER \
31+ SYSTEMLIBS_DIR "ld-musl-arm" MUSL_DYNAMIC_LINKER_E "%{mfloat-abi=hard:hf}.so.1"
32+
33 /* At this point, bpabi.h will have clobbered LINK_SPEC. We want to
34 use the GNU/Linux version, not the generic BPABI version. */
35 #undef LINK_SPEC
36Index: gcc-4.9.2/libitm/config/arm/hwcap.cc
37===================================================================
38--- gcc-4.9.2.orig/libitm/config/arm/hwcap.cc
39+++ gcc-4.9.2/libitm/config/arm/hwcap.cc
40@@ -40,7 +40,11 @@ int GTM_hwcap HIDDEN = 0
41
42 #ifdef __linux__
43 #include <unistd.h>
44+#ifdef __GLIBC__
45 #include <sys/fcntl.h>
46+#else
47+#include <fcntl.h>
48+#endif
49 #include <elf.h>
50
51 static void __attribute__((constructor))
52Index: gcc-4.9.2/gcc/config/i386/linux.h
53===================================================================
54--- gcc-4.9.2.orig/gcc/config/i386/linux.h
55+++ gcc-4.9.2/gcc/config/i386/linux.h
56@@ -21,3 +21,4 @@ along with GCC; see the file COPYING3.
57
58 #define GNU_USER_LINK_EMULATION "elf_i386"
59 #define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-linux.so.2"
60+#define MUSL_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-musl-i386.so.1"
61Index: gcc-4.9.2/gcc/config/i386/linux64.h
62===================================================================
63--- gcc-4.9.2.orig/gcc/config/i386/linux64.h
64+++ gcc-4.9.2/gcc/config/i386/linux64.h
65@@ -30,3 +30,8 @@ see the files COPYING3 and COPYING.RUNTI
66 #define GLIBC_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld-linux.so.2"
67 #define GLIBC_DYNAMIC_LINKER64 SYSTEMLIBS_DIR "ld-linux-x86-64.so.2"
68 #define GLIBC_DYNAMIC_LINKERX32 SYSTEMLIBS_DIR "ld-linux-x32.so.2"
69+
70+#define MUSL_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld-musl-i386.so.1"
71+#define MUSL_DYNAMIC_LINKER64 SYSTEMLIBS_DIR "ld-musl-x86_64.so.1"
72+#define MUSL_DYNAMIC_LINKERX32 SYSTEMLIBS_DIR "ld-musl-x32.so.1"
73+
74Index: gcc-4.9.2/gcc/config/mips/linux.h
75===================================================================
76--- gcc-4.9.2.orig/gcc/config/mips/linux.h
77+++ gcc-4.9.2/gcc/config/mips/linux.h
78@@ -23,3 +23,6 @@ along with GCC; see the file COPYING3.
79 #undef UCLIBC_DYNAMIC_LINKER
80 #define UCLIBC_DYNAMIC_LINKER \
81 "%{mnan=2008:" SYSTEMLIBS_DIR "ld-uClibc-mipsn8.so.0;:" SYSTEMLIBS_DIR "ld-uClibc.so.0}"
82+
83+#define MUSL_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-musl-mips.so.1"
84+
85Index: gcc-4.9.2/gcc/config/mips/linux64.h
86===================================================================
87--- gcc-4.9.2.orig/gcc/config/mips/linux64.h
88+++ gcc-4.9.2/gcc/config/mips/linux64.h
89@@ -39,6 +39,11 @@ along with GCC; see the file COPYING3.
90 "%{mnan=2008:" SYSTEMLIBS_DIR "ld-uClibc-mipsn8.so.0;:" SYSTEMLIBS_DIR "ld-uClibc.so.0}"
91
92 #define BIONIC_DYNAMIC_LINKERN32 "/system/bin/linker32"
93+
94+#define MUSL_DYNAMIC_LINKERN32 SYSTEMLIBS_DIR "ld-musl-mips.so.1"
95+#define MUSL_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld-musl-mips.so.1"
96+#define MUSL_DYNAMIC_LINKER64 SYSTEMLIBS_DIR "ld-musl-mips.so.1"
97+
98 #define GNU_USER_DYNAMIC_LINKERN32 \
99 CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERN32, UCLIBC_DYNAMIC_LINKERN32, \
100- BIONIC_DYNAMIC_LINKERN32)
101+ BIONIC_DYNAMIC_LINKERN32, MUSL_DYNAMIC_LINKERN32)
102Index: gcc-4.9.2/gcc/config/rs6000/linux64.h
103===================================================================
104--- gcc-4.9.2.orig/gcc/config/rs6000/linux64.h
105+++ gcc-4.9.2/gcc/config/rs6000/linux64.h
106@@ -375,17 +375,22 @@ extern int dot_symbols;
107 #endif
108 #define UCLIBC_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld-uClibc.so.0"
109 #define UCLIBC_DYNAMIC_LINKER64 SYSTEMLIBS_DIR "ld64-uClibc.so.0"
110+#define MUSL_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld-musl-powerpc.so.1"
111+#define MUSL_DYNAMIC_LINKER64 SYSTEMLIBS_DIR "ld-musl-powerpc64.so.1"
112+
113 #if DEFAULT_LIBC == LIBC_UCLIBC
114-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
115+#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}"
116 #elif DEFAULT_LIBC == LIBC_GLIBC
117-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}"
118+#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{muclibc:" U ";:%{mmusl:" M ";:" G "}}"
119+#elif DEFAULT_LIBC == LIBC_MUSL
120+#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{muclibc:" U ";:" M "}}"
121 #else
122 #error "Unsupported DEFAULT_LIBC"
123 #endif
124 #define GNU_USER_DYNAMIC_LINKER32 \
125- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32)
126+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32)
127 #define GNU_USER_DYNAMIC_LINKER64 \
128- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64)
129+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64)
130
131 #undef DEFAULT_ASM_ENDIAN
132 #if (TARGET_DEFAULT & MASK_LITTLE_ENDIAN)
133Index: gcc-4.9.2/gcc/config/rs6000/sysv4.h
134===================================================================
135--- gcc-4.9.2.orig/gcc/config/rs6000/sysv4.h
136+++ gcc-4.9.2/gcc/config/rs6000/sysv4.h
137@@ -768,15 +768,19 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEF
138
139 #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
140 #define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
141+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-powerpc.so.1"
142+
143 #if DEFAULT_LIBC == LIBC_UCLIBC
144-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
145+#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}"
146+#elif DEFAULT_LIBC == LIBC_MUSL
147+#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{muclibc:" U ";:" M "}}"
148 #elif !defined (DEFAULT_LIBC) || DEFAULT_LIBC == LIBC_GLIBC
149-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}"
150+#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{muclibc:" U ";:%{mmusl:" M ";:" G "}}"
151 #else
152 #error "Unsupported DEFAULT_LIBC"
153 #endif
154 #define GNU_USER_DYNAMIC_LINKER \
155- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER)
156+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER)
157
158 #define LINK_OS_LINUX_SPEC "-m elf32ppclinux %{!shared: %{!static: \
159 %{rdynamic:-export-dynamic} \
160Index: gcc-4.9.2/libitm/config/linux/x86/tls.h
161===================================================================
162--- gcc-4.9.2.orig/libitm/config/linux/x86/tls.h
163+++ gcc-4.9.2/libitm/config/linux/x86/tls.h
164@@ -25,16 +25,19 @@
165 #ifndef LIBITM_X86_TLS_H
166 #define LIBITM_X86_TLS_H 1
167
168-#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 10)
169+#if defined(__GLIBC_PREREQ)
170+#if __GLIBC_PREREQ(2, 10)
171 /* Use slots in the TCB head rather than __thread lookups.
172 GLIBC has reserved words 10 through 13 for TM. */
173 #define HAVE_ARCH_GTM_THREAD 1
174 #define HAVE_ARCH_GTM_THREAD_DISP 1
175 #endif
176+#endif
177
178 #include "config/generic/tls.h"
179
180-#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 10)
181+#if defined(__GLIBC_PREREQ)
182+#if __GLIBC_PREREQ(2, 10)
183 namespace GTM HIDDEN {
184
185 #ifdef __x86_64__
186@@ -101,5 +104,6 @@ static inline void set_abi_disp(struct a
187
188 } // namespace GTM
189 #endif /* >= GLIBC 2.10 */
190+#endif
191
192 #endif // LIBITM_X86_TLS_H
193Index: gcc-4.9.2/gcc/config/aarch64/aarch64-linux.h
194===================================================================
195--- gcc-4.9.2.orig/gcc/config/aarch64/aarch64-linux.h
196+++ gcc-4.9.2/gcc/config/aarch64/aarch64-linux.h
197@@ -25,6 +25,8 @@
198
199 #define CPP_SPEC "%{pthread:-D_REENTRANT}"
200
201+#define MUSL_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-musl-aarch64.so.1"
202+
203 #define LINUX_TARGET_LINK_SPEC "%{h*} \
204 %{static:-Bstatic} \
205 %{shared:-shared} \
diff --git a/meta/recipes-devtools/gcc/gcc-4.9/0069-musl-no-fixincludes.patch b/meta/recipes-devtools/gcc/gcc-4.9/0069-musl-no-fixincludes.patch
new file mode 100644
index 0000000000..e2b18a4022
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.9/0069-musl-no-fixincludes.patch
@@ -0,0 +1,21 @@
1# HG changeset patch
2# Parent 600a8a422ccaf5627ad1f5a138e7398df2b9e9d8
3Get rid of ever-broken fixincludes on musl.
4Upstream-Status: Pending
5Signed-off-by: Khem Raj <raj.khem@gmail.com>
6
7
8Index: gcc-4.9-20140316/fixincludes/mkfixinc.sh
9===================================================================
10--- gcc-4.9-20140316.orig/fixincludes/mkfixinc.sh
11+++ gcc-4.9-20140316/fixincludes/mkfixinc.sh
12@@ -19,7 +19,8 @@ case $machine in
13 powerpc-*-eabi* | \
14 powerpc-*-rtems* | \
15 powerpcle-*-eabisim* | \
16- powerpcle-*-eabi* )
17+ powerpcle-*-eabi* | \
18+ *-musl* )
19 # IF there is no include fixing,
20 # THEN create a no-op fixer and exit
21 (echo "#! /bin/sh" ; echo "exit 0" ) > ${target}
diff --git a/meta/recipes-devtools/gcc/gcc-4.9/0070-libstdc-musl.patch b/meta/recipes-devtools/gcc/gcc-4.9/0070-libstdc-musl.patch
new file mode 100644
index 0000000000..048e481dce
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.9/0070-libstdc-musl.patch
@@ -0,0 +1,32 @@
1Upstream-Status: Pending
2Signed-off-by: Khem Raj <raj.khem@gmail.com>
3
4Index: gcc-4.9-20140316/libstdc++-v3/configure.host
5===================================================================
6--- gcc-4.9-20140316.orig/libstdc++-v3/configure.host 2014-03-26 01:12:19.466008193 -0700
7+++ gcc-4.9-20140316/libstdc++-v3/configure.host 2014-03-26 01:43:48.222684357 -0700
8@@ -264,14 +264,24 @@
9 os_include_dir="os/bsd/freebsd"
10 ;;
11 gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu)
12+ # check for musl by target
13+ case "${host_os}" in
14+ *-musl*)
15+ os_include_dir="os/generic"
16+ ;;
17+ *)
18 if [ "$uclibc" = "yes" ]; then
19 os_include_dir="os/uclibc"
20 elif [ "$bionic" = "yes" ]; then
21 os_include_dir="os/bionic"
22+ elif [ "$musl" = "yes" ]; then
23+ os_include_dir="os/generic"
24 else
25 os_include_dir="os/gnu-linux"
26 fi
27 ;;
28+ esac
29+ ;;
30 hpux*)
31 os_include_dir="os/hpux"
32 ;;
diff --git a/meta/recipes-devtools/gcc/gcc-5.2.inc b/meta/recipes-devtools/gcc/gcc-5.2.inc
index e5e92e9ab2..2ebc675d9d 100644
--- a/meta/recipes-devtools/gcc/gcc-5.2.inc
+++ b/meta/recipes-devtools/gcc/gcc-5.2.inc
@@ -75,6 +75,10 @@ SRC_URI = "\
75 file://0041-handle-target-sysroot-multilib.patch \ 75 file://0041-handle-target-sysroot-multilib.patch \
76 file://0042-cxxflags-for-build.patch \ 76 file://0042-cxxflags-for-build.patch \
77 file://0043-fix-arm-thumb.patch \ 77 file://0043-fix-arm-thumb.patch \
78 file://0043-libstdc-musl.patch \
79 file://0044-gcc-musl-support.patch \
80 file://0045-musl-dynamic-linker.patch \
81 file://0046-musl-no-fixincludes.patch \
78 " 82 "
79 83
80BACKPORTS = "" 84BACKPORTS = ""
diff --git a/meta/recipes-devtools/gcc/gcc-5.2/0043-libstdc-musl.patch b/meta/recipes-devtools/gcc/gcc-5.2/0043-libstdc-musl.patch
new file mode 100644
index 0000000000..048e481dce
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-5.2/0043-libstdc-musl.patch
@@ -0,0 +1,32 @@
1Upstream-Status: Pending
2Signed-off-by: Khem Raj <raj.khem@gmail.com>
3
4Index: gcc-4.9-20140316/libstdc++-v3/configure.host
5===================================================================
6--- gcc-4.9-20140316.orig/libstdc++-v3/configure.host 2014-03-26 01:12:19.466008193 -0700
7+++ gcc-4.9-20140316/libstdc++-v3/configure.host 2014-03-26 01:43:48.222684357 -0700
8@@ -264,14 +264,24 @@
9 os_include_dir="os/bsd/freebsd"
10 ;;
11 gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu)
12+ # check for musl by target
13+ case "${host_os}" in
14+ *-musl*)
15+ os_include_dir="os/generic"
16+ ;;
17+ *)
18 if [ "$uclibc" = "yes" ]; then
19 os_include_dir="os/uclibc"
20 elif [ "$bionic" = "yes" ]; then
21 os_include_dir="os/bionic"
22+ elif [ "$musl" = "yes" ]; then
23+ os_include_dir="os/generic"
24 else
25 os_include_dir="os/gnu-linux"
26 fi
27 ;;
28+ esac
29+ ;;
30 hpux*)
31 os_include_dir="os/hpux"
32 ;;
diff --git a/meta/recipes-devtools/gcc/gcc-5.2/0044-gcc-musl-support.patch b/meta/recipes-devtools/gcc/gcc-5.2/0044-gcc-musl-support.patch
new file mode 100644
index 0000000000..4d1ab872ae
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-5.2/0044-gcc-musl-support.patch
@@ -0,0 +1,267 @@
1# HG changeset patch
2# Parent e5b4564f249f8634194bdabef4b3057d0e54ee97
3Adding -mmusl as a musl libc specifier, and the necessary hacks for it to know how to find musl's dynamic linker.
4
5Upstream-Status: Backport [partial]
6Signed-off-by: Khem Raj <raj.khem@gmail.com>
7
8Index: gcc-4.9.0/gcc/config.gcc
9===================================================================
10--- gcc-4.9.0.orig/gcc/config.gcc 2014-04-22 22:44:17.153567150 -0700
11+++ gcc-4.9.0/gcc/config.gcc 2014-04-23 23:54:31.427357051 -0700
12@@ -594,7 +594,7 @@
13 esac
14
15 # Common C libraries.
16-tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3"
17+tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3 LIBC_MUSL=4"
18
19 # 32-bit x86 processors supported by --with-arch=. Each processor
20 # MUST be separated by exactly one space.
21@@ -719,6 +719,9 @@
22 *-*-*uclibc*)
23 tm_defines="$tm_defines DEFAULT_LIBC=LIBC_UCLIBC"
24 ;;
25+ *-*-*musl*)
26+ tm_defines="$tm_defines DEFAULT_LIBC=LIBC_MUSL"
27+ ;;
28 *)
29 tm_defines="$tm_defines DEFAULT_LIBC=LIBC_GLIBC"
30 ;;
31@@ -2328,6 +2331,11 @@
32 powerpc*-*-linux*paired*)
33 tm_file="${tm_file} rs6000/750cl.h" ;;
34 esac
35+ case ${target} in
36+ *-linux*-musl*)
37+ enable_secureplt=yes ;;
38+ esac
39+
40 if test x${enable_secureplt} = xyes; then
41 tm_file="rs6000/secureplt.h ${tm_file}"
42 fi
43Index: gcc-4.9.0/gcc/config/linux.h
44===================================================================
45--- gcc-4.9.0.orig/gcc/config/linux.h 2014-01-02 14:23:26.000000000 -0800
46+++ gcc-4.9.0/gcc/config/linux.h 2014-04-24 00:11:29.034028895 -0700
47@@ -32,10 +32,12 @@
48 #define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC)
49 #define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
50 #define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
51+#define OPTION_MUSL (DEFAULT_LIBC == LIBC_MUSL)
52 #else
53 #define OPTION_GLIBC (linux_libc == LIBC_GLIBC)
54 #define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC)
55 #define OPTION_BIONIC (linux_libc == LIBC_BIONIC)
56+#define OPTION_MUSL (linux_libc == LIBC_MUSL)
57 #endif
58
59 #define GNU_USER_TARGET_OS_CPP_BUILTINS() \
60@@ -53,18 +55,21 @@
61 uClibc or Bionic is the default C library and whether
62 -muclibc or -mglibc or -mbionic has been passed to change the default. */
63
64-#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LD1, LD2, LD3) \
65- "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:" LD1 "}}"
66+#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LIBC4, LD1, LD2, LD3, LD4) \
67+ "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:%{" LIBC4 ":" LD4 ";:" LD1 "}}}"
68
69 #if DEFAULT_LIBC == LIBC_GLIBC
70-#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
71- CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", G, U, B)
72+#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
73+ CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", "mmusl", G, U, B, M)
74 #elif DEFAULT_LIBC == LIBC_UCLIBC
75-#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
76- CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", U, G, B)
77+#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
78+ CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", "mmusl", U, G, B, M)
79 #elif DEFAULT_LIBC == LIBC_BIONIC
80-#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
81- CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", B, G, U)
82+#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
83+ CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", "mmusl", B, G, U, M)
84+#elif DEFAULT_LIBC == LIBC_MUSL
85+#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
86+ CHOOSE_DYNAMIC_LINKER1 ("mmusl", "mglibc", "muclibc", "mbionic", M, G, U, B)
87 #else
88 #error "Unsupported DEFAULT_LIBC"
89 #endif /* DEFAULT_LIBC */
90@@ -84,16 +89,16 @@
91
92 #define GNU_USER_DYNAMIC_LINKER \
93 CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, \
94- BIONIC_DYNAMIC_LINKER)
95+ BIONIC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER)
96 #define GNU_USER_DYNAMIC_LINKER32 \
97 CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, \
98- BIONIC_DYNAMIC_LINKER32)
99+ BIONIC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32)
100 #define GNU_USER_DYNAMIC_LINKER64 \
101 CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, \
102- BIONIC_DYNAMIC_LINKER64)
103+ BIONIC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64)
104 #define GNU_USER_DYNAMIC_LINKERX32 \
105 CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERX32, UCLIBC_DYNAMIC_LINKERX32, \
106- BIONIC_DYNAMIC_LINKERX32)
107+ BIONIC_DYNAMIC_LINKERX32, MUSL_DYNAMIC_LINKERX32)
108
109 /* Whether we have Bionic libc runtime */
110 #undef TARGET_HAS_BIONIC
111@@ -127,3 +132,74 @@
112 # define TARGET_LIBC_HAS_FUNCTION linux_libc_has_function
113
114 #endif
115+
116+/* musl avoids problematic includes by rearranging the include directories.
117+ * Unfortunately, this is mostly duplicated from cppdefault.c */
118+#if DEFAULT_LIBC == LIBC_MUSL
119+#define INCLUDE_DEFAULTS_MUSL_GPP \
120+ { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, \
121+ GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 }, \
122+ { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1, \
123+ GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 1 }, \
124+ { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, \
125+ GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 },
126+
127+#ifdef LOCAL_INCLUDE_DIR
128+#define INCLUDE_DEFAULTS_MUSL_LOCAL \
129+ { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 2 }, \
130+ { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 0 },
131+#else
132+#define INCLUDE_DEFAULTS_MUSL_LOCAL
133+#endif
134+
135+#ifdef PREFIX_INCLUDE_DIR
136+#define INCLUDE_DEFAULTS_MUSL_PREFIX \
137+ { PREFIX_INCLUDE_DIR, 0, 0, 1, 0, 0},
138+#else
139+#define INCLUDE_DEFAULTS_MUSL_PREFIX
140+#endif
141+
142+#ifdef CROSS_INCLUDE_DIR
143+#define INCLUDE_DEFAULTS_MUSL_CROSS \
144+ { CROSS_INCLUDE_DIR, "GCC", 0, 0, 0, 0},
145+#else
146+#define INCLUDE_DEFAULTS_MUSL_CROSS
147+#endif
148+
149+#ifdef TOOL_INCLUDE_DIR
150+#define INCLUDE_DEFAULTS_MUSL_TOOL \
151+ { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1, 0, 0},
152+#else
153+#define INCLUDE_DEFAULTS_MUSL_TOOL
154+#endif
155+
156+#ifdef NATIVE_SYSTEM_HEADER_DIR
157+#define INCLUDE_DEFAULTS_MUSL_NATIVE \
158+ { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 2 }, \
159+ { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 0 },
160+#else
161+#define INCLUDE_DEFAULTS_MUSL_NATIVE
162+#endif
163+
164+#if defined (CROSS_DIRECTORY_STRUCTURE) && !defined (TARGET_SYSTEM_ROOT)
165+# undef INCLUDE_DEFAULTS_MUSL_LOCAL
166+# define INCLUDE_DEFAULTS_MUSL_LOCAL
167+# undef INCLUDE_DEFAULTS_MUSL_NATIVE
168+# define INCLUDE_DEFAULTS_MUSL_NATIVE
169+#else
170+# undef INCLUDE_DEFAULTS_MUSL_CROSS
171+# define INCLUDE_DEFAULTS_MUSL_CROSS
172+#endif
173+
174+#undef INCLUDE_DEFAULTS
175+#define INCLUDE_DEFAULTS \
176+ { \
177+ INCLUDE_DEFAULTS_MUSL_GPP \
178+ INCLUDE_DEFAULTS_MUSL_PREFIX \
179+ INCLUDE_DEFAULTS_MUSL_CROSS \
180+ INCLUDE_DEFAULTS_MUSL_TOOL \
181+ INCLUDE_DEFAULTS_MUSL_NATIVE \
182+ { GCC_INCLUDE_DIR, "GCC", 0, 1, 0, 0 }, \
183+ { 0, 0, 0, 0, 0, 0 } \
184+ }
185+#endif
186Index: gcc-4.9.0/gcc/config/linux.opt
187===================================================================
188--- gcc-4.9.0.orig/gcc/config/linux.opt 2014-01-02 14:23:26.000000000 -0800
189+++ gcc-4.9.0/gcc/config/linux.opt 2014-04-22 22:44:17.280233817 -0700
190@@ -30,3 +30,7 @@
191 muclibc
192 Target Report RejectNegative Var(linux_libc,LIBC_UCLIBC) Negative(mbionic)
193 Use uClibc C library
194+
195+mmusl
196+Target Report RejectNegative Var(linux_libc,LIBC_MUSL) Negative(mglibc)
197+Use musl C library
198Index: gcc-4.9.0/gcc/ginclude/stddef.h
199===================================================================
200--- gcc-4.9.0.orig/gcc/ginclude/stddef.h 2014-01-02 14:23:26.000000000 -0800
201+++ gcc-4.9.0/gcc/ginclude/stddef.h 2014-04-22 22:44:17.280233817 -0700
202@@ -181,6 +181,7 @@
203 #ifndef _GCC_SIZE_T
204 #ifndef _SIZET_
205 #ifndef __size_t
206+#ifndef __DEFINED_size_t /* musl */
207 #define __size_t__ /* BeOS */
208 #define __SIZE_T__ /* Cray Unicos/Mk */
209 #define _SIZE_T
210@@ -197,6 +198,7 @@
211 #define ___int_size_t_h
212 #define _GCC_SIZE_T
213 #define _SIZET_
214+#define __DEFINED_size_t /* musl */
215 #if (defined (__FreeBSD__) && (__FreeBSD__ >= 5)) \
216 || defined(__FreeBSD_kernel__)
217 /* __size_t is a typedef on FreeBSD 5, must not trash it. */
218@@ -214,6 +216,7 @@
219 typedef long ssize_t;
220 #endif /* __BEOS__ */
221 #endif /* !(defined (__GNUG__) && defined (size_t)) */
222+#endif /* __DEFINED_size_t */
223 #endif /* __size_t */
224 #endif /* _SIZET_ */
225 #endif /* _GCC_SIZE_T */
226Index: gcc-4.9.0/gcc/config/rs6000/secureplt.h
227===================================================================
228--- gcc-4.9.0.orig/gcc/config/rs6000/secureplt.h 2014-01-02 14:23:26.000000000 -0800
229+++ gcc-4.9.0/gcc/config/rs6000/secureplt.h 2014-04-23 23:55:15.114024175 -0700
230@@ -18,3 +18,4 @@
231 <http://www.gnu.org/licenses/>. */
232
233 #define CC1_SECURE_PLT_DEFAULT_SPEC "-msecure-plt"
234+#define LINK_SECURE_PLT_DEFAULT_SPEC "--secure-plt"
235Index: gcc-4.9.0/gcc/config/rs6000/sysv4.h
236===================================================================
237--- gcc-4.9.0.orig/gcc/config/rs6000/sysv4.h 2014-04-23 23:52:13.854023015 -0700
238+++ gcc-4.9.0/gcc/config/rs6000/sysv4.h 2014-04-24 00:10:55.550695334 -0700
239@@ -538,6 +538,10 @@
240 #define CC1_SECURE_PLT_DEFAULT_SPEC ""
241 #endif
242
243+#ifndef LINK_SECURE_PLT_DEFAULT_SPEC
244+#define LINK_SECURE_PLT_DEFAULT_SPEC ""
245+#endif
246+
247 /* Pass -G xxx to the compiler. */
248 #define CC1_SPEC "%{G*} %(cc1_cpu)" \
249 "%{meabi: %{!mcall-*: -mcall-sysv }} \
250@@ -585,7 +589,8 @@
251
252 /* Override the default target of the linker. */
253 #define LINK_TARGET_SPEC \
254- ENDIAN_SELECT("", " --oformat elf32-powerpcle", "")
255+ ENDIAN_SELECT("", " --oformat elf32-powerpcle", "") \
256+ "%{!mbss-plt: %{!msecure-plt: %(link_secure_plt_default)}}"
257
258 /* Any specific OS flags. */
259 #define LINK_OS_SPEC "\
260@@ -894,6 +899,7 @@
261 { "link_os_openbsd", LINK_OS_OPENBSD_SPEC }, \
262 { "link_os_default", LINK_OS_DEFAULT_SPEC }, \
263 { "cc1_secure_plt_default", CC1_SECURE_PLT_DEFAULT_SPEC }, \
264+ { "link_secure_plt_default", LINK_SECURE_PLT_DEFAULT_SPEC }, \
265 { "cpp_os_ads", CPP_OS_ADS_SPEC }, \
266 { "cpp_os_yellowknife", CPP_OS_YELLOWKNIFE_SPEC }, \
267 { "cpp_os_mvme", CPP_OS_MVME_SPEC }, \
diff --git a/meta/recipes-devtools/gcc/gcc-5.2/0045-musl-dynamic-linker.patch b/meta/recipes-devtools/gcc/gcc-5.2/0045-musl-dynamic-linker.patch
new file mode 100644
index 0000000000..3dadb9504f
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-5.2/0045-musl-dynamic-linker.patch
@@ -0,0 +1,198 @@
1# HG changeset patch
2# Parent 6738fd6f6fcc2a72f2ba527bda3325642af26885
3Support for arm-linux-musl.
4
5Upstream-Status: backport [partial]
6Signed-off-by: Khem Raj <raj.khem@gmail.com>
7
8
9Index: gcc-5.1.0/gcc/config/arm/linux-eabi.h
10===================================================================
11--- gcc-5.1.0.orig/gcc/config/arm/linux-eabi.h
12+++ gcc-5.1.0/gcc/config/arm/linux-eabi.h
13@@ -81,6 +81,23 @@
14 #undef TARGET_FIX_V4BX_SPEC
15 #define TARGET_FIX_V4BX_SPEC "%{mcpu=arm8|mcpu=arm810|mcpu=strongarm*|march=armv4: --fix-v4bx}"
16
17+/* For ARM musl currently supports four dynamic linkers:
18+ - ld-musl-arm.so.1 - for the EABI-derived soft-float ABI
19+ - ld-musl-armhf.so.1 - for the EABI-derived hard-float ABI
20+ - ld-musl-armeb.so.1 - for the EABI-derived soft-float ABI, EB
21+ - ld-musl-armebhf.so.1 - for the EABI-derived hard-float ABI, EB
22+ musl does not support the legacy OABI mode.
23+ All the dynamic linkers live in /lib.
24+ We default to soft-float, EL. */
25+#undef MUSL_DYNAMIC_LINKER
26+#if TARGET_BIG_ENDIAN_DEFAULT
27+#define MUSL_DYNAMIC_LINKER_E "%{mlittle-endian:;:eb}"
28+#else
29+#define MUSL_DYNAMIC_LINKER_E "%{mbig-endian:eb}"
30+#endif
31+#define MUSL_DYNAMIC_LINKER \
32+ SYSTEMLIBS_DIR "ld-musl-arm" MUSL_DYNAMIC_LINKER_E "%{mfloat-abi=hard:hf}.so.1"
33+
34 /* At this point, bpabi.h will have clobbered LINK_SPEC. We want to
35 use the GNU/Linux version, not the generic BPABI version. */
36 #undef LINK_SPEC
37Index: gcc-5.1.0/libitm/config/arm/hwcap.cc
38===================================================================
39--- gcc-5.1.0.orig/libitm/config/arm/hwcap.cc
40+++ gcc-5.1.0/libitm/config/arm/hwcap.cc
41@@ -40,7 +40,11 @@ int GTM_hwcap HIDDEN = 0
42
43 #ifdef __linux__
44 #include <unistd.h>
45+#ifdef __GLIBC__
46 #include <sys/fcntl.h>
47+#else
48+#include <fcntl.h>
49+#endif
50 #include <elf.h>
51
52 static void __attribute__((constructor))
53Index: gcc-5.1.0/gcc/config/i386/linux.h
54===================================================================
55--- gcc-5.1.0.orig/gcc/config/i386/linux.h
56+++ gcc-5.1.0/gcc/config/i386/linux.h
57@@ -21,3 +21,4 @@ along with GCC; see the file COPYING3.
58
59 #define GNU_USER_LINK_EMULATION "elf_i386"
60 #define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-linux.so.2"
61+#define MUSL_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-musl-i386.so.1"
62Index: gcc-5.1.0/gcc/config/i386/linux64.h
63===================================================================
64--- gcc-5.1.0.orig/gcc/config/i386/linux64.h
65+++ gcc-5.1.0/gcc/config/i386/linux64.h
66@@ -30,3 +30,8 @@ see the files COPYING3 and COPYING.RUNTI
67 #define GLIBC_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld-linux.so.2"
68 #define GLIBC_DYNAMIC_LINKER64 SYSTEMLIBS_DIR "ld-linux-x86-64.so.2"
69 #define GLIBC_DYNAMIC_LINKERX32 SYSTEMLIBS_DIR "ld-linux-x32.so.2"
70+
71+#define MUSL_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld-musl-i386.so.1"
72+#define MUSL_DYNAMIC_LINKER64 SYSTEMLIBS_DIR "ld-musl-x86_64.so.1"
73+#define MUSL_DYNAMIC_LINKERX32 SYSTEMLIBS_DIR "ld-musl-x32.so.1"
74+
75Index: gcc-5.1.0/gcc/config/mips/linux.h
76===================================================================
77--- gcc-5.1.0.orig/gcc/config/mips/linux.h
78+++ gcc-5.1.0/gcc/config/mips/linux.h
79@@ -21,6 +21,10 @@ along with GCC; see the file COPYING3.
80 #define GNU_USER_LINK_EMULATION64 "elf64%{EB:b}%{EL:l}tsmip"
81 #define GNU_USER_LINK_EMULATIONN32 "elf32%{EB:b}%{EL:l}tsmipn32"
82
83+#define MUSL_DYNAMIC_LINKERN32 SYSTEMLIBS_DIR "ld-musl-mips.so.1"
84+#define MUSL_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld-musl-mips.so.1"
85+#define MUSL_DYNAMIC_LINKER64 SYSTEMLIBS_DIR "ld-musl-mips.so.1"
86+
87 #define GLIBC_DYNAMIC_LINKER32 \
88 "%{mnan=2008:" SYSTEMLIBS_DIR "ld-linux-mipsn8.so.1;:" SYSTEMLIBS_DIR "ld.so.1}"
89 #define GLIBC_DYNAMIC_LINKER64 \
90@@ -40,4 +44,4 @@ along with GCC; see the file COPYING3.
91 #define BIONIC_DYNAMIC_LINKERN32 "/system/bin/linker32"
92 #define GNU_USER_DYNAMIC_LINKERN32 \
93 CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERN32, UCLIBC_DYNAMIC_LINKERN32, \
94- BIONIC_DYNAMIC_LINKERN32)
95+ BIONIC_DYNAMIC_LINKERN32, MUSL_DYNAMIC_LINKERN32)
96Index: gcc-5.1.0/gcc/config/rs6000/linux64.h
97===================================================================
98--- gcc-5.1.0.orig/gcc/config/rs6000/linux64.h
99+++ gcc-5.1.0/gcc/config/rs6000/linux64.h
100@@ -365,17 +365,22 @@ extern int dot_symbols;
101 #endif
102 #define UCLIBC_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld-uClibc.so.0"
103 #define UCLIBC_DYNAMIC_LINKER64 SYSTEMLIBS_DIR "ld64-uClibc.so.0"
104+#define MUSL_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld-musl-powerpc.so.1"
105+#define MUSL_DYNAMIC_LINKER64 SYSTEMLIBS_DIR "ld-musl-powerpc64.so.1"
106+
107 #if DEFAULT_LIBC == LIBC_UCLIBC
108-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
109+#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}"
110 #elif DEFAULT_LIBC == LIBC_GLIBC
111-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}"
112+#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{muclibc:" U ";:%{mmusl:" M ";:" G "}}"
113+#elif DEFAULT_LIBC == LIBC_MUSL
114+#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{muclibc:" U ";:" M "}}"
115 #else
116 #error "Unsupported DEFAULT_LIBC"
117 #endif
118 #define GNU_USER_DYNAMIC_LINKER32 \
119- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32)
120+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32)
121 #define GNU_USER_DYNAMIC_LINKER64 \
122- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64)
123+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64)
124
125 #undef DEFAULT_ASM_ENDIAN
126 #if (TARGET_DEFAULT & MASK_LITTLE_ENDIAN)
127Index: gcc-5.1.0/gcc/config/rs6000/sysv4.h
128===================================================================
129--- gcc-5.1.0.orig/gcc/config/rs6000/sysv4.h
130+++ gcc-5.1.0/gcc/config/rs6000/sysv4.h
131@@ -769,15 +769,19 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEF
132
133 #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
134 #define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
135+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-powerpc.so.1"
136+
137 #if DEFAULT_LIBC == LIBC_UCLIBC
138-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
139+#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}"
140+#elif DEFAULT_LIBC == LIBC_MUSL
141+#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{muclibc:" U ";:" M "}}"
142 #elif !defined (DEFAULT_LIBC) || DEFAULT_LIBC == LIBC_GLIBC
143-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}"
144+#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{muclibc:" U ";:%{mmusl:" M ";:" G "}}"
145 #else
146 #error "Unsupported DEFAULT_LIBC"
147 #endif
148 #define GNU_USER_DYNAMIC_LINKER \
149- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER)
150+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER)
151
152 #define LINK_OS_LINUX_SPEC "-m elf32ppclinux %{!shared: %{!static: \
153 %{rdynamic:-export-dynamic} \
154Index: gcc-5.1.0/libitm/config/linux/x86/tls.h
155===================================================================
156--- gcc-5.1.0.orig/libitm/config/linux/x86/tls.h
157+++ gcc-5.1.0/libitm/config/linux/x86/tls.h
158@@ -25,16 +25,19 @@
159 #ifndef LIBITM_X86_TLS_H
160 #define LIBITM_X86_TLS_H 1
161
162-#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 10)
163+#if defined(__GLIBC_PREREQ)
164+#if __GLIBC_PREREQ(2, 10)
165 /* Use slots in the TCB head rather than __thread lookups.
166 GLIBC has reserved words 10 through 13 for TM. */
167 #define HAVE_ARCH_GTM_THREAD 1
168 #define HAVE_ARCH_GTM_THREAD_DISP 1
169 #endif
170+#endif
171
172 #include "config/generic/tls.h"
173
174-#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 10)
175+#if defined(__GLIBC_PREREQ)
176+#if __GLIBC_PREREQ(2, 10)
177 namespace GTM HIDDEN {
178
179 #ifdef __x86_64__
180@@ -101,5 +104,6 @@ static inline void set_abi_disp(struct a
181
182 } // namespace GTM
183 #endif /* >= GLIBC 2.10 */
184+#endif
185
186 #endif // LIBITM_X86_TLS_H
187Index: gcc-5.1.0/gcc/config/aarch64/aarch64-linux.h
188===================================================================
189--- gcc-5.1.0.orig/gcc/config/aarch64/aarch64-linux.h
190+++ gcc-5.1.0/gcc/config/aarch64/aarch64-linux.h
191@@ -22,6 +22,7 @@
192 #define GCC_AARCH64_LINUX_H
193
194 #define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-linux-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1"
195+#define MUSL_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-musl-aarch64.so.1"
196
197 #undef ASAN_CC1_SPEC
198 #define ASAN_CC1_SPEC "%{%:sanitize(address):-funwind-tables}"
diff --git a/meta/recipes-devtools/gcc/gcc-5.2/0046-musl-no-fixincludes.patch b/meta/recipes-devtools/gcc/gcc-5.2/0046-musl-no-fixincludes.patch
new file mode 100644
index 0000000000..05fe52f5f5
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-5.2/0046-musl-no-fixincludes.patch
@@ -0,0 +1,22 @@
1# HG changeset patch
2# Parent 600a8a422ccaf5627ad1f5a138e7398df2b9e9d8
3Get rid of ever-broken fixincludes on musl.
4
5Upstream-Status: Pending
6Signed-off-by: Khem Raj <raj.khem@gmail.com>
7
8
9Index: gcc-4.9-20140316/fixincludes/mkfixinc.sh
10===================================================================
11--- gcc-4.9-20140316.orig/fixincludes/mkfixinc.sh
12+++ gcc-4.9-20140316/fixincludes/mkfixinc.sh
13@@ -19,7 +19,8 @@ case $machine in
14 powerpc-*-eabi* | \
15 powerpc-*-rtems* | \
16 powerpcle-*-eabisim* | \
17- powerpcle-*-eabi* )
18+ powerpcle-*-eabi* | \
19+ *-musl* )
20 # IF there is no include fixing,
21 # THEN create a no-op fixer and exit
22 (echo "#! /bin/sh" ; echo "exit 0" ) > ${target}