Root/toolchain/gcc/patches/4.5-linaro/200-musl.patch

1diff -urN gcc-linaro-4.5-2012.03/config.sub gcc-linaro-4.5-2012.03.new/config.sub
2--- gcc-linaro-4.5-2012.03/config.sub 2012-03-12 12:29:55.000000000 +0100
3+++ gcc-linaro-4.5-2012.03.new/config.sub 2012-11-29 15:45:43.802377940 +0100
4@@ -125,6 +125,7 @@
5 maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
6 case $maybe_os in
7   nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
8+ linux-musl* | \
9   linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
10   knetbsd*-gnu* | netbsd*-gnu* | \
11   kopensolaris*-gnu* | \
12@@ -1310,6 +1311,7 @@
13           | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
14           | -mingw32* | -linux-gnu* | -linux-android* \
15           | -linux-newlib* | -linux-uclibc* \
16+ | -linux-musl* \
17           | -uxpv* | -beos* | -mpeix* | -udk* \
18           | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
19           | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
20diff -urN gcc-linaro-4.5-2012.03/gcc/config/arm/linux-eabi.h gcc-linaro-4.5-2012.03.new/gcc/config/arm/linux-eabi.h
21--- gcc-linaro-4.5-2012.03/gcc/config/arm/linux-eabi.h 2012-03-12 12:29:55.000000000 +0100
22+++ gcc-linaro-4.5-2012.03.new/gcc/config/arm/linux-eabi.h 2012-11-29 15:45:43.802377940 +0100
23@@ -63,6 +63,10 @@
24 #undef GLIBC_DYNAMIC_LINKER
25 #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.3"
26 
27+/* musl has no "classic" (i.e. broken) mode */
28+#undef MUSL_DYNAMIC_LINKER
29+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-arm.so.1"
30+
31 /* At this point, bpabi.h will have clobbered LINK_SPEC. We want to
32    use the GNU/Linux version, not the generic BPABI version. */
33 #undef LINK_SPEC
34diff -urN gcc-linaro-4.5-2012.03/gcc/config/i386/linux.h gcc-linaro-4.5-2012.03.new/gcc/config/i386/linux.h
35--- gcc-linaro-4.5-2012.03/gcc/config/i386/linux.h 2012-03-12 12:29:55.000000000 +0100
36+++ gcc-linaro-4.5-2012.03.new/gcc/config/i386/linux.h 2012-11-29 15:45:43.802377940 +0100
37@@ -101,6 +101,7 @@
38 /* These macros may be overridden in k*bsd-gnu.h and i386/k*bsd-gnu.h. */
39 #define LINK_EMULATION "elf_i386"
40 #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
41+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-i386.so.1"
42 
43 #undef ASM_SPEC
44 #define ASM_SPEC \
45diff -urN gcc-linaro-4.5-2012.03/gcc/config/i386/linux64.h gcc-linaro-4.5-2012.03.new/gcc/config/i386/linux64.h
46--- gcc-linaro-4.5-2012.03/gcc/config/i386/linux64.h 2012-03-12 12:29:55.000000000 +0100
47+++ gcc-linaro-4.5-2012.03.new/gcc/config/i386/linux64.h 2012-11-29 15:45:43.802377940 +0100
48@@ -61,6 +61,9 @@
49 #define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2"
50 #define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux-x86-64.so.2"
51 
52+#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-i386.so.1"
53+#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-x86_64.so.1"
54+
55 #if TARGET_64BIT_DEFAULT
56 #define SPEC_32 "m32"
57 #define SPEC_64 "!m32"
58diff -urN gcc-linaro-4.5-2012.03/gcc/config/linux.h gcc-linaro-4.5-2012.03.new/gcc/config/linux.h
59--- gcc-linaro-4.5-2012.03/gcc/config/linux.h 2012-03-12 12:29:55.000000000 +0100
60+++ gcc-linaro-4.5-2012.03.new/gcc/config/linux.h 2012-11-29 15:46:48.982379607 +0100
61@@ -86,6 +86,7 @@
62 #define OPTION_GLIBC (linux_libc == LIBC_GLIBC)
63 #define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC)
64 #define OPTION_BIONIC (linux_libc == LIBC_BIONIC)
65+#define OPTION_MUSL (linux_libc == LIBC_MUSL)
66 
67 #define LINUX_TARGET_OS_CPP_BUILTINS() \
68     do { \
69@@ -120,18 +121,21 @@
70    uClibc or Bionic is the default C library and whether
71    -muclibc or -mglibc or -mbionic has been passed to change the default. */
72 
73-#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LD1, LD2, LD3) \
74- "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:" LD1 "}}"
75+#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LIBC4, LD1, LD2, LD3, LD4) \
76+ "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:%{" LIBC4 ":" LD4 ";:" LD1 "}}}"
77 
78 #if DEFAULT_LIBC == LIBC_GLIBC
79-#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
80- CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", G, U, B)
81+#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
82+ CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", "mmusl", G, U, B, M)
83 #elif DEFAULT_LIBC == LIBC_UCLIBC
84-#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
85- CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", U, G, B)
86+#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
87+ CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", "mmusl", U, G, B, M)
88 #elif DEFAULT_LIBC == LIBC_BIONIC
89-#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
90- CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", B, G, U)
91+#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
92+ CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", "mmusl", B, G, U, M)
93+#elif DEFAULT_LIBC == LIBC_MUSL
94+#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
95+ CHOOSE_DYNAMIC_LINKER1 ("mmusl", "mglibc", "muclibc", "mbionic", M, G, U, B)
96 #else
97 #error "Unsupported DEFAULT_LIBC"
98 #endif /* DEFAULT_LIBC */
99@@ -149,13 +153,13 @@
100 
101 #define LINUX_DYNAMIC_LINKER \
102   CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, \
103- BIONIC_DYNAMIC_LINKER)
104+ BIONIC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER)
105 #define LINUX_DYNAMIC_LINKER32 \
106   CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, \
107- BIONIC_DYNAMIC_LINKER32)
108+ BIONIC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32)
109 #define LINUX_DYNAMIC_LINKER64 \
110   CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, \
111- BIONIC_DYNAMIC_LINKER64)
112+ BIONIC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64)
113 
114 /* Determine whether the entire c99 runtime
115    is present in the runtime library. */
116diff -urN gcc-linaro-4.5-2012.03/gcc/config/linux.opt gcc-linaro-4.5-2012.03.new/gcc/config/linux.opt
117--- gcc-linaro-4.5-2012.03/gcc/config/linux.opt 2012-03-12 12:29:55.000000000 +0100
118+++ gcc-linaro-4.5-2012.03.new/gcc/config/linux.opt 2012-11-29 15:45:43.802377940 +0100
119@@ -30,3 +30,7 @@
120 muclibc
121 Target Report RejectNegative Var(linux_libc,LIBC_UCLIBC) VarExists Negative(mbionic)
122 Use uClibc C library
123+
124+mmusl
125+Target Report RejectNegative Var(linux_libc,LIBC_MUSL) Negative(mglibc)
126+Use musl C library
127diff -urN gcc-linaro-4.5-2012.03/gcc/config/mips/linux.h gcc-linaro-4.5-2012.03.new/gcc/config/mips/linux.h
128--- gcc-linaro-4.5-2012.03/gcc/config/mips/linux.h 2012-03-12 12:29:55.000000000 +0100
129+++ gcc-linaro-4.5-2012.03.new/gcc/config/mips/linux.h 2012-11-29 15:45:43.802377940 +0100
130@@ -66,6 +66,8 @@
131 
132 #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
133 
134+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-mips.so.1"
135+
136 /* Borrowed from sparc/linux.h */
137 #undef LINK_SPEC
138 #define LINK_SPEC \
139diff -urN gcc-linaro-4.5-2012.03/gcc/config/mips/linux64.h gcc-linaro-4.5-2012.03.new/gcc/config/mips/linux64.h
140--- gcc-linaro-4.5-2012.03/gcc/config/mips/linux64.h 2012-03-12 12:29:55.000000000 +0100
141+++ gcc-linaro-4.5-2012.03.new/gcc/config/mips/linux64.h 2012-11-29 15:48:10.542381697 +0100
142@@ -39,8 +39,11 @@
143 #define GLIBC_DYNAMIC_LINKER64 "/lib64/ld.so.1"
144 #define GLIBC_DYNAMIC_LINKERN32 "/lib32/ld.so.1"
145 #define UCLIBC_DYNAMIC_LINKERN32 "/lib32/ld-uClibc.so.0"
146+#define MUSL_DYNAMIC_LINKERN32 "/lib32/ld-musl-mips.so.1"
147+#define MUSL_DYNAMIC_LINKER32 "/lib32/ld-musl-mips.so.1"
148+#define MUSL_DYNAMIC_LINKER64 "/lib64/ld-musl-mips.so.1"
149 #define LINUX_DYNAMIC_LINKERN32 \
150- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERN32, UCLIBC_DYNAMIC_LINKERN32)
151+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERN32, UCLIBC_DYNAMIC_LINKERN32, MUSL_DYNAMIC_LINKERN32)
152 
153 #undef LINK_SPEC
154 #define LINK_SPEC "\
155diff -urN gcc-linaro-4.5-2012.03/gcc/config.gcc gcc-linaro-4.5-2012.03.new/gcc/config.gcc
156--- gcc-linaro-4.5-2012.03/gcc/config.gcc 2012-03-12 12:29:55.000000000 +0100
157+++ gcc-linaro-4.5-2012.03.new/gcc/config.gcc 2012-11-29 15:46:18.474378826 +0100
158@@ -514,7 +514,7 @@
159       tmake_file="$tmake_file t-gnu";;
160   esac
161   # Common C libraries.
162- tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3"
163+ tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3 LIBC_MUSL=4"
164   # glibc / uclibc / bionic switch.
165   # uclibc and bionic aren't usable for GNU/Hurd and neither for GNU/k*BSD.
166   case $target in
167@@ -530,6 +530,9 @@
168     *-*-*uclibc*)
169       tm_defines="$tm_defines DEFAULT_LIBC=LIBC_UCLIBC"
170       ;;
171+ *-*-*musl*)
172+ tm_defines="$tm_defines DEFAULT_LIBC=LIBC_MUSL"
173+ ;;
174     *)
175       tm_defines="$tm_defines DEFAULT_LIBC=LIBC_GLIBC"
176       ;;
177diff -urN gcc-linaro-4.5-2012.03/gcc/ginclude/stddef.h gcc-linaro-4.5-2012.03.new/gcc/ginclude/stddef.h
178--- gcc-linaro-4.5-2012.03/gcc/ginclude/stddef.h 2012-03-12 12:29:55.000000000 +0100
179+++ gcc-linaro-4.5-2012.03.new/gcc/ginclude/stddef.h 2012-11-29 15:45:43.802377940 +0100
180@@ -183,6 +183,7 @@
181 #ifndef _GCC_SIZE_T
182 #ifndef _SIZET_
183 #ifndef __size_t
184+#ifndef __DEFINED_size_t /* musl */
185 #define __size_t__ /* BeOS */
186 #define __SIZE_T__ /* Cray Unicos/Mk */
187 #define _SIZE_T
188@@ -199,6 +200,7 @@
189 #define ___int_size_t_h
190 #define _GCC_SIZE_T
191 #define _SIZET_
192+#define __DEFINED_size_t /* musl */
193 #if defined (__FreeBSD__) && (__FreeBSD__ >= 5)
194 /* __size_t is a typedef on FreeBSD 5!, must not trash it. */
195 #else
196@@ -213,6 +215,7 @@
197 typedef long ssize_t;
198 #endif /* __BEOS__ */
199 #endif /* !(defined (__GNUG__) && defined (size_t)) */
200+#endif /* __DEFINED_size_t */
201 #endif /* __size_t */
202 #endif /* _SIZET_ */
203 #endif /* _GCC_SIZE_T */
204diff -urN gcc-linaro-4.5-2012.03/libgomp/config/posix/time.c gcc-linaro-4.5-2012.03.new/libgomp/config/posix/time.c
205--- gcc-linaro-4.5-2012.03/libgomp/config/posix/time.c 2012-03-12 12:29:55.000000000 +0100
206+++ gcc-linaro-4.5-2012.03.new/libgomp/config/posix/time.c 2012-11-29 15:45:43.802377940 +0100
207@@ -28,6 +28,8 @@
208    The following implementation uses the most simple POSIX routines.
209    If present, POSIX 4 clocks should be used instead. */
210 
211+#define _POSIX_C_SOURCE 199309L /* for clocks */
212+
213 #include "libgomp.h"
214 #include <unistd.h>
215 #if TIME_WITH_SYS_TIME
216diff -urN gcc-linaro-4.5-2012.03/libstdc++-v3/configure.host gcc-linaro-4.5-2012.03.new/libstdc++-v3/configure.host
217--- gcc-linaro-4.5-2012.03/libstdc++-v3/configure.host 2012-03-12 12:29:55.000000000 +0100
218+++ gcc-linaro-4.5-2012.03.new/libstdc++-v3/configure.host 2012-11-29 15:45:43.806377939 +0100
219@@ -236,6 +236,13 @@
220     os_include_dir="os/bsd/freebsd"
221     ;;
222   gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu)
223+ # check for musl by target
224+ case "${host_os}" in
225+ *-musl*)
226+ os_include_dir="os/generic"
227+ ;;
228+ *)
229+
230     if [ "$uclibc" = "yes" ]; then
231       os_include_dir="os/uclibc"
232     elif [ "$bionic" = "yes" ]; then
233@@ -244,6 +251,9 @@
234       os_include_dir="os/gnu-linux"
235     fi
236     ;;
237+
238+ esac
239+ ;;
240   hpux*)
241     os_include_dir="os/hpux"
242     ;;
243

Archive Download this file



interactive