psp: add a patch for GCC 4.7.4
[rofl0r-mmix-cross.git] / patches / gcc-4.2.1-musl.diff
blobfce1e319591616888e141f419bc4df4f32aff931
1 diff --git a/config.sub b/config.sub
2 --- a/config.sub
3 +++ b/config.sub
4 @@ -120,7 +120,7 @@
5 # Here we must recognize all the valid KERNEL-OS combinations.
6 maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
7 case $maybe_os in
8 - nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
9 + nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | linux-musl* | \
10 uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
11 storm-chaos* | os2-emx* | rtmk-nova*)
12 os=-$maybe_os
13 @@ -1211,7 +1211,7 @@
14 | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
15 | -chorusos* | -chorusrdb* \
16 | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
17 - | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
18 + | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* | -linux-musl* \
19 | -uxpv* | -beos* | -mpeix* | -udk* \
20 | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
21 | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
22 diff --git a/gcc/config.gcc b/gcc/config.gcc
23 --- a/gcc/config.gcc
24 +++ b/gcc/config.gcc
25 @@ -469,10 +469,13 @@
26 tmake_file="t-slibgcc-elf-ver t-linux"
27 case ${target} in
28 *-*-*uclibc*)
29 - tm_defines="${tm_defines} UCLIBC_DEFAULT=1"
30 + tm_defines="${tm_defines} UCLIBC_DEFAULT=1 MUSL_DEFAULT=0"
31 + ;;
32 + *-*-*musl*)
33 + tm_defines="$tm_defines UCLIBC_DEFAULT=0 MUSL_DEFAULT=1"
36 - tm_defines="${tm_defines} UCLIBC_DEFAULT=0"
37 + tm_defines="${tm_defines} UCLIBC_DEFAULT=0 MUSL_DEFAULT=1"
39 esac
40 # Assume that glibc or uClibc are being used and so __cxa_atexit is provided.
41 diff --git a/gcc/config/arm/linux-eabi.h b/gcc/config/arm/linux-eabi.h
42 --- a/gcc/config/arm/linux-eabi.h
43 +++ b/gcc/config/arm/linux-eabi.h
44 @@ -55,6 +55,10 @@
45 #undef GLIBC_DYNAMIC_LINKER
46 #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.3"
48 +/* musl has no "classic" (i.e. broken) mode */
49 +#undef MUSL_DYNAMIC_LINKER
50 +#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-arm.so.1"
52 /* At this point, bpabi.h will have clobbered LINK_SPEC. We want to
53 use the GNU/Linux version, not the generic BPABI version. */
54 #undef LINK_SPEC
55 diff --git a/gcc/config/i386/linux.h b/gcc/config/i386/linux.h
56 --- a/gcc/config/i386/linux.h
57 +++ b/gcc/config/i386/linux.h
58 @@ -102,6 +102,7 @@
59 /* These macros may be overridden in k*bsd-gnu.h and i386/k*bsd-gnu.h. */
60 #define LINK_EMULATION "elf_i386"
61 #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
62 +#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-i386.so.1"
64 #undef SUBTARGET_EXTRA_SPECS
65 #define SUBTARGET_EXTRA_SPECS \
66 diff --git a/gcc/config/i386/linux64.h b/gcc/config/i386/linux64.h
67 --- a/gcc/config/i386/linux64.h
68 +++ b/gcc/config/i386/linux64.h
69 @@ -52,6 +52,9 @@
70 #define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2"
71 #define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux-x86-64.so.2"
73 +#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-i386.so.1"
74 +#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-x86_64.so.1"
76 #undef LINK_SPEC
77 #define LINK_SPEC "%{!m32:-m elf_x86_64} %{m32:-m elf_i386} \
78 %{shared:-shared} \
79 diff --git a/gcc/config/linux.h b/gcc/config/linux.h
80 --- a/gcc/config/linux.h
81 +++ b/gcc/config/linux.h
82 @@ -103,9 +103,11 @@
83 uClibc is the default C library and whether -muclibc or -mglibc has
84 been passed to change the default. */
85 #if UCLIBC_DEFAULT
86 -#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:%{muclibc:%e-mglibc and -muclibc used together}" G ";:" U "}"
87 +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mmusl:" M ";:%{mglibc:%{muclibc:%e-mglibc and -muclibc used together}" G ";:" U "}}"
88 +#elif defined(MUSL_DEFAULT)
89 +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mglibc:" G ";:%{muclibc:" U ";:" M "}}"
90 #else
91 -#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:%{mglibc:%e-mglibc and -muclibc used together}" U ";:" G "}"
92 +#define CHOOSE_DYNAMIC_LINKER(G, U, M) "%{mmusl:" M ";:%{muclibc:%{mglibc:%e-mglibc and -muclibc used together}" U ";:" G "}}"
93 #endif
95 /* For most targets the following definitions suffice;
96 @@ -116,11 +118,11 @@
97 #define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0"
98 #define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0"
99 #define LINUX_DYNAMIC_LINKER \
100 - CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER)
101 + CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER)
102 #define LINUX_DYNAMIC_LINKER32 \
103 - CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32)
104 + CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32)
105 #define LINUX_DYNAMIC_LINKER64 \
106 - CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64)
107 + CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64)
109 /* Determine whether the entire c99 runtime
110 is present in the runtime library. */
111 diff --git a/gcc/config/linux.opt b/gcc/config/linux.opt
112 --- a/gcc/config/linux.opt
113 +++ b/gcc/config/linux.opt
114 @@ -25,5 +25,9 @@
115 Use uClibc instead of GNU libc
117 mglibc
118 -Target RejectNegative Report InverseMask(UCLIBC, GLIBC) Var(linux_uclibc) VarExists
119 +Target RejectNegative Report InverseMask(UCLIBC, GLIBC) Var(linux_uclibc) VarExists InverseMask(MUSL, GLIBC) Var(linux_musl) VarExists
120 Use GNU libc instead of uClibc
122 +mmusl
123 +Target RejectNegative Report Mask(MUSL) Var(linux_musl) Init(MUSL_DEFAULT ? OPTION_MASK_MUSL : 0)
124 +Use musl C library
125 diff --git a/gcc/config/mips/linux.h b/gcc/config/mips/linux.h
126 --- a/gcc/config/mips/linux.h
127 +++ b/gcc/config/mips/linux.h
128 @@ -106,6 +106,8 @@
130 #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
132 +#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-mips.so.1"
134 /* Borrowed from sparc/linux.h */
135 #undef LINK_SPEC
136 #define LINK_SPEC \
137 diff --git a/gcc/ginclude/stddef.h b/gcc/ginclude/stddef.h
138 --- a/gcc/ginclude/stddef.h
139 +++ b/gcc/ginclude/stddef.h
140 @@ -186,6 +186,7 @@
141 #ifndef _GCC_SIZE_T
142 #ifndef _SIZET_
143 #ifndef __size_t
144 +#ifndef __DEFINED_size_t /* musl */
145 #define __size_t__ /* BeOS */
146 #define __SIZE_T__ /* Cray Unicos/Mk */
147 #define _SIZE_T
148 @@ -202,6 +203,7 @@
149 #define ___int_size_t_h
150 #define _GCC_SIZE_T
151 #define _SIZET_
152 +#define __DEFINED_size_t /* musl */
153 #if defined (__FreeBSD__) && (__FreeBSD__ >= 5)
154 /* __size_t is a typedef on FreeBSD 5!, must not trash it. */
155 #else
156 @@ -216,6 +218,7 @@
157 typedef long ssize_t;
158 #endif /* __BEOS__ */
159 #endif /* !(defined (__GNUG__) && defined (size_t)) */
160 +#endif /* __DEFINED_size_t */
161 #endif /* __size_t */
162 #endif /* _SIZET_ */
163 #endif /* _GCC_SIZE_T */
164 diff --git a/libgomp/config/posix/time.c b/libgomp/config/posix/time.c
165 --- a/libgomp/config/posix/time.c
166 +++ b/libgomp/config/posix/time.c
167 @@ -31,6 +31,8 @@
168 The following implementation uses the most simple POSIX routines.
169 If present, POSIX 4 clocks should be used instead. */
171 +#define _POSIX_C_SOURCE 199309L /* for clocks */
173 #include "libgomp.h"
174 #include <unistd.h>
175 #if TIME_WITH_SYS_TIME
176 diff --git a/libgomp/env.c b/libgomp/env.c
177 --- a/libgomp/env.c
178 +++ b/libgomp/env.c
179 @@ -28,6 +28,8 @@
180 /* This file defines the OpenMP internal control variables, and arranges
181 for them to be initialized from environment variables at startup. */
183 +#define _GNU_SOURCE
185 #include "libgomp.h"
186 #include "libgomp_f.h"
187 #include <ctype.h>
188 diff --git a/libstdc++-v3/configure.host b/libstdc++-v3/configure.host
189 --- a/libstdc++-v3/configure.host
190 +++ b/libstdc++-v3/configure.host
191 @@ -211,12 +211,22 @@
192 os_include_dir="os/bsd/freebsd"
194 gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu)
195 + # check for musl by target
196 + case "${host_os}" in
197 + *-musl*)
198 + os_include_dir="os/generic"
199 + ;;
200 + *)
202 if [ "$uclibc" = "yes" ]; then
203 os_include_dir="os/uclibc"
204 else
205 os_include_dir="os/gnu-linux"
209 + esac
210 + ;;
211 hpux*)
212 os_include_dir="os/hpux"