toolchain/gcc: refresh patches
[openwrt/openwrt.git] / toolchain / gcc / patches / 4.7-linaro / 200-musl.patch
1 --- a/gcc/config.gcc
2 +++ b/gcc/config.gcc
3 @@ -529,7 +529,7 @@ case ${target} in
4 esac
5
6 # Common C libraries.
7 -tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3"
8 +tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3 LIBC_MUSL=4"
9
10 # Common parts for widely ported systems.
11 case ${target} in
12 @@ -632,6 +632,9 @@ case ${target} in
13 *-*-*uclibc*)
14 tm_defines="$tm_defines DEFAULT_LIBC=LIBC_UCLIBC"
15 ;;
16 + *-*-*musl*)
17 + tm_defines="$tm_defines DEFAULT_LIBC=LIBC_MUSL"
18 + ;;
19 *)
20 tm_defines="$tm_defines DEFAULT_LIBC=LIBC_GLIBC"
21 ;;
22 @@ -1755,6 +1758,7 @@ microblaze*-linux*)
23 tm_file="${tm_file} dbxelf.h gnu-user.h linux.h microblaze/linux.h"
24 c_target_objs="${c_target_objs} microblaze-c.o"
25 cxx_target_objs="${cxx_target_objs} microblaze-c.o"
26 + tmake_file="${tmake_file} microblaze/t-microblaze"
27 ;;
28 microblaze*-*-rtems*)
29 tm_file="${tm_file} dbxelf.h"
30 --- a/gcc/config/arm/linux-eabi.h
31 +++ b/gcc/config/arm/linux-eabi.h
32 @@ -78,6 +78,10 @@
33 %{mfloat-abi=soft*:" GLIBC_DYNAMIC_LINKER_SOFT_FLOAT "} \
34 %{!mfloat-abi=*:" GLIBC_DYNAMIC_LINKER_DEFAULT "}"
35
36 +/* musl has no "classic" (i.e. broken) mode */
37 +#undef MUSL_DYNAMIC_LINKER
38 +#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-arm.so.1"
39 +
40 /* At this point, bpabi.h will have clobbered LINK_SPEC. We want to
41 use the GNU/Linux version, not the generic BPABI version. */
42 #undef LINK_SPEC
43 --- a/gcc/config/i386/linux.h
44 +++ b/gcc/config/i386/linux.h
45 @@ -22,3 +22,4 @@ along with GCC; see the file COPYING3.
46
47 #define GNU_USER_LINK_EMULATION "elf_i386"
48 #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
49 +#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-i386.so.1"
50 --- a/gcc/config/i386/linux64.h
51 +++ b/gcc/config/i386/linux64.h
52 @@ -31,3 +31,7 @@ see the files COPYING3 and COPYING.RUNTI
53 #define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2"
54 #define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux-x86-64.so.2"
55 #define GLIBC_DYNAMIC_LINKERX32 "/libx32/ld-linux-x32.so.2"
56 +
57 +#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-i386.so.1"
58 +#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-x86_64.so.1"
59 +#define MUSL_DYNAMIC_LINKERX32 "/lib/ld-musl-x32.so.1"
60 --- a/gcc/config/linux.h
61 +++ b/gcc/config/linux.h
62 @@ -33,10 +33,12 @@ see the files COPYING3 and COPYING.RUNTI
63 #define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC)
64 #define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
65 #define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
66 +#define OPTION_MUSL (DEFAULT_LIBC == LIBC_MUSL)
67 #else
68 #define OPTION_GLIBC (linux_libc == LIBC_GLIBC)
69 #define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC)
70 #define OPTION_BIONIC (linux_libc == LIBC_BIONIC)
71 +#define OPTION_MUSL (linux_libc == LIBC_MUSL)
72 #endif
73
74 #define GNU_USER_TARGET_OS_CPP_BUILTINS() \
75 @@ -54,18 +56,21 @@ see the files COPYING3 and COPYING.RUNTI
76 uClibc or Bionic is the default C library and whether
77 -muclibc or -mglibc or -mbionic has been passed to change the default. */
78
79 -#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LD1, LD2, LD3) \
80 - "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:" LD1 "}}"
81 +#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LIBC4, LD1, LD2, LD3, LD4) \
82 + "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:%{" LIBC4 ":" LD4 ";:" LD1 "}}}"
83
84 #if DEFAULT_LIBC == LIBC_GLIBC
85 -#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
86 - CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", G, U, B)
87 +#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
88 + CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", "mmusl", G, U, B, M)
89 #elif DEFAULT_LIBC == LIBC_UCLIBC
90 -#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
91 - CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", U, G, B)
92 +#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
93 + CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", "mmusl", U, G, B, M)
94 #elif DEFAULT_LIBC == LIBC_BIONIC
95 -#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
96 - CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", B, G, U)
97 +#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
98 + CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", "mmusl", B, G, U, M)
99 +#elif DEFAULT_LIBC == LIBC_MUSL
100 +#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
101 + CHOOSE_DYNAMIC_LINKER1 ("mmusl", "mglibc", "muclibc", "mbionic", M, G, U, B)
102 #else
103 #error "Unsupported DEFAULT_LIBC"
104 #endif /* DEFAULT_LIBC */
105 @@ -85,16 +90,16 @@ see the files COPYING3 and COPYING.RUNTI
106
107 #define GNU_USER_DYNAMIC_LINKER \
108 CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, \
109 - BIONIC_DYNAMIC_LINKER)
110 + BIONIC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER)
111 #define GNU_USER_DYNAMIC_LINKER32 \
112 CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, \
113 - BIONIC_DYNAMIC_LINKER32)
114 + BIONIC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32)
115 #define GNU_USER_DYNAMIC_LINKER64 \
116 CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, \
117 - BIONIC_DYNAMIC_LINKER64)
118 + BIONIC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64)
119 #define GNU_USER_DYNAMIC_LINKERX32 \
120 CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERX32, UCLIBC_DYNAMIC_LINKERX32, \
121 - BIONIC_DYNAMIC_LINKERX32)
122 + BIONIC_DYNAMIC_LINKERX32, MUSL_DYNAMIC_LINKERX32)
123
124 /* Determine whether the entire c99 runtime
125 is present in the runtime library. */
126 --- a/gcc/config/linux.opt
127 +++ b/gcc/config/linux.opt
128 @@ -30,3 +30,7 @@ Use GNU C library
129 muclibc
130 Target Report RejectNegative Var(linux_libc,LIBC_UCLIBC) Negative(mbionic)
131 Use uClibc C library
132 +
133 +mmusl
134 +Target Report RejectNegative Var(linux_libc,LIBC_MUSL) Negative(mglibc)
135 +Use musl C library
136 --- a/gcc/config/mips/linux.h
137 +++ b/gcc/config/mips/linux.h
138 @@ -19,3 +19,5 @@ along with GCC; see the file COPYING3.
139 <http://www.gnu.org/licenses/>. */
140
141 #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
142 +
143 +#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-mips.so.1"
144 --- a/gcc/config/rs6000/linux64.h
145 +++ b/gcc/config/rs6000/linux64.h
146 @@ -362,17 +362,21 @@ extern int dot_symbols;
147 #define GLIBC_DYNAMIC_LINKER64 "/lib64/ld64.so.1"
148 #define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0"
149 #define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0"
150 +#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-powerpc.so.1"
151 +#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-powerpc64.so.1"
152 #if DEFAULT_LIBC == LIBC_UCLIBC
153 -#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
154 +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}"
155 #elif DEFAULT_LIBC == LIBC_GLIBC
156 -#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}"
157 +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{muclibc:" U ";:%{mmusl:" M ";:" G "}}"
158 +#elif DEFAULT_LIBC == LIBC_MUSL
159 +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{muclibc:" U ";:" M "}}"
160 #else
161 #error "Unsupported DEFAULT_LIBC"
162 #endif
163 #define GNU_USER_DYNAMIC_LINKER32 \
164 - CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32)
165 + CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32)
166 #define GNU_USER_DYNAMIC_LINKER64 \
167 - CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64)
168 + CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64)
169
170
171 #define LINK_OS_LINUX_SPEC32 "-m elf32ppclinux %{!shared: %{!static: \
172 --- a/gcc/config/rs6000/sysv4.h
173 +++ b/gcc/config/rs6000/sysv4.h
174 @@ -804,15 +804,18 @@ extern int fixuplabelno;
175
176 #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
177 #define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
178 +#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-powerpc.so.1"
179 #if DEFAULT_LIBC == LIBC_UCLIBC
180 -#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
181 +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{mmusl:" M ";:" U "}}"
182 +#elif DEFAULT_LIBC == LIBC_MUSL
183 +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{muclibc:" U ";:" M "}}"
184 #elif !defined (DEFAULT_LIBC) || DEFAULT_LIBC == LIBC_GLIBC
185 -#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}"
186 +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{muclibc:" U ";:%{mmusl:" M ";:" G "}}"
187 #else
188 #error "Unsupported DEFAULT_LIBC"
189 #endif
190 #define GNU_USER_DYNAMIC_LINKER \
191 - CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER)
192 + CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER)
193
194 #define LINK_OS_LINUX_SPEC "-m elf32ppclinux %{!shared: %{!static: \
195 %{rdynamic:-export-dynamic} \
196 --- a/gcc/ginclude/stddef.h
197 +++ b/gcc/ginclude/stddef.h
198 @@ -184,6 +184,7 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t;
199 #ifndef _GCC_SIZE_T
200 #ifndef _SIZET_
201 #ifndef __size_t
202 +#ifndef __DEFINED_size_t /* musl */
203 #define __size_t__ /* BeOS */
204 #define __SIZE_T__ /* Cray Unicos/Mk */
205 #define _SIZE_T
206 @@ -200,6 +201,7 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t;
207 #define ___int_size_t_h
208 #define _GCC_SIZE_T
209 #define _SIZET_
210 +#define __DEFINED_size_t /* musl */
211 #if (defined (__FreeBSD__) && (__FreeBSD__ >= 5)) \
212 || defined(__FreeBSD_kernel__)
213 /* __size_t is a typedef on FreeBSD 5, must not trash it. */
214 @@ -215,6 +217,7 @@ typedef __SIZE_TYPE__ size_t;
215 typedef long ssize_t;
216 #endif /* __BEOS__ */
217 #endif /* !(defined (__GNUG__) && defined (size_t)) */
218 +#endif /* __DEFINED_size_t */
219 #endif /* __size_t */
220 #endif /* _SIZET_ */
221 #endif /* _GCC_SIZE_T */
222 --- a/libgomp/config/posix/time.c
223 +++ b/libgomp/config/posix/time.c
224 @@ -28,6 +28,8 @@
225 The following implementation uses the most simple POSIX routines.
226 If present, POSIX 4 clocks should be used instead. */
227
228 +#define _POSIX_C_SOURCE 199309L /* for clocks */
229 +
230 #include "libgomp.h"
231 #include <unistd.h>
232 #if TIME_WITH_SYS_TIME
233 --- a/libitm/config/arm/hwcap.cc
234 +++ b/libitm/config/arm/hwcap.cc
235 @@ -40,7 +40,11 @@ int GTM_hwcap HIDDEN = 0
236
237 #ifdef __linux__
238 #include <unistd.h>
239 +#ifdef __GLIBC__
240 #include <sys/fcntl.h>
241 +#else
242 +#include <fcntl.h>
243 +#endif
244 #include <elf.h>
245
246 static void __attribute__((constructor))
247 --- a/libitm/config/linux/x86/tls.h
248 +++ b/libitm/config/linux/x86/tls.h
249 @@ -25,16 +25,19 @@
250 #ifndef LIBITM_X86_TLS_H
251 #define LIBITM_X86_TLS_H 1
252
253 -#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 10)
254 +#if defined(__GLIBC_PREREQ)
255 +#if __GLIBC_PREREQ(2, 10)
256 /* Use slots in the TCB head rather than __thread lookups.
257 GLIBC has reserved words 10 through 13 for TM. */
258 #define HAVE_ARCH_GTM_THREAD 1
259 #define HAVE_ARCH_GTM_THREAD_DISP 1
260 #endif
261 +#endif
262
263 #include "config/generic/tls.h"
264
265 -#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 10)
266 +#if defined(__GLIBC_PREREQ)
267 +#if __GLIBC_PREREQ(2, 10)
268 namespace GTM HIDDEN {
269
270 #ifdef __x86_64__
271 @@ -101,5 +104,6 @@ static inline void set_abi_disp(struct a
272
273 } // namespace GTM
274 #endif /* >= GLIBC 2.10 */
275 +#endif
276
277 #endif // LIBITM_X86_TLS_H
278 --- a/libstdc++-v3/configure.host
279 +++ b/libstdc++-v3/configure.host
280 @@ -246,6 +246,13 @@ case "${host_os}" in
281 os_include_dir="os/bsd/freebsd"
282 ;;
283 gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu)
284 + # check for musl by target
285 + case "${host_os}" in
286 + *-musl*)
287 + os_include_dir="os/generic"
288 + ;;
289 + *)
290 +
291 if [ "$uclibc" = "yes" ]; then
292 os_include_dir="os/uclibc"
293 elif [ "$bionic" = "yes" ]; then
294 @@ -254,6 +261,9 @@ case "${host_os}" in
295 os_include_dir="os/gnu-linux"
296 fi
297 ;;
298 +
299 + esac
300 + ;;
301 hpux*)
302 os_include_dir="os/hpux"
303 ;;
304 --- a/gcc/config/mips/linux64.h
305 +++ b/gcc/config/mips/linux64.h
306 @@ -28,6 +28,9 @@ along with GCC; see the file COPYING3.
307 #define GLIBC_DYNAMIC_LINKERN32 "/lib32/ld.so.1"
308 #define UCLIBC_DYNAMIC_LINKERN32 "/lib32/ld-uClibc.so.0"
309 #define BIONIC_DYNAMIC_LINKERN32 "/system/bin/linker32"
310 +#define MUSL_DYNAMIC_LINKERN32 "/lib/ld-musl-mips.so.1"
311 +#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-mips.so.1"
312 +#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-mips.so.1"
313 #define GNU_USER_DYNAMIC_LINKERN32 \
314 CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERN32, UCLIBC_DYNAMIC_LINKERN32, \
315 - BIONIC_DYNAMIC_LINKERN32)
316 + BIONIC_DYNAMIC_LINKERN32, MUSL_DYNAMIC_LINKERN32)