toolchain/gcc: refresh patches
[openwrt/openwrt.git] / toolchain / gcc / patches / 4.6.3 / 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 @@ -478,7 +478,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 @@ -591,6 +591,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 --- a/gcc/config/arm/linux-eabi.h
33 +++ b/gcc/config/arm/linux-eabi.h
34 @@ -64,6 +64,10 @@
35 #undef GLIBC_DYNAMIC_LINKER
36 #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.3"
37
38 +/* musl has no "classic" (i.e. broken) mode */
39 +#undef MUSL_DYNAMIC_LINKER
40 +#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-arm.so.1"
41 +
42 /* At this point, bpabi.h will have clobbered LINK_SPEC. We want to
43 use the GNU/Linux version, not the generic BPABI version. */
44 #undef LINK_SPEC
45 --- a/gcc/config/i386/linux.h
46 +++ b/gcc/config/i386/linux.h
47 @@ -93,6 +93,7 @@ along with GCC; see the file COPYING3.
48 /* These macros may be overridden in k*bsd-gnu.h and i386/k*bsd-gnu.h. */
49 #define LINK_EMULATION "elf_i386"
50 #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
51 +#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-i386.so.1"
52
53 #undef ASM_SPEC
54 #define ASM_SPEC \
55 --- a/gcc/config/i386/linux64.h
56 +++ b/gcc/config/i386/linux64.h
57 @@ -65,6 +65,9 @@ see the files COPYING3 and COPYING.RUNTI
58 #define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2"
59 #define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux-x86-64.so.2"
60
61 +#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-i386.so.1"
62 +#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-x86_64.so.1"
63 +
64 #if TARGET_64BIT_DEFAULT
65 #define SPEC_32 "m32"
66 #define SPEC_64 "!m32"
67 --- a/gcc/config/linux.h
68 +++ b/gcc/config/linux.h
69 @@ -33,10 +33,12 @@ see the files COPYING3 and COPYING.RUNTI
70 #define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC)
71 #define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
72 #define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
73 +#define OPTION_MUSL (DEFAULT_LIBC == LIBC_MUSL)
74 #else
75 #define OPTION_GLIBC (linux_libc == LIBC_GLIBC)
76 #define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC)
77 #define OPTION_BIONIC (linux_libc == LIBC_BIONIC)
78 +#define OPTION_MUSL (linux_libc == LIBC_MUSL)
79 #endif
80
81 #define LINUX_TARGET_OS_CPP_BUILTINS() \
82 @@ -54,18 +56,21 @@ see the files COPYING3 and COPYING.RUNTI
83 uClibc or Bionic is the default C library and whether
84 -muclibc or -mglibc or -mbionic has been passed to change the default. */
85
86 -#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LD1, LD2, LD3) \
87 - "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:" LD1 "}}"
88 +#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LIBC4, LD1, LD2, LD3, LD4) \
89 + "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:%{" LIBC4 ":" LD4 ";:" LD1 "}}}"
90
91 #if DEFAULT_LIBC == LIBC_GLIBC
92 -#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
93 - CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", G, U, B)
94 +#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
95 + CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", "mmusl", G, U, B, M)
96 #elif DEFAULT_LIBC == LIBC_UCLIBC
97 -#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
98 - CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", U, G, B)
99 +#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
100 + CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", "mmusl", U, G, B, M)
101 #elif DEFAULT_LIBC == LIBC_BIONIC
102 -#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
103 - CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", B, G, U)
104 +#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
105 + CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", "mmusl", B, G, U, M)
106 +#elif DEFAULT_LIBC == LIBC_MUSL
107 +#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
108 + CHOOSE_DYNAMIC_LINKER1 ("mmusl", "mglibc", "muclibc", "mbionic", M, G, U, B)
109 #else
110 #error "Unsupported DEFAULT_LIBC"
111 #endif /* DEFAULT_LIBC */
112 @@ -83,13 +88,13 @@ see the files COPYING3 and COPYING.RUNTI
113
114 #define LINUX_DYNAMIC_LINKER \
115 CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, \
116 - BIONIC_DYNAMIC_LINKER)
117 + BIONIC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER)
118 #define LINUX_DYNAMIC_LINKER32 \
119 CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, \
120 - BIONIC_DYNAMIC_LINKER32)
121 + BIONIC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32)
122 #define LINUX_DYNAMIC_LINKER64 \
123 CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, \
124 - BIONIC_DYNAMIC_LINKER64)
125 + BIONIC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64)
126
127 /* Determine whether the entire c99 runtime
128 is present in the runtime library. */
129 --- a/gcc/config/linux.opt
130 +++ b/gcc/config/linux.opt
131 @@ -30,3 +30,7 @@ Use GNU C library
132 muclibc
133 Target Report RejectNegative Var(linux_libc,LIBC_UCLIBC) Negative(mbionic)
134 Use uClibc C library
135 +
136 +mmusl
137 +Target Report RejectNegative Var(linux_libc,LIBC_MUSL) Negative(mglibc)
138 +Use musl C library
139 --- a/gcc/config/mips/linux.h
140 +++ b/gcc/config/mips/linux.h
141 @@ -63,6 +63,8 @@ along with GCC; see the file COPYING3.
142
143 #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
144
145 +#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-mips.so.1"
146 +
147 /* Borrowed from sparc/linux.h */
148 #undef LINK_SPEC
149 #define LINK_SPEC \
150 --- a/gcc/ginclude/stddef.h
151 +++ b/gcc/ginclude/stddef.h
152 @@ -184,6 +184,7 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t;
153 #ifndef _GCC_SIZE_T
154 #ifndef _SIZET_
155 #ifndef __size_t
156 +#ifndef __DEFINED_size_t /* musl */
157 #define __size_t__ /* BeOS */
158 #define __SIZE_T__ /* Cray Unicos/Mk */
159 #define _SIZE_T
160 @@ -200,6 +201,7 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t;
161 #define ___int_size_t_h
162 #define _GCC_SIZE_T
163 #define _SIZET_
164 +#define __DEFINED_size_t /* musl */
165 #if defined (__FreeBSD__) && (__FreeBSD__ >= 5)
166 /* __size_t is a typedef on FreeBSD 5!, must not trash it. */
167 #else
168 @@ -214,6 +216,7 @@ typedef __SIZE_TYPE__ size_t;
169 typedef long ssize_t;
170 #endif /* __BEOS__ */
171 #endif /* !(defined (__GNUG__) && defined (size_t)) */
172 +#endif /* __DEFINED_size_t */
173 #endif /* __size_t */
174 #endif /* _SIZET_ */
175 #endif /* _GCC_SIZE_T */
176 --- a/libgomp/config/posix/time.c
177 +++ b/libgomp/config/posix/time.c
178 @@ -28,6 +28,8 @@
179 The following implementation uses the most simple POSIX routines.
180 If present, POSIX 4 clocks should be used instead. */
181
182 +#define _POSIX_C_SOURCE 199309L /* for clocks */
183 +
184 #include "libgomp.h"
185 #include <unistd.h>
186 #if TIME_WITH_SYS_TIME
187 --- a/libstdc++-v3/configure.host
188 +++ b/libstdc++-v3/configure.host
189 @@ -237,6 +237,13 @@ case "${host_os}" in
190 os_include_dir="os/bsd/freebsd"
191 ;;
192 gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu)
193 + # check for musl by target
194 + case "${host_os}" in
195 + *-musl*)
196 + os_include_dir="os/generic"
197 + ;;
198 + *)
199 +
200 if [ "$uclibc" = "yes" ]; then
201 os_include_dir="os/uclibc"
202 elif [ "$bionic" = "yes" ]; then
203 @@ -245,6 +252,9 @@ case "${host_os}" in
204 os_include_dir="os/gnu-linux"
205 fi
206 ;;
207 +
208 + esac
209 + ;;
210 hpux*)
211 os_include_dir="os/hpux"
212 ;;
213 --- a/gcc/config/mips/linux64.h
214 +++ b/gcc/config/mips/linux64.h
215 @@ -40,9 +40,12 @@ along with GCC; see the file COPYING3.
216 #define GLIBC_DYNAMIC_LINKERN32 "/lib32/ld.so.1"
217 #define UCLIBC_DYNAMIC_LINKERN32 "/lib32/ld-uClibc.so.0"
218 #define BIONIC_DYNAMIC_LINKERN32 "/system/bin/linker32"
219 +#define MUSL_DYNAMIC_LINKERN32 "/lib/ld-musl-mips.so.1"
220 +#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-mips.so.1"
221 +#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-mips.so.1"
222 #define LINUX_DYNAMIC_LINKERN32 \
223 CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERN32, UCLIBC_DYNAMIC_LINKERN32, \
224 - BIONIC_DYNAMIC_LINKERN32)
225 + BIONIC_DYNAMIC_LINKERN32, MUSL_DYNAMIC_LINKERN32)
226
227 #undef LINK_SPEC
228 #define LINK_SPEC "\