diff options
Diffstat (limited to 'meta/recipes-devtools/gcc/gcc-5.4/0044-Adding-mmusl-as-a-musl-libc-specifier-and-the-necess.patch')
-rw-r--r-- | meta/recipes-devtools/gcc/gcc-5.4/0044-Adding-mmusl-as-a-musl-libc-specifier-and-the-necess.patch | 270 |
1 files changed, 270 insertions, 0 deletions
diff --git a/meta/recipes-devtools/gcc/gcc-5.4/0044-Adding-mmusl-as-a-musl-libc-specifier-and-the-necess.patch b/meta/recipes-devtools/gcc/gcc-5.4/0044-Adding-mmusl-as-a-musl-libc-specifier-and-the-necess.patch new file mode 100644 index 0000000000..b91c02d0b4 --- /dev/null +++ b/meta/recipes-devtools/gcc/gcc-5.4/0044-Adding-mmusl-as-a-musl-libc-specifier-and-the-necess.patch | |||
@@ -0,0 +1,270 @@ | |||
1 | From 0b54799d80fb859c7b142467e4d42c99db59df50 Mon Sep 17 00:00:00 2001 | ||
2 | From: Khem Raj <raj.khem@gmail.com> | ||
3 | Date: Tue, 8 Dec 2015 08:30:35 +0000 | ||
4 | Subject: [PATCH 44/46] Adding -mmusl as a musl libc specifier, and the | ||
5 | necessary hacks for it to know how to find musl's dynamic linker. | ||
6 | |||
7 | Upstream-Status: Backport [partial] | ||
8 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
9 | --- | ||
10 | gcc/config.gcc | 10 ++++- | ||
11 | gcc/config/linux.h | 100 +++++++++++++++++++++++++++++++++++++----- | ||
12 | gcc/config/linux.opt | 4 ++ | ||
13 | gcc/config/rs6000/secureplt.h | 1 + | ||
14 | gcc/config/rs6000/sysv4.h | 5 +++ | ||
15 | gcc/ginclude/stddef.h | 3 ++ | ||
16 | 6 files changed, 110 insertions(+), 13 deletions(-) | ||
17 | |||
18 | diff --git a/gcc/config.gcc b/gcc/config.gcc | ||
19 | index 3825bd5..39ce047 100644 | ||
20 | --- a/gcc/config.gcc | ||
21 | +++ b/gcc/config.gcc | ||
22 | @@ -575,7 +575,7 @@ case ${target} in | ||
23 | esac | ||
24 | |||
25 | # Common C libraries. | ||
26 | -tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3" | ||
27 | +tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3 LIBC_MUSL=4" | ||
28 | |||
29 | # 32-bit x86 processors supported by --with-arch=. Each processor | ||
30 | # MUST be separated by exactly one space. | ||
31 | @@ -720,6 +720,9 @@ case ${target} in | ||
32 | *-*-*uclibc*) | ||
33 | tm_defines="$tm_defines DEFAULT_LIBC=LIBC_UCLIBC" | ||
34 | ;; | ||
35 | + *-*-*musl*) | ||
36 | + tm_defines="$tm_defines DEFAULT_LIBC=LIBC_MUSL" | ||
37 | + ;; | ||
38 | *) | ||
39 | tm_defines="$tm_defines DEFAULT_LIBC=LIBC_GLIBC" | ||
40 | ;; | ||
41 | @@ -2420,6 +2423,11 @@ powerpc*-*-linux*) | ||
42 | powerpc*-*-linux*paired*) | ||
43 | tm_file="${tm_file} rs6000/750cl.h" ;; | ||
44 | esac | ||
45 | + case ${target} in | ||
46 | + *-linux*-musl*) | ||
47 | + enable_secureplt=yes ;; | ||
48 | + esac | ||
49 | + | ||
50 | if test x${enable_secureplt} = xyes; then | ||
51 | tm_file="rs6000/secureplt.h ${tm_file}" | ||
52 | fi | ||
53 | diff --git a/gcc/config/linux.h b/gcc/config/linux.h | ||
54 | index 22b9be5..ca9a17f 100644 | ||
55 | --- a/gcc/config/linux.h | ||
56 | +++ b/gcc/config/linux.h | ||
57 | @@ -32,10 +32,12 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see | ||
58 | #define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC) | ||
59 | #define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC) | ||
60 | #define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC) | ||
61 | +#define OPTION_MUSL (DEFAULT_LIBC == LIBC_MUSL) | ||
62 | #else | ||
63 | #define OPTION_GLIBC (linux_libc == LIBC_GLIBC) | ||
64 | #define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC) | ||
65 | #define OPTION_BIONIC (linux_libc == LIBC_BIONIC) | ||
66 | +#define OPTION_MUSL (linux_libc == LIBC_MUSL) | ||
67 | #endif | ||
68 | |||
69 | #define GNU_USER_TARGET_OS_CPP_BUILTINS() \ | ||
70 | @@ -53,18 +55,21 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see | ||
71 | uClibc or Bionic is the default C library and whether | ||
72 | -muclibc or -mglibc or -mbionic has been passed to change the default. */ | ||
73 | |||
74 | -#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LD1, LD2, LD3) \ | ||
75 | - "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:" LD1 "}}" | ||
76 | +#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LIBC4, LD1, LD2, LD3, LD4) \ | ||
77 | + "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:%{" LIBC4 ":" LD4 ";:" LD1 "}}}" | ||
78 | |||
79 | #if DEFAULT_LIBC == LIBC_GLIBC | ||
80 | -#define CHOOSE_DYNAMIC_LINKER(G, U, B) \ | ||
81 | - CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", G, U, B) | ||
82 | +#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \ | ||
83 | + CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", "mmusl", G, U, B, M) | ||
84 | #elif DEFAULT_LIBC == LIBC_UCLIBC | ||
85 | -#define CHOOSE_DYNAMIC_LINKER(G, U, B) \ | ||
86 | - CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", U, G, B) | ||
87 | +#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \ | ||
88 | + CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", "mmusl", U, G, B, M) | ||
89 | #elif DEFAULT_LIBC == LIBC_BIONIC | ||
90 | -#define CHOOSE_DYNAMIC_LINKER(G, U, B) \ | ||
91 | - CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", B, G, U) | ||
92 | +#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \ | ||
93 | + CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", "mmusl", B, G, U, M) | ||
94 | +#elif DEFAULT_LIBC == LIBC_MUSL | ||
95 | +#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \ | ||
96 | + CHOOSE_DYNAMIC_LINKER1 ("mmusl", "mglibc", "muclibc", "mbionic", M, G, U, B) | ||
97 | #else | ||
98 | #error "Unsupported DEFAULT_LIBC" | ||
99 | #endif /* DEFAULT_LIBC */ | ||
100 | @@ -84,16 +89,16 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see | ||
101 | |||
102 | #define GNU_USER_DYNAMIC_LINKER \ | ||
103 | CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, \ | ||
104 | - BIONIC_DYNAMIC_LINKER) | ||
105 | + BIONIC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER) | ||
106 | #define GNU_USER_DYNAMIC_LINKER32 \ | ||
107 | CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, \ | ||
108 | - BIONIC_DYNAMIC_LINKER32) | ||
109 | + BIONIC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32) | ||
110 | #define GNU_USER_DYNAMIC_LINKER64 \ | ||
111 | CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, \ | ||
112 | - BIONIC_DYNAMIC_LINKER64) | ||
113 | + BIONIC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64) | ||
114 | #define GNU_USER_DYNAMIC_LINKERX32 \ | ||
115 | CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERX32, UCLIBC_DYNAMIC_LINKERX32, \ | ||
116 | - BIONIC_DYNAMIC_LINKERX32) | ||
117 | + BIONIC_DYNAMIC_LINKERX32, MUSL_DYNAMIC_LINKERX32) | ||
118 | |||
119 | /* Whether we have Bionic libc runtime */ | ||
120 | #undef TARGET_HAS_BIONIC | ||
121 | @@ -123,3 +128,74 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see | ||
122 | # define TARGET_LIBC_HAS_FUNCTION linux_libc_has_function | ||
123 | |||
124 | #endif | ||
125 | + | ||
126 | +/* musl avoids problematic includes by rearranging the include directories. | ||
127 | + * Unfortunately, this is mostly duplicated from cppdefault.c */ | ||
128 | +#if DEFAULT_LIBC == LIBC_MUSL | ||
129 | +#define INCLUDE_DEFAULTS_MUSL_GPP \ | ||
130 | + { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, \ | ||
131 | + GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 }, \ | ||
132 | + { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1, \ | ||
133 | + GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 1 }, \ | ||
134 | + { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, \ | ||
135 | + GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 }, | ||
136 | + | ||
137 | +#ifdef LOCAL_INCLUDE_DIR | ||
138 | +#define INCLUDE_DEFAULTS_MUSL_LOCAL \ | ||
139 | + { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 2 }, \ | ||
140 | + { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 0 }, | ||
141 | +#else | ||
142 | +#define INCLUDE_DEFAULTS_MUSL_LOCAL | ||
143 | +#endif | ||
144 | + | ||
145 | +#ifdef PREFIX_INCLUDE_DIR | ||
146 | +#define INCLUDE_DEFAULTS_MUSL_PREFIX \ | ||
147 | + { PREFIX_INCLUDE_DIR, 0, 0, 1, 0, 0}, | ||
148 | +#else | ||
149 | +#define INCLUDE_DEFAULTS_MUSL_PREFIX | ||
150 | +#endif | ||
151 | + | ||
152 | +#ifdef CROSS_INCLUDE_DIR | ||
153 | +#define INCLUDE_DEFAULTS_MUSL_CROSS \ | ||
154 | + { CROSS_INCLUDE_DIR, "GCC", 0, 0, 0, 0}, | ||
155 | +#else | ||
156 | +#define INCLUDE_DEFAULTS_MUSL_CROSS | ||
157 | +#endif | ||
158 | + | ||
159 | +#ifdef TOOL_INCLUDE_DIR | ||
160 | +#define INCLUDE_DEFAULTS_MUSL_TOOL \ | ||
161 | + { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1, 0, 0}, | ||
162 | +#else | ||
163 | +#define INCLUDE_DEFAULTS_MUSL_TOOL | ||
164 | +#endif | ||
165 | + | ||
166 | +#ifdef NATIVE_SYSTEM_HEADER_DIR | ||
167 | +#define INCLUDE_DEFAULTS_MUSL_NATIVE \ | ||
168 | + { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 2 }, \ | ||
169 | + { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 0 }, | ||
170 | +#else | ||
171 | +#define INCLUDE_DEFAULTS_MUSL_NATIVE | ||
172 | +#endif | ||
173 | + | ||
174 | +#if defined (CROSS_DIRECTORY_STRUCTURE) && !defined (TARGET_SYSTEM_ROOT) | ||
175 | +# undef INCLUDE_DEFAULTS_MUSL_LOCAL | ||
176 | +# define INCLUDE_DEFAULTS_MUSL_LOCAL | ||
177 | +# undef INCLUDE_DEFAULTS_MUSL_NATIVE | ||
178 | +# define INCLUDE_DEFAULTS_MUSL_NATIVE | ||
179 | +#else | ||
180 | +# undef INCLUDE_DEFAULTS_MUSL_CROSS | ||
181 | +# define INCLUDE_DEFAULTS_MUSL_CROSS | ||
182 | +#endif | ||
183 | + | ||
184 | +#undef INCLUDE_DEFAULTS | ||
185 | +#define INCLUDE_DEFAULTS \ | ||
186 | + { \ | ||
187 | + INCLUDE_DEFAULTS_MUSL_GPP \ | ||
188 | + INCLUDE_DEFAULTS_MUSL_PREFIX \ | ||
189 | + INCLUDE_DEFAULTS_MUSL_CROSS \ | ||
190 | + INCLUDE_DEFAULTS_MUSL_TOOL \ | ||
191 | + INCLUDE_DEFAULTS_MUSL_NATIVE \ | ||
192 | + { GCC_INCLUDE_DIR, "GCC", 0, 1, 0, 0 }, \ | ||
193 | + { 0, 0, 0, 0, 0, 0 } \ | ||
194 | + } | ||
195 | +#endif | ||
196 | diff --git a/gcc/config/linux.opt b/gcc/config/linux.opt | ||
197 | index c054338..9334f74 100644 | ||
198 | --- a/gcc/config/linux.opt | ||
199 | +++ b/gcc/config/linux.opt | ||
200 | @@ -30,3 +30,7 @@ Use GNU C library | ||
201 | muclibc | ||
202 | Target Report RejectNegative Var(linux_libc,LIBC_UCLIBC) Negative(mbionic) | ||
203 | Use uClibc C library | ||
204 | + | ||
205 | +mmusl | ||
206 | +Target Report RejectNegative Var(linux_libc,LIBC_MUSL) Negative(mglibc) | ||
207 | +Use musl C library | ||
208 | diff --git a/gcc/config/rs6000/secureplt.h b/gcc/config/rs6000/secureplt.h | ||
209 | index b463463..77edf2a 100644 | ||
210 | --- a/gcc/config/rs6000/secureplt.h | ||
211 | +++ b/gcc/config/rs6000/secureplt.h | ||
212 | @@ -18,3 +18,4 @@ along with GCC; see the file COPYING3. If not see | ||
213 | <http://www.gnu.org/licenses/>. */ | ||
214 | |||
215 | #define CC1_SECURE_PLT_DEFAULT_SPEC "-msecure-plt" | ||
216 | +#define LINK_SECURE_PLT_DEFAULT_SPEC "--secure-plt" | ||
217 | diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h | ||
218 | index c6c31dc..7cd07e0 100644 | ||
219 | --- a/gcc/config/rs6000/sysv4.h | ||
220 | +++ b/gcc/config/rs6000/sysv4.h | ||
221 | @@ -538,6 +538,10 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN) | ||
222 | #define CC1_SECURE_PLT_DEFAULT_SPEC "" | ||
223 | #endif | ||
224 | |||
225 | +#ifndef LINK_SECURE_PLT_DEFAULT_SPEC | ||
226 | +#define LINK_SECURE_PLT_DEFAULT_SPEC "" | ||
227 | +#endif | ||
228 | + | ||
229 | /* Pass -G xxx to the compiler. */ | ||
230 | #undef CC1_SPEC | ||
231 | #define CC1_SPEC "%{G*} %(cc1_cpu)" \ | ||
232 | @@ -889,6 +893,7 @@ ncrtn.o%s" | ||
233 | { "link_os_openbsd", LINK_OS_OPENBSD_SPEC }, \ | ||
234 | { "link_os_default", LINK_OS_DEFAULT_SPEC }, \ | ||
235 | { "cc1_secure_plt_default", CC1_SECURE_PLT_DEFAULT_SPEC }, \ | ||
236 | + { "link_secure_plt_default", LINK_SECURE_PLT_DEFAULT_SPEC }, \ | ||
237 | { "cpp_os_ads", CPP_OS_ADS_SPEC }, \ | ||
238 | { "cpp_os_yellowknife", CPP_OS_YELLOWKNIFE_SPEC }, \ | ||
239 | { "cpp_os_mvme", CPP_OS_MVME_SPEC }, \ | ||
240 | diff --git a/gcc/ginclude/stddef.h b/gcc/ginclude/stddef.h | ||
241 | index f20a41b..eb879ef 100644 | ||
242 | --- a/gcc/ginclude/stddef.h | ||
243 | +++ b/gcc/ginclude/stddef.h | ||
244 | @@ -184,6 +184,7 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t; | ||
245 | #ifndef _GCC_SIZE_T | ||
246 | #ifndef _SIZET_ | ||
247 | #ifndef __size_t | ||
248 | +#ifndef __DEFINED_size_t /* musl */ | ||
249 | #define __size_t__ /* BeOS */ | ||
250 | #define __SIZE_T__ /* Cray Unicos/Mk */ | ||
251 | #define _SIZE_T | ||
252 | @@ -200,6 +201,7 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t; | ||
253 | #define ___int_size_t_h | ||
254 | #define _GCC_SIZE_T | ||
255 | #define _SIZET_ | ||
256 | +#define __DEFINED_size_t /* musl */ | ||
257 | #if (defined (__FreeBSD__) && (__FreeBSD__ >= 5)) \ | ||
258 | || defined(__DragonFly__) \ | ||
259 | || defined(__FreeBSD_kernel__) | ||
260 | @@ -218,6 +220,7 @@ typedef __SIZE_TYPE__ size_t; | ||
261 | typedef long ssize_t; | ||
262 | #endif /* __BEOS__ */ | ||
263 | #endif /* !(defined (__GNUG__) && defined (size_t)) */ | ||
264 | +#endif /* __DEFINED_size_t */ | ||
265 | #endif /* __size_t */ | ||
266 | #endif /* _SIZET_ */ | ||
267 | #endif /* _GCC_SIZE_T */ | ||
268 | -- | ||
269 | 2.6.3 | ||
270 | |||