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