configs/imx6ulpico: Use common script for image generation
[buildroot-gz.git] / package / gcc / 5.4.0 / 904-musl-libc-config.patch
blob85491406cf7f39bab940d0ea37fc2b597f2577ba
1 From: ktkachov <ktkachov@138bc75d-0d04-0410-961f-82ee72b054a4>
2 Date: Fri, 8 May 2015 08:25:47 +0000 (+0000)
3 Subject: [PATCH 2/13] musl libc config
4 X-Git-Url: https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff_plain;h=a9173ceabaf29c16f8ef226fbf98af373a4b2ceb
6 [PATCH 2/13] musl libc config
8 2015-05-08 Gregor Richards <gregor.richards@uwaterloo.ca>
9 Szabolcs Nagy <szabolcs.nagy@arm.com>
11 * config.gcc (LIBC_MUSL): New tm_defines macro.
12 * config/linux.h (OPTION_MUSL): Define.
13 (MUSL_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER32,)
14 (MUSL_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKERX32,)
15 (INCLUDE_DEFAULTS_MUSL_GPP, INCLUDE_DEFAULTS_MUSL_LOCAL,)
16 (INCLUDE_DEFAULTS_MUSL_PREFIX, INCLUDE_DEFAULTS_MUSL_CROSS,)
17 (INCLUDE_DEFAULTS_MUSL_TOOL, INCLUDE_DEFAULTS_MUSL_NATIVE): Define.
18 * config/linux.opt (mmusl): New option.
19 * doc/invoke.texi (GNU/Linux Options): Document -mmusl.
20 * configure.ac (gcc_cv_libc_provides_ssp): Add *-*-musl*.
21 (gcc_cv_target_dl_iterate_phdr): Add *-linux-musl*.
22 * configure: Regenerate.
25 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@222904 138bc75d-0d04-0410-961f-82ee72b054a4
26 ---
28 Index: b/gcc/config.gcc
29 ===================================================================
30 --- a/gcc/config.gcc
31 +++ b/gcc/config.gcc
32 @@ -575,7 +575,7 @@
33 esac
35 # Common C libraries.
36 -tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3"
37 +tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3 LIBC_MUSL=4"
39 # 32-bit x86 processors supported by --with-arch=. Each processor
40 # MUST be separated by exactly one space.
41 @@ -720,6 +720,9 @@
42 *-*-*uclibc*)
43 tm_defines="$tm_defines DEFAULT_LIBC=LIBC_UCLIBC"
45 + *-*-*musl*)
46 + tm_defines="$tm_defines DEFAULT_LIBC=LIBC_MUSL"
47 + ;;
49 tm_defines="$tm_defines DEFAULT_LIBC=LIBC_GLIBC"
51 Index: b/gcc/config/linux.h
52 ===================================================================
53 --- a/gcc/config/linux.h
54 +++ b/gcc/config/linux.h
55 @@ -32,10 +32,12 @@
56 #define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC)
57 #define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
58 #define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
59 +#define OPTION_MUSL (DEFAULT_LIBC == LIBC_MUSL)
60 #else
61 #define OPTION_GLIBC (linux_libc == LIBC_GLIBC)
62 #define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC)
63 #define OPTION_BIONIC (linux_libc == LIBC_BIONIC)
64 +#define OPTION_MUSL (linux_libc == LIBC_MUSL)
65 #endif
67 #define GNU_USER_TARGET_OS_CPP_BUILTINS() \
68 @@ -50,21 +52,25 @@
69 } while (0)
71 /* Determine which dynamic linker to use depending on whether GLIBC or
72 - uClibc or Bionic is the default C library and whether
73 - -muclibc or -mglibc or -mbionic has been passed to change the default. */
74 + uClibc or Bionic or musl is the default C library and whether
75 + -muclibc or -mglibc or -mbionic or -mmusl has been passed to change
76 + the default. */
78 -#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LD1, LD2, LD3) \
79 - "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:" LD1 "}}"
80 +#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LIBC4, LD1, LD2, LD3, LD4) \
81 + "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:%{" LIBC4 ":" LD4 ";:" LD1 "}}}"
83 #if DEFAULT_LIBC == LIBC_GLIBC
84 -#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
85 - CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", G, U, B)
86 +#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
87 + CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", "mmusl", G, U, B, M)
88 #elif DEFAULT_LIBC == LIBC_UCLIBC
89 -#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
90 - CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", U, G, B)
91 +#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
92 + CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", "mmusl", U, G, B, M)
93 #elif DEFAULT_LIBC == LIBC_BIONIC
94 -#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
95 - CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", B, G, U)
96 +#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
97 + CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", "mmusl", B, G, U, M)
98 +#elif DEFAULT_LIBC == LIBC_MUSL
99 +#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
100 + CHOOSE_DYNAMIC_LINKER1 ("mmusl", "mglibc", "muclibc", "mbionic", M, G, U, B)
101 #else
102 #error "Unsupported DEFAULT_LIBC"
103 #endif /* DEFAULT_LIBC */
104 @@ -81,24 +87,100 @@
105 #define BIONIC_DYNAMIC_LINKER32 "/system/bin/linker"
106 #define BIONIC_DYNAMIC_LINKER64 "/system/bin/linker64"
107 #define BIONIC_DYNAMIC_LINKERX32 "/system/bin/linkerx32"
108 +/* Should be redefined for each target that supports musl. */
109 +#define MUSL_DYNAMIC_LINKER "/dev/null"
110 +#define MUSL_DYNAMIC_LINKER32 "/dev/null"
111 +#define MUSL_DYNAMIC_LINKER64 "/dev/null"
112 +#define MUSL_DYNAMIC_LINKERX32 "/dev/null"
114 #define GNU_USER_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 GNU_USER_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 GNU_USER_DYNAMIC_LINKER64 \
123 CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, \
124 - BIONIC_DYNAMIC_LINKER64)
125 + BIONIC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64)
126 #define GNU_USER_DYNAMIC_LINKERX32 \
127 CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERX32, UCLIBC_DYNAMIC_LINKERX32, \
128 - BIONIC_DYNAMIC_LINKERX32)
129 + BIONIC_DYNAMIC_LINKERX32, MUSL_DYNAMIC_LINKERX32)
131 /* Whether we have Bionic libc runtime */
132 #undef TARGET_HAS_BIONIC
133 #define TARGET_HAS_BIONIC (OPTION_BIONIC)
135 +/* musl avoids problematic includes by rearranging the include directories.
136 + * Unfortunately, this is mostly duplicated from cppdefault.c */
137 +#if DEFAULT_LIBC == LIBC_MUSL
138 +#define INCLUDE_DEFAULTS_MUSL_GPP \
139 + { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, \
140 + GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 }, \
141 + { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1, \
142 + GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 1 }, \
143 + { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, \
144 + GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 },
146 +#ifdef LOCAL_INCLUDE_DIR
147 +#define INCLUDE_DEFAULTS_MUSL_LOCAL \
148 + { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 2 }, \
149 + { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 0 },
150 +#else
151 +#define INCLUDE_DEFAULTS_MUSL_LOCAL
152 +#endif
154 +#ifdef PREFIX_INCLUDE_DIR
155 +#define INCLUDE_DEFAULTS_MUSL_PREFIX \
156 + { PREFIX_INCLUDE_DIR, 0, 0, 1, 0, 0},
157 +#else
158 +#define INCLUDE_DEFAULTS_MUSL_PREFIX
159 +#endif
161 +#ifdef CROSS_INCLUDE_DIR
162 +#define INCLUDE_DEFAULTS_MUSL_CROSS \
163 + { CROSS_INCLUDE_DIR, "GCC", 0, 0, 0, 0},
164 +#else
165 +#define INCLUDE_DEFAULTS_MUSL_CROSS
166 +#endif
168 +#ifdef TOOL_INCLUDE_DIR
169 +#define INCLUDE_DEFAULTS_MUSL_TOOL \
170 + { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1, 0, 0},
171 +#else
172 +#define INCLUDE_DEFAULTS_MUSL_TOOL
173 +#endif
175 +#ifdef NATIVE_SYSTEM_HEADER_DIR
176 +#define INCLUDE_DEFAULTS_MUSL_NATIVE \
177 + { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 2 }, \
178 + { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 0 },
179 +#else
180 +#define INCLUDE_DEFAULTS_MUSL_NATIVE
181 +#endif
183 +#if defined (CROSS_DIRECTORY_STRUCTURE) && !defined (TARGET_SYSTEM_ROOT)
184 +# undef INCLUDE_DEFAULTS_MUSL_LOCAL
185 +# define INCLUDE_DEFAULTS_MUSL_LOCAL
186 +# undef INCLUDE_DEFAULTS_MUSL_NATIVE
187 +# define INCLUDE_DEFAULTS_MUSL_NATIVE
188 +#else
189 +# undef INCLUDE_DEFAULTS_MUSL_CROSS
190 +# define INCLUDE_DEFAULTS_MUSL_CROSS
191 +#endif
193 +#undef INCLUDE_DEFAULTS
194 +#define INCLUDE_DEFAULTS \
195 + { \
196 + INCLUDE_DEFAULTS_MUSL_GPP \
197 + INCLUDE_DEFAULTS_MUSL_PREFIX \
198 + INCLUDE_DEFAULTS_MUSL_CROSS \
199 + INCLUDE_DEFAULTS_MUSL_TOOL \
200 + INCLUDE_DEFAULTS_MUSL_NATIVE \
201 + { GCC_INCLUDE_DIR, "GCC", 0, 1, 0, 0 }, \
202 + { 0, 0, 0, 0, 0, 0 } \
204 +#endif
206 #if (DEFAULT_LIBC == LIBC_UCLIBC) && defined (SINGLE_LIBC) /* uClinux */
207 /* This is a *uclinux* target. We don't define below macros to normal linux
208 versions, because doing so would require *uclinux* targets to include
209 Index: b/gcc/config/linux.opt
210 ===================================================================
211 --- a/gcc/config/linux.opt
212 +++ b/gcc/config/linux.opt
213 @@ -28,5 +28,9 @@
214 Use GNU C library
216 muclibc
217 -Target Report RejectNegative Var(linux_libc,LIBC_UCLIBC) Negative(mbionic)
218 +Target Report RejectNegative Var(linux_libc,LIBC_UCLIBC) Negative(mmusl)
219 Use uClibc C library
221 +mmusl
222 +Target Report RejectNegative Var(linux_libc,LIBC_MUSL) Negative(mbionic)
223 +Use musl C library
224 Index: b/gcc/configure
225 ===================================================================
226 --- a/gcc/configure
227 +++ b/gcc/configure
228 @@ -27809,6 +27813,9 @@
229 gcc_cv_target_dl_iterate_phdr=no
232 + *-linux-musl*)
233 + gcc_cv_target_dl_iterate_phdr=yes
234 + ;;
235 esac
237 if test x$gcc_cv_target_dl_iterate_phdr = xyes; then
238 Index: b/gcc/configure.ac
239 ===================================================================
240 --- a/gcc/configure.ac
241 +++ b/gcc/configure.ac
242 @@ -5298,6 +5302,9 @@
243 gcc_cv_target_dl_iterate_phdr=no
246 + *-linux-musl*)
247 + gcc_cv_target_dl_iterate_phdr=yes
248 + ;;
249 esac
250 GCC_TARGET_TEMPLATE([TARGET_DL_ITERATE_PHDR])
251 if test x$gcc_cv_target_dl_iterate_phdr = xyes; then
252 Index: b/gcc/doc/invoke.texi
253 ===================================================================
254 --- a/gcc/doc/invoke.texi
255 +++ b/gcc/doc/invoke.texi
256 @@ -667,7 +667,7 @@
257 -mcpu=@var{cpu}}
259 @emph{GNU/Linux Options}
260 -@gccoptlist{-mglibc -muclibc -mbionic -mandroid @gol
261 +@gccoptlist{-mglibc -muclibc -mmusl -mbionic -mandroid @gol
262 -tno-android-cc -tno-android-ld}
264 @emph{H8/300 Options}
265 @@ -15324,13 +15324,19 @@
266 @item -mglibc
267 @opindex mglibc
268 Use the GNU C library. This is the default except
269 -on @samp{*-*-linux-*uclibc*} and @samp{*-*-linux-*android*} targets.
270 +on @samp{*-*-linux-*uclibc*}, @samp{*-*-linux-*musl*} and
271 +@samp{*-*-linux-*android*} targets.
273 @item -muclibc
274 @opindex muclibc
275 Use uClibc C library. This is the default on
276 @samp{*-*-linux-*uclibc*} targets.
278 +@item -mmusl
279 +@opindex mmusl
280 +Use the musl C library. This is the default on
281 +@samp{*-*-linux-*musl*} targets.
283 @item -mbionic
284 @opindex mbionic
285 Use Bionic C library. This is the default on