Root/toolchain/gcc/patches/4.6.3/200-musl.patch

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

Archive Download this file



interactive