summaryrefslogtreecommitdiffstats
path: root/meta-oe/recipes-devtools/gcc/gcc-4.5/linaro/gcc-4.5-linaro-r99494.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta-oe/recipes-devtools/gcc/gcc-4.5/linaro/gcc-4.5-linaro-r99494.patch')
-rw-r--r--meta-oe/recipes-devtools/gcc/gcc-4.5/linaro/gcc-4.5-linaro-r99494.patch1272
1 files changed, 1272 insertions, 0 deletions
diff --git a/meta-oe/recipes-devtools/gcc/gcc-4.5/linaro/gcc-4.5-linaro-r99494.patch b/meta-oe/recipes-devtools/gcc/gcc-4.5/linaro/gcc-4.5-linaro-r99494.patch
new file mode 100644
index 0000000000..56897e984b
--- /dev/null
+++ b/meta-oe/recipes-devtools/gcc/gcc-4.5/linaro/gcc-4.5-linaro-r99494.patch
@@ -0,0 +1,1272 @@
12011-04-09 Andrew Stubbs <ams@codesourcery.com>
2
3 Backport from mainline:
4
5 Maxim Kuvyrkov <maxim@codesourcery.com>
6
7 * config.sub: Recognize *-linux-android*.
8
9 2010-05-27 Maxim Kuvyrkov <maxim@codesourcery.com>
10
11 Add support for Bionic C library
12 gcc/
13 * config.gcc (LIBC_GLIBC, LIBC_BIONIC, LIBC_UCLIBC): New tm_define
14 macro.
15 (DEFAULT_LIBC): New tm_define macro set to one of LIBC_*.
16 (bfin*-uclinux, moxie-*-uclinux*, m68k-*-uclinux*): Update.
17
18 * config/linux.h (OPTION_GLIBC, OPTION_UCLIBC, OPTION_BIONIC): Define.
19 (LINUX_TARGET_OS_CPP_BUILTINS): Define __gnu_linux__ only for GLIBC.
20 (CHOOSE_DYNAMIC_LINKER1, CHOOSE_DYNAMIC_LINKER): Make it easier
21 to support multiple C libraries. Handle Bionic.
22 (BIONIC_DYNAMIC_LINKER, BIONIC_DYNAMIC_LINKER32,)
23 (BIONIC_DYNAMIC_LINKER64): Define.
24 (LINUX_DYNAMIC_LINKER, LINUX_DYNAMIC_LINKER32, LINUX_DYNAMIC_LINKER64):
25 Update.
26 (TARGET_HAS_SINCOS): Enable for Bionic.
27
28 * config/linux.opt: Rewrite to handle more than 2 C libraries. Make
29 the last option specified on command line take effect.
30 (linux_uclibc): Rename to linux_libc, initialize using DEFAULT_LIBC.
31 (mbionic): New.
32 (mglibc, muclibc): Update.
33
34 * config/alpha/linux-elf.h, config/rs6000/linux64.h,
35 * config/rs6000/sysv4.h (CHOOSE_DYNAMIC_LINKER): Update to use
36 DEFAULT_LIBC.
37
38 * doc/invoke.texi (-mglibc, -muclibc): Update.
39 (-mbionic): Document.
40
41 gcc/testsuite/
42 * gcc.dg/glibc-uclibc-1.c, gcc.dg/glibc-uclibc-2.c: Remove, no longer
43 necessary.
44
45 2010-05-27 Maxim Kuvyrkov <maxim@codesourcery.com>
46
47 Support compilation for Android platform. Reimplement -mandroid.
48 gcc/
49 * config.gcc (*linux*): Include linux-android.h and linux-android.opt.
50 (*android*): Set ANDROID_DEFAULT.
51 (arm*-*-linux*): Include linux-android.h.
52 (arm*-*-eabi*): Don't include previous -mandroid implementation.
53 * config/arm/eabi.h: Remove, move Android-specific parts ...
54 * config/linux-android.h: ... here. New file.
55 * config/arm/eabi.opt: Rename to ...
56 * config/linux-android.opt: ... this.
57 (mandroid): Allow -mno-android option. Initialize based on
58 ANDROID_DEFAULT.
59 * config/linux.h (STARTFILE_SPEC, ENDFILE_SPEC, CC1_SPEC, LIB_SPEC):
60 Move logic to corresponding LINUX_TARGET_* macros.
61 (TARGET_OS_CPP_BUILTINS): Define __ANDROID__, when appropriate.
62 * config/linux-eabi.h (LINK_SPEC, CC1_SPEC, CC1PLUS_SPEC, LIB_SPEC,)
63 (STARTFILE_SPEC, ENDFILE_SPEC): Define to choose between Linux and
64 Android definitions.
65 (LINUX_TARGET_OS_CPP_BUILTINS): Define __ANDROID__ if TARGET_ANDROID.
66 * doc/invoke.texi (-mandroid, -tno-android-cc, -tno-android-ld):
67 Document.
68
69 2010-06-01 Maxim Kuvyrkov <maxim@codesourcery.com>
70
71 gcc/
72 * config/arm/t-linux-androideabi: New.
73 * config.gcc (arm*-*-linux-androideabi): Include multilib configuration.
74
75 2010-05-27 Maxim Kuvyrkov <maxim@codesourcery.com>
76
77 gcc/
78 * gthr-posix.h (pthread_cancel): Don't declare if compiling against
79 Bionic C library.
80 (__gthread_active_p): Check for pthread_create if compiling against
81 Bionic C library.
82
83 2010-06-01 Maxim Kuvyrkov <maxim@codesourcery.com>
84
85 libstdc++-v3/
86 * acinclude.m4: Support Bionic C library.
87 Explicitly specify -fexceptions for exception check.
88 * configure.host: Support Bionic C library.
89 * configure: Regenerate.
90 * config/os/bionic/ctype_base.h, config/os/bionic/ctype_inline.h,
91 * config/os/bionic/ctype_noincline.h, config/os/bionic/os_defines.h:
92 New files, based on config/os/newlib/*.
93
94=== modified file 'config.sub'
95Index: gcc-4.5.3/config.sub
96===================================================================
97--- gcc-4.5.3.orig/config.sub
98+++ gcc-4.5.3/config.sub
99@@ -4,7 +4,7 @@
100 # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
101 # Free Software Foundation, Inc.
102
103-timestamp='2010-03-22'
104+timestamp='2010-04-23'
105
106 # This file is (in principle) common to ALL GNU software.
107 # The presence of a machine in this file suggests that SOME GNU software
108@@ -124,8 +124,9 @@ esac
109 # Here we must recognize all the valid KERNEL-OS combinations.
110 maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
111 case $maybe_os in
112- nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
113- uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
114+ nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
115+ linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
116+ knetbsd*-gnu* | netbsd*-gnu* | \
117 kopensolaris*-gnu* | \
118 storm-chaos* | os2-emx* | rtmk-nova*)
119 os=-$maybe_os
120@@ -1307,7 +1308,8 @@ case $os in
121 | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
122 | -chorusos* | -chorusrdb* | -cegcc* \
123 | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
124- | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
125+ | -mingw32* | -linux-gnu* | -linux-android* \
126+ | -linux-newlib* | -linux-uclibc* \
127 | -uxpv* | -beos* | -mpeix* | -udk* \
128 | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
129 | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
130Index: gcc-4.5.3/gcc/config.gcc
131===================================================================
132--- gcc-4.5.3.orig/gcc/config.gcc
133+++ gcc-4.5.3/gcc/config.gcc
134@@ -513,26 +513,48 @@ case ${target} in
135 *-*-gnu*)
136 tmake_file="$tmake_file t-gnu";;
137 esac
138- # glibc / uclibc switch. uclibc isn't usable for GNU/Hurd and neither for
139- # GNU/k*BSD.
140+ # Common C libraries.
141+ tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3"
142+ # glibc / uclibc / bionic switch.
143+ # uclibc and bionic aren't usable for GNU/Hurd and neither for GNU/k*BSD.
144 case $target in
145 *linux*)
146 extra_options="$extra_options linux.opt";;
147 *)
148 tm_defines="$tm_defines OPTION_GLIBC=1";;
149 esac
150- case ${target} in
151+ case $target in
152+ *-*-*android*)
153+ tm_defines="$tm_defines DEFAULT_LIBC=LIBC_BIONIC"
154+ ;;
155 *-*-*uclibc*)
156- tm_defines="${tm_defines} UCLIBC_DEFAULT=1"
157+ tm_defines="$tm_defines DEFAULT_LIBC=LIBC_UCLIBC"
158 ;;
159 *)
160- tm_defines="${tm_defines} UCLIBC_DEFAULT=0"
161+ tm_defines="$tm_defines DEFAULT_LIBC=LIBC_GLIBC"
162 ;;
163 esac
164- # Assume that glibc or uClibc are being used and so __cxa_atexit is provided.
165+ # Assume that glibc or uClibc or Bionic are being used and so __cxa_atexit
166+ # is provided.
167 default_use_cxa_atexit=yes
168 use_gcc_tgmath=no
169 use_gcc_stdint=wrap
170+ # Add Android userspace support to Linux targets.
171+ case $target in
172+ *linux*)
173+ tm_file="$tm_file linux-android.h"
174+ extra_options="$extra_options linux-android.opt"
175+ ;;
176+ esac
177+ # Enable compilation for Android by default for *android* targets.
178+ case $target in
179+ *-*-*android*)
180+ tm_defines="$tm_defines ANDROID_DEFAULT=1"
181+ ;;
182+ *)
183+ tm_defines="$tm_defines ANDROID_DEFAULT=0"
184+ ;;
185+ esac
186 ;;
187 *-*-netbsd*)
188 tmake_file="t-slibgcc-elf-ver t-libc-ok t-netbsd t-libgcc-pic"
189@@ -728,7 +750,7 @@ arm*-*-netbsd*)
190 use_collect2=yes
191 ;;
192 arm*-*-linux*) # ARM GNU/Linux with ELF
193- tm_file="dbxelf.h elfos.h linux.h glibc-stdint.h arm/elf.h arm/linux-gas.h arm/linux-elf.h"
194+ tm_file="dbxelf.h elfos.h linux.h linux-android.h glibc-stdint.h arm/elf.h arm/linux-gas.h arm/linux-elf.h"
195 case $target in
196 arm*b-*)
197 tm_defines="${tm_defines} TARGET_BIG_ENDIAN_DEFAULT=1"
198@@ -739,6 +761,12 @@ arm*-*-linux*) # ARM GNU/Linux with EL
199 arm*-*-linux-*eabi)
200 tm_file="$tm_file arm/bpabi.h arm/linux-eabi.h"
201 tmake_file="$tmake_file arm/t-arm-elf arm/t-bpabi arm/t-linux-eabi t-slibgcc-libgcc"
202+ # Define multilib configuration for arm-linux-androideabi.
203+ case ${target} in
204+ *-androideabi)
205+ tmake_file="$tmake_file arm/t-linux-androideabi"
206+ ;;
207+ esac
208 # The BPABI long long divmod functions return a 128-bit value in
209 # registers r0-r3. Correctly modeling that requires the use of
210 # TImode.
211@@ -785,9 +813,8 @@ arm*-*-eabi* | arm*-*-symbianelf* )
212 tmake_file="arm/t-arm arm/t-arm-elf"
213 case ${target} in
214 arm*-*-eabi*)
215- tm_file="$tm_file arm/eabi.h newlib-stdint.h"
216+ tm_file="$tm_file newlib-stdint.h"
217 tmake_file="${tmake_file} arm/t-bpabi"
218- extra_options="${extra_options} arm/eabi.opt"
219 use_gcc_stdint=wrap
220 ;;
221 arm*-*-symbianelf*)
222@@ -843,7 +870,7 @@ bfin*-elf*)
223 bfin*-uclinux*)
224 tm_file="${tm_file} dbxelf.h elfos.h bfin/elf.h linux.h glibc-stdint.h bfin/uclinux.h"
225 tmake_file=bfin/t-bfin-uclinux
226- tm_defines="${tm_defines} UCLIBC_DEFAULT=1"
227+ tm_defines="${tm_defines} DEFAULT_LIBC=LIBC_UCLIBC"
228 extra_options="${extra_options} linux.opt"
229 use_collect2=no
230 ;;
231@@ -924,7 +951,7 @@ moxie-*-uclinux*)
232 tm_file="dbxelf.h elfos.h svr4.h ${tm_file} linux.h glibc-stdint.h moxie/uclinux.h"
233 extra_parts="crti.o crtn.o crtbegin.o crtend.o"
234 tmake_file="${tmake_file} moxie/t-moxie moxie/t-moxie-softfp soft-fp/t-softfp"
235- tm_defines="${tm_defines} UCLIBC_DEFAULT=1"
236+ tm_defines="${tm_defines} DEFAULT_LIBC=LIBC_UCLIBC"
237 extra_options="${extra_options} linux.opt"
238 ;;
239 h8300-*-rtems*)
240@@ -1644,7 +1671,7 @@ m68k-*-uclinux*) # Motorola m68k/ColdFi
241 default_m68k_cpu=68020
242 default_cf_cpu=5206
243 tm_file="${tm_file} dbxelf.h elfos.h svr4.h linux.h glibc-stdint.h flat.h m68k/linux.h m68k/uclinux.h ./sysroot-suffix.h"
244- tm_defines="${tm_defines} MOTOROLA=1 UCLIBC_DEFAULT=1"
245+ tm_defines="${tm_defines} MOTOROLA=1 DEFAULT_LIBC=LIBC_UCLIBC"
246 extra_options="${extra_options} linux.opt"
247 tmake_file="m68k/t-floatlib m68k/t-uclinux m68k/t-mlibs"
248 ;;
249Index: gcc-4.5.3/gcc/config/alpha/linux-elf.h
250===================================================================
251--- gcc-4.5.3.orig/gcc/config/alpha/linux-elf.h
252+++ gcc-4.5.3/gcc/config/alpha/linux-elf.h
253@@ -29,10 +29,12 @@ along with GCC; see the file COPYING3.
254
255 #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
256 #define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
257-#if UCLIBC_DEFAULT
258-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:%{muclibc:%e-mglibc and -muclibc used together}" G ";:" U "}"
259+#if DEFAULT_LIBC == LIBC_UCLIBC
260+#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
261+#elif DEFAULT_LIBC == LIBC_GLIBC
262+#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}"
263 #else
264-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:%{mglibc:%e-mglibc and -muclibc used together}" U ";:" G "}"
265+#error "Unsupported DEFAULT_LIBC"
266 #endif
267 #define LINUX_DYNAMIC_LINKER \
268 CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER)
269Index: gcc-4.5.3/gcc/config/arm/eabi.h
270===================================================================
271--- gcc-4.5.3.orig/gcc/config/arm/eabi.h
272+++ /dev/null
273@@ -1,125 +0,0 @@
274-/* Configuration file for ARM EABI targets.
275- Copyright (C) 2008
276- Free Software Foundation, Inc.
277- Contributed by Doug Kwan (dougkwan@google.com)
278-
279- This file is part of GCC.
280-
281- GCC is free software; you can redistribute it and/or modify it
282- under the terms of the GNU General Public License as published
283- by the Free Software Foundation; either version 3, or (at your
284- option) any later version.
285-
286- GCC is distributed in the hope that it will be useful, but WITHOUT
287- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
288- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
289- License for more details.
290-
291- You should have received a copy of the GNU General Public License
292- along with GCC; see the file COPYING3. If not see
293- <http://www.gnu.org/licenses/>. */
294-
295-/* This file contains macro overrides for EABI targets. */
296-
297-#undef TARGET_OS_CPP_BUILTINS
298-#define TARGET_OS_CPP_BUILTINS() \
299- do \
300- { \
301- TARGET_BPABI_CPP_BUILTINS (); \
302- if (TARGET_ANDROID) \
303- builtin_define ("__ANDROID__"); \
304- } \
305- while (false)
306-
307-#undef SUBSUBTARGET_EXTRA_SPECS
308-#define SUBSUBTARGET_EXTRA_SPECS \
309- { "link_android", ANDROID_LINK_SPEC }, \
310- { "link_default", BPABI_LINK_SPEC }, \
311- { "cc1_android", ANDROID_CC1_SPEC }, \
312- { "cc1_default", CC1_DEFAULT_SPEC }, \
313- { "cc1plus_android", ANDROID_CC1PLUS_SPEC }, \
314- { "cc1plus_default", CC1PLUS_DEFAULT_SPEC }, \
315- { "lib_android", ANDROID_LIB_SPEC }, \
316- { "lib_default", LIB_DEFAULT_SPEC }, \
317- { "startfile_android", ANDROID_STARTFILE_SPEC }, \
318- { "startfile_default", UNKNOWN_ELF_STARTFILE_SPEC }, \
319- { "endfile_android", ANDROID_ENDFILE_SPEC }, \
320- { "endfile_default", UNKNOWN_ELF_ENDFILE_SPEC }, \
321-
322-#undef ANDROID_LINK_SPEC
323-#define ANDROID_LINK_SPEC \
324-"%{mbig-endian:-EB} %{mlittle-endian:-EL} " \
325-"%{static:-Bstatic} %{shared:-shared} %{symbolic:-Bsymbolic} " \
326-"%{!static:" \
327- "%{shared: -Bsymbolic} " \
328- "%{!shared:" \
329- "%{rdynamic:-export-dynamic} " \
330- "%{!dynamic-linker:-dynamic-linker /system/bin/linker}}} " \
331-"-X" SUBTARGET_EXTRA_LINK_SPEC
332-
333-/* Override LINK_SPEC in bpabi.h. */
334-#undef LINK_SPEC
335-#define LINK_SPEC \
336-"%{mandroid: %(link_android) ;" \
337-" : %(link_default)}"
338-
339-/* Android uses -fno-exceptions by default. */
340-#undef ANDROID_CC1_SPEC
341-#define ANDROID_CC1_SPEC "%{!fexceptions:-fno-exceptions}"
342-
343-/* Default CC1_SPEC as in arm.h. */
344-#undef CC1_DEFAULT_SPEC
345-#define CC1_DEFAULT_SPEC ""
346-
347-#undef CC1_SPEC
348-#define CC1_SPEC \
349-"%{mandroid: %(cc1_android) ;" \
350-" : %(cc1_default)}"
351-
352-/* Android uses -fno-rtti by default. */
353-#undef ANDROID_CC1PLUS_SPEC
354-#define ANDROID_CC1PLUS_SPEC "%{!frtti:-fno-rtti}"
355-
356-/* Default CC1PLUS_SPEC as in gcc.c. */
357-#undef CC1PLUS_DEFAULT_SPEC
358-#define CC1PLUS_DEFAULT_SPEC ""
359-
360-#undef CC1PLUS_SPEC
361-#define CC1PLUS_SPEC \
362-"%{mandroid: %(cc1plus_android) ;" \
363-" : %(cc1plus_default)}"
364-
365-#undef ANDROID_LIB_SPEC
366-#define ANDROID_LIB_SPEC "-lc %{!static:-ldl}"
367-
368-/* Default LIB_SPEC as in gcc.c. */
369-#undef LIB_DEFAULT_SPEC
370-#define LIB_DEFAULT_SPEC \
371-"%{!shared:%{g*:-lg} %{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}}"
372-
373-#undef LIB_SPEC
374-#define LIB_SPEC \
375-"%{mandroid: %(lib_android) ;" \
376-" : %(lib_default)}"
377-
378-#undef ANDROID_STARTFILE_SPEC
379-#define ANDROID_STARTFILE_SPEC \
380-"%{!shared:" \
381- "%{static: crtbegin_static%O%s ;" \
382- " : crtbegin_dynamic%O%s}}"
383-
384-/* Override STARTFILE_SPEC in unknown-elf.h. */
385-#undef STARTFILE_SPEC
386-#define STARTFILE_SPEC \
387-"%{mandroid: %(startfile_android) ;" \
388-" : %(startfile_default)}"
389-
390-#undef ANDROID_ENDFILE_SPEC
391-#define ANDROID_ENDFILE_SPEC "%{!shared:crtend_android%O%s}"
392-
393-/* Override ENDFILE_SPEC in unknown-elf.h. */
394-#undef ENDFILE_SPEC
395-#define ENDFILE_SPEC \
396-"%{mandroid: %(endfile_android) ;" \
397-" : %(endfile_default)}"
398-
399Index: gcc-4.5.3/gcc/config/arm/eabi.opt
400===================================================================
401--- gcc-4.5.3.orig/gcc/config/arm/eabi.opt
402+++ /dev/null
403@@ -1,23 +0,0 @@
404-; EABI specific options for ARM port of the compiler.
405-
406-; Copyright (C) 2008 Free Software Foundation, Inc.
407-;
408-; This file is part of GCC.
409-;
410-; GCC is free software; you can redistribute it and/or modify it under
411-; the terms of the GNU General Public License as published by the Free
412-; Software Foundation; either version 3, or (at your option) any later
413-; version.
414-;
415-; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
416-; WARRANTY; without even the implied warranty of MERCHANTABILITY or
417-; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
418-; for more details.
419-;
420-; You should have received a copy of the GNU General Public License
421-; along with GCC; see the file COPYING3. If not see
422-; <http://www.gnu.org/licenses/>.
423-
424-mandroid
425-Target Report RejectNegative Mask(ANDROID)
426-Generate code for the Android operating system.
427Index: gcc-4.5.3/gcc/config/arm/linux-eabi.h
428===================================================================
429--- gcc-4.5.3.orig/gcc/config/arm/linux-eabi.h
430+++ gcc-4.5.3/gcc/config/arm/linux-eabi.h
431@@ -70,7 +70,30 @@
432 /* At this point, bpabi.h will have clobbered LINK_SPEC. We want to
433 use the GNU/Linux version, not the generic BPABI version. */
434 #undef LINK_SPEC
435-#define LINK_SPEC LINUX_TARGET_LINK_SPEC BE8_LINK_SPEC TARGET_FIX_V4BX_SPEC
436+#define LINK_SPEC BE8_LINK_SPEC TARGET_FIX_V4BX_SPEC \
437+ LINUX_OR_ANDROID_LD (LINUX_TARGET_LINK_SPEC, \
438+ LINUX_TARGET_LINK_SPEC " " ANDROID_LINK_SPEC)
439+
440+#undef CC1_SPEC
441+#define CC1_SPEC \
442+ LINUX_OR_ANDROID_CC (LINUX_TARGET_CC1_SPEC, \
443+ LINUX_TARGET_CC1_SPEC " " ANDROID_CC1_SPEC)
444+
445+#define CC1PLUS_SPEC \
446+ LINUX_OR_ANDROID_CC ("", ANDROID_CC1PLUS_SPEC)
447+
448+#undef LIB_SPEC
449+#define LIB_SPEC \
450+ LINUX_OR_ANDROID_LD (LINUX_TARGET_LIB_SPEC, \
451+ LINUX_TARGET_LIB_SPEC " " ANDROID_LIB_SPEC)
452+
453+#undef STARTFILE_SPEC
454+#define STARTFILE_SPEC \
455+ LINUX_OR_ANDROID_LD (LINUX_TARGET_STARTFILE_SPEC, ANDROID_STARTFILE_SPEC)
456+
457+#undef ENDFILE_SPEC
458+#define ENDFILE_SPEC \
459+ LINUX_OR_ANDROID_LD (LINUX_TARGET_ENDFILE_SPEC, ANDROID_ENDFILE_SPEC)
460
461 /* Use the default LIBGCC_SPEC, not the version in linux-elf.h, as we
462 do not use -lfloat. */
463Index: gcc-4.5.3/gcc/config/arm/t-linux-androideabi
464===================================================================
465--- /dev/null
466+++ gcc-4.5.3/gcc/config/arm/t-linux-androideabi
467@@ -0,0 +1,10 @@
468+MULTILIB_OPTIONS = march=armv7-a mthumb
469+MULTILIB_DIRNAMES = armv7-a thumb
470+MULTILIB_EXCEPTIONS =
471+MULTILIB_MATCHES =
472+MULTILIB_OSDIRNAMES =
473+
474+# The "special" multilib can be used to build native applications for Android,
475+# as opposed to native shared libraries that are then called via JNI.
476+#MULTILIB_OPTIONS += tno-android-cc
477+#MULTILIB_DIRNAMES += special
478Index: gcc-4.5.3/gcc/config/linux-android.h
479===================================================================
480--- /dev/null
481+++ gcc-4.5.3/gcc/config/linux-android.h
482@@ -0,0 +1,53 @@
483+/* Configuration file for Linux Android targets.
484+ Copyright (C) 2010
485+ Free Software Foundation, Inc.
486+ Contributed by CodeSourcery, Inc.
487+
488+ This file is part of GCC.
489+
490+ GCC is free software; you can redistribute it and/or modify it
491+ under the terms of the GNU General Public License as published
492+ by the Free Software Foundation; either version 3, or (at your
493+ option) any later version.
494+
495+ GCC is distributed in the hope that it will be useful, but WITHOUT
496+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
497+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
498+ License for more details.
499+
500+ You should have received a copy of the GNU General Public License
501+ along with GCC; see the file COPYING3. If not see
502+ <http://www.gnu.org/licenses/>. */
503+
504+#if ANDROID_DEFAULT
505+# define NOANDROID "mno-android"
506+#else
507+# define NOANDROID "!mandroid"
508+#endif
509+
510+#define LINUX_OR_ANDROID_CC(LINUX_SPEC, ANDROID_SPEC) \
511+ "%{" NOANDROID "|tno-android-cc:" LINUX_SPEC ";:" ANDROID_SPEC "}"
512+
513+#define LINUX_OR_ANDROID_LD(LINUX_SPEC, ANDROID_SPEC) \
514+ "%{" NOANDROID "|tno-android-ld:" LINUX_SPEC ";:" ANDROID_SPEC "}"
515+
516+#define ANDROID_LINK_SPEC \
517+ "%{shared: -Bsymbolic}"
518+
519+#define ANDROID_CC1_SPEC \
520+ "%{!mglibc:%{!muclibc:%{!mbionic: -mbionic}}} " \
521+ "%{!fno-pic:%{!fno-PIC:%{!fpic:%{!fPIC: -fPIC}}}}"
522+
523+#define ANDROID_CC1PLUS_SPEC \
524+ "%{!fexceptions:%{!fno-exceptions: -fno-exceptions}} " \
525+ "%{!frtti:%{!fno-rtti: -fno-rtti}}"
526+
527+#define ANDROID_LIB_SPEC \
528+ "%{!static: -ldl}"
529+
530+#define ANDROID_STARTFILE_SPEC \
531+ "%{!shared:" \
532+ " %{static: crtbegin_static%O%s;: crtbegin_dynamic%O%s}}"
533+
534+#define ANDROID_ENDFILE_SPEC \
535+ "%{!shared: crtend_android%O%s}"
536Index: gcc-4.5.3/gcc/config/linux-android.opt
537===================================================================
538--- /dev/null
539+++ gcc-4.5.3/gcc/config/linux-android.opt
540@@ -0,0 +1,23 @@
541+; Android specific options.
542+
543+; Copyright (C) 2010 Free Software Foundation, Inc.
544+;
545+; This file is part of GCC.
546+;
547+; GCC is free software; you can redistribute it and/or modify it under
548+; the terms of the GNU General Public License as published by the Free
549+; Software Foundation; either version 3, or (at your option) any later
550+; version.
551+;
552+; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
553+; WARRANTY; without even the implied warranty of MERCHANTABILITY or
554+; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
555+; for more details.
556+;
557+; You should have received a copy of the GNU General Public License
558+; along with GCC; see the file COPYING3. If not see
559+; <http://www.gnu.org/licenses/>.
560+
561+mandroid
562+Target Report Mask(ANDROID) Var(flag_android) Init(ANDROID_DEFAULT ? OPTION_MASK_ANDROID : 0)
563+Generate code for the Android platform.
564Index: gcc-4.5.3/gcc/config/linux.h
565===================================================================
566--- gcc-4.5.3.orig/gcc/config/linux.h
567+++ gcc-4.5.3/gcc/config/linux.h
568@@ -1,6 +1,6 @@
569 /* Definitions for Linux-based GNU systems with ELF format
570 Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2003, 2004, 2005, 2006,
571- 2007, 2009 Free Software Foundation, Inc.
572+ 2007, 2009, 2010 Free Software Foundation, Inc.
573 Contributed by Eric Youngdale.
574 Modified for stabs-in-ELF by H.J. Lu (hjl@lucon.org).
575
576@@ -42,16 +42,17 @@ see the files COPYING3 and COPYING.RUNTI
577 provides part of the support for getting C++ file-scope static
578 object constructed before entering `main'. */
579
580-#undef STARTFILE_SPEC
581 #if defined HAVE_LD_PIE
582-#define STARTFILE_SPEC \
583+#define LINUX_TARGET_STARTFILE_SPEC \
584 "%{!shared: %{pg|p|profile:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}} \
585 crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
586 #else
587-#define STARTFILE_SPEC \
588+#define LINUX_TARGET_STARTFILE_SPEC \
589 "%{!shared: %{pg|p|profile:gcrt1.o%s;:crt1.o%s}} \
590 crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
591 #endif
592+#undef STARTFILE_SPEC
593+#define STARTFILE_SPEC LINUX_TARGET_STARTFILE_SPEC
594
595 /* Provide a ENDFILE_SPEC appropriate for GNU/Linux. Here we tack on
596 the GNU/Linux magical crtend.o file (see crtstuff.c) which
597@@ -59,33 +60,44 @@ see the files COPYING3 and COPYING.RUNTI
598 object constructed before entering `main', followed by a normal
599 GNU/Linux "finalizer" file, `crtn.o'. */
600
601-#undef ENDFILE_SPEC
602-#define ENDFILE_SPEC \
603+#define LINUX_TARGET_ENDFILE_SPEC \
604 "%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
605+#undef ENDFILE_SPEC
606+#define ENDFILE_SPEC LINUX_TARGET_ENDFILE_SPEC
607
608 /* This is for -profile to use -lc_p instead of -lc. */
609+#define LINUX_TARGET_CC1_SPEC "%{profile:-p}"
610 #ifndef CC1_SPEC
611-#define CC1_SPEC "%{profile:-p}"
612+#define CC1_SPEC LINUX_TARGET_CC1_SPEC
613 #endif
614
615 /* The GNU C++ standard library requires that these macros be defined. */
616 #undef CPLUSPLUS_CPP_SPEC
617 #define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
618
619-#undef LIB_SPEC
620-#define LIB_SPEC \
621+#define LINUX_TARGET_LIB_SPEC \
622 "%{pthread:-lpthread} \
623 %{shared:-lc} \
624 %{!shared:%{mieee-fp:-lieee} %{profile:-lc_p}%{!profile:-lc}}"
625+#undef LIB_SPEC
626+#define LIB_SPEC LINUX_TARGET_LIB_SPEC
627+
628+/* C libraries supported on Linux. */
629+#define OPTION_GLIBC (linux_libc == LIBC_GLIBC)
630+#define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC)
631+#define OPTION_BIONIC (linux_libc == LIBC_BIONIC)
632
633 #define LINUX_TARGET_OS_CPP_BUILTINS() \
634 do { \
635- builtin_define ("__gnu_linux__"); \
636+ if (OPTION_GLIBC) \
637+ builtin_define ("__gnu_linux__"); \
638 builtin_define_std ("linux"); \
639 builtin_define_std ("unix"); \
640 builtin_assert ("system=linux"); \
641 builtin_assert ("system=unix"); \
642 builtin_assert ("system=posix"); \
643+ if (OPTION_ANDROID) \
644+ builtin_define ("__ANDROID__"); \
645 } while (0)
646
647 #if defined(HAVE_LD_EH_FRAME_HDR)
648@@ -105,13 +117,24 @@ see the files COPYING3 and COPYING.RUNTI
649 #endif
650
651 /* Determine which dynamic linker to use depending on whether GLIBC or
652- uClibc is the default C library and whether -muclibc or -mglibc has
653- been passed to change the default. */
654-#if UCLIBC_DEFAULT
655-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:%{muclibc:%e-mglibc and -muclibc used together}" G ";:" U "}"
656+ uClibc or Bionic is the default C library and whether
657+ -muclibc or -mglibc or -mbionic has been passed to change the default. */
658+
659+#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LD1, LD2, LD3) \
660+ "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:" LD1 "}}"
661+
662+#if DEFAULT_LIBC == LIBC_GLIBC
663+#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
664+ CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", G, U, B)
665+#elif DEFAULT_LIBC == LIBC_UCLIBC
666+#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
667+ CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", U, G, B)
668+#elif DEFAULT_LIBC == LIBC_BIONIC
669+#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
670+ CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", B, G, U)
671 #else
672-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:%{mglibc:%e-mglibc and -muclibc used together}" U ";:" G "}"
673-#endif
674+#error "Unsupported DEFAULT_LIBC"
675+#endif /* DEFAULT_LIBC */
676
677 /* For most targets the following definitions suffice;
678 GLIBC_DYNAMIC_LINKER must be defined for each target using them, or
679@@ -120,18 +143,25 @@ see the files COPYING3 and COPYING.RUNTI
680 #define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
681 #define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0"
682 #define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0"
683-#define LINUX_DYNAMIC_LINKER \
684- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER)
685-#define LINUX_DYNAMIC_LINKER32 \
686- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32)
687-#define LINUX_DYNAMIC_LINKER64 \
688- CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64)
689+#define BIONIC_DYNAMIC_LINKER "/system/bin/linker"
690+#define BIONIC_DYNAMIC_LINKER32 "/system/bin/linker"
691+#define BIONIC_DYNAMIC_LINKER64 "/system/bin/linker64"
692+
693+#define LINUX_DYNAMIC_LINKER \
694+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, \
695+ BIONIC_DYNAMIC_LINKER)
696+#define LINUX_DYNAMIC_LINKER32 \
697+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, \
698+ BIONIC_DYNAMIC_LINKER32)
699+#define LINUX_DYNAMIC_LINKER64 \
700+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, \
701+ BIONIC_DYNAMIC_LINKER64)
702
703 /* Determine whether the entire c99 runtime
704 is present in the runtime library. */
705 #define TARGET_C99_FUNCTIONS (OPTION_GLIBC)
706
707 /* Whether we have sincos that follows the GNU extension. */
708-#define TARGET_HAS_SINCOS (OPTION_GLIBC)
709+#define TARGET_HAS_SINCOS (OPTION_GLIBC | OPTION_BIONIC)
710
711 #define TARGET_POSIX_IO
712Index: gcc-4.5.3/gcc/config/linux.opt
713===================================================================
714--- gcc-4.5.3.orig/gcc/config/linux.opt
715+++ gcc-4.5.3/gcc/config/linux.opt
716@@ -1,6 +1,6 @@
717 ; Processor-independent options for GNU/Linux.
718 ;
719-; Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc.
720+; Copyright (C) 2006, 2007, 2009, 2010 Free Software Foundation, Inc.
721 ; Contributed by CodeSourcery.
722 ;
723 ; This file is part of GCC.
724@@ -19,10 +19,14 @@
725 ; along with GCC; see the file COPYING3. If not see
726 ; <http://www.gnu.org/licenses/>.
727
728+mbionic
729+Target Report RejectNegative Var(linux_libc,LIBC_BIONIC) Init(DEFAULT_LIBC) Negative(mglibc)
730+Use Bionic C library
731+
732 mglibc
733-Target RejectNegative Report InverseMask(UCLIBC, GLIBC) Var(linux_uclibc) Init(UCLIBC_DEFAULT ? OPTION_MASK_UCLIBC : 0)
734-Use GNU libc instead of uClibc
735+Target Report RejectNegative Var(linux_libc,LIBC_GLIBC) VarExists Negative(muclibc)
736+Use GNU C library
737
738 muclibc
739-Target RejectNegative Report Mask(UCLIBC) Var(linux_uclibc) VarExists
740-Use uClibc instead of GNU libc
741+Target Report RejectNegative Var(linux_libc,LIBC_UCLIBC) VarExists Negative(mbionic)
742+Use uClibc C library
743Index: gcc-4.5.3/gcc/config/rs6000/linux64.h
744===================================================================
745--- gcc-4.5.3.orig/gcc/config/rs6000/linux64.h
746+++ gcc-4.5.3/gcc/config/rs6000/linux64.h
747@@ -344,10 +344,12 @@ extern int dot_symbols;
748 #define GLIBC_DYNAMIC_LINKER64 "/lib64/ld64.so.1"
749 #define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0"
750 #define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0"
751-#if UCLIBC_DEFAULT
752-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:%{muclibc:%e-mglibc and -muclibc used together}" G ";:" U "}"
753+#if DEFAULT_LIBC == LIBC_UCLIBC
754+#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
755+#elif DEFAULT_LIBC == LIBC_GLIBC
756+#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}"
757 #else
758-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:%{mglibc:%e-mglibc and -muclibc used together}" U ";:" G "}"
759+#error "Unsupported DEFAULT_LIBC"
760 #endif
761 #define LINUX_DYNAMIC_LINKER32 \
762 CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32)
763Index: gcc-4.5.3/gcc/config/rs6000/sysv4.h
764===================================================================
765--- gcc-4.5.3.orig/gcc/config/rs6000/sysv4.h
766+++ gcc-4.5.3/gcc/config/rs6000/sysv4.h
767@@ -901,10 +901,12 @@ SVR4_ASM_SPEC \
768
769 #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
770 #define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
771-#if UCLIBC_DEFAULT
772-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:%{muclibc:%e-mglibc and -muclibc used together}" G ";:" U "}"
773+#if DEFAULT_LIBC == LIBC_UCLIBC
774+#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
775+#elif DEFAULT_LIBC == LIBC_GLIBC
776+#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}"
777 #else
778-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:%{mglibc:%e-mglibc and -muclibc used together}" U ";:" G "}"
779+#error "Unsupported DEFAULT_LIBC"
780 #endif
781 #define LINUX_DYNAMIC_LINKER \
782 CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER)
783Index: gcc-4.5.3/gcc/doc/invoke.texi
784===================================================================
785--- gcc-4.5.3.orig/gcc/doc/invoke.texi
786+++ gcc-4.5.3/gcc/doc/invoke.texi
787@@ -565,7 +565,8 @@ Objective-C and Objective-C++ Dialects}.
788 -mcpu=@var{cpu}}
789
790 @emph{GNU/Linux Options}
791-@gccoptlist{-muclibc}
792+@gccoptlist{-mglibc -muclibc -mbionic -mandroid @gol
793+-tno-android-cc -tno-android-ld}
794
795 @emph{H8/300 Options}
796 @gccoptlist{-mrelax -mh -ms -mn -mint32 -malign-300}
797@@ -11469,13 +11470,41 @@ These @samp{-m} options are defined for
798 @table @gcctabopt
799 @item -mglibc
800 @opindex mglibc
801-Use the GNU C library instead of uClibc. This is the default except
802-on @samp{*-*-linux-*uclibc*} targets.
803+Use the GNU C library. This is the default except
804+on @samp{*-*-linux-*uclibc*} and @samp{*-*-linux-*android*} targets.
805
806 @item -muclibc
807 @opindex muclibc
808-Use uClibc instead of the GNU C library. This is the default on
809+Use uClibc C library. This is the default on
810 @samp{*-*-linux-*uclibc*} targets.
811+
812+@item -mbionic
813+@opindex mbionic
814+Use Bionic C library. This is the default on
815+@samp{*-*-linux-*android*} targets.
816+
817+@item -mandroid
818+@opindex mandroid
819+Compile code compatible with Android platform. This is the default on
820+@samp{*-*-linux-*android*} targets.
821+
822+When compiling, this option enables @option{-mbionic}, @option{-fPIC},
823+@option{-fno-exceptions} and @option{-fno-rtti} by default. When linking,
824+this option makes the GCC driver pass Android-specific options to the linker.
825+Finally, this option causes the preprocessor macro @code{__ANDROID__}
826+to be defined.
827+
828+@item -tno-android-cc
829+@opindex tno-android-cc
830+Disable compilation effects of @option{-mandroid}, i.e., do not enable
831+@option{-mbionic}, @option{-fPIC}, @option{-fno-exceptions} and
832+@option{-fno-rtti} by default.
833+
834+@item -tno-android-ld
835+@opindex tno-android-ld
836+Disable linking effects of @option{-mandroid}, i.e., pass standard Linux
837+linking options to the linker.
838+
839 @end table
840
841 @node H8/300 Options
842Index: gcc-4.5.3/gcc/gthr-posix.h
843===================================================================
844--- gcc-4.5.3.orig/gcc/gthr-posix.h
845+++ gcc-4.5.3/gcc/gthr-posix.h
846@@ -124,7 +124,9 @@ __gthrw(pthread_join)
847 __gthrw(pthread_equal)
848 __gthrw(pthread_self)
849 __gthrw(pthread_detach)
850+#ifndef __BIONIC__
851 __gthrw(pthread_cancel)
852+#endif
853 __gthrw(sched_yield)
854
855 __gthrw(pthread_mutex_lock)
856@@ -238,7 +240,15 @@ static inline int
857 __gthread_active_p (void)
858 {
859 static void *const __gthread_active_ptr
860- = __extension__ (void *) &__gthrw_(pthread_cancel);
861+ = __extension__ (void *) &__gthrw_(
862+/* Android's C library does not provide pthread_cancel, check for
863+ `pthread_create' instead. */
864+#ifndef __BIONIC__
865+ pthread_cancel
866+#else
867+ pthread_create
868+#endif
869+ );
870 return __gthread_active_ptr != 0;
871 }
872
873Index: gcc-4.5.3/gcc/testsuite/gcc.dg/glibc-uclibc-1.c
874===================================================================
875--- gcc-4.5.3.orig/gcc/testsuite/gcc.dg/glibc-uclibc-1.c
876+++ /dev/null
877@@ -1,6 +0,0 @@
878-/* Test -mglibc and -muclibc not allowed together. */
879-/* Origin: Joseph Myers <joseph@codesourcery.com> */
880-/* { dg-do link { target *-*-linux* } } */
881-/* { dg-options "-mglibc -muclibc" } */
882-
883-/* { dg-message "-mglibc and -muclibc used together" "" { target *-*-* } 0 } */
884Index: gcc-4.5.3/gcc/testsuite/gcc.dg/glibc-uclibc-2.c
885===================================================================
886--- gcc-4.5.3.orig/gcc/testsuite/gcc.dg/glibc-uclibc-2.c
887+++ /dev/null
888@@ -1,6 +0,0 @@
889-/* Test -mglibc and -muclibc not allowed together. */
890-/* Origin: Joseph Myers <joseph@codesourcery.com> */
891-/* { dg-do link { target *-*-linux* } } */
892-/* { dg-options "-muclibc -mglibc" } */
893-
894-/* { dg-message "-mglibc and -muclibc used together" "" { target *-*-* } 0 } */
895Index: gcc-4.5.3/libstdc++-v3/acinclude.m4
896===================================================================
897--- gcc-4.5.3.orig/libstdc++-v3/acinclude.m4
898+++ gcc-4.5.3/libstdc++-v3/acinclude.m4
899@@ -95,7 +95,7 @@ AC_DEFUN([GLIBCXX_CONFIGURE], [
900 ## (Right now, this only matters for enable_wchar_t, but nothing prevents
901 ## other macros from doing the same. This should be automated.) -pme
902
903- # Check for uClibc since Linux platforms use different configuration
904+ # Check for C library flavor since Linux platforms use different configuration
905 # directories depending on the C library in use.
906 AC_EGREP_CPP([_using_uclibc], [
907 #include <stdio.h>
908@@ -104,6 +104,13 @@ AC_DEFUN([GLIBCXX_CONFIGURE], [
909 #endif
910 ], uclibc=yes, uclibc=no)
911
912+ AC_EGREP_CPP([_using_bionic], [
913+ #include <stdio.h>
914+ #if __BIONIC__
915+ _using_bionic
916+ #endif
917+ ], bionic=yes, bionic=no)
918+
919 # Find platform-specific directories containing configuration info.
920 # Also possibly modify flags used elsewhere, as needed by the platform.
921 GLIBCXX_CHECK_HOST
922@@ -2722,7 +2729,7 @@ void foo()
923 }
924 EOF
925 old_CXXFLAGS="$CXXFLAGS"
926- CXXFLAGS=-S
927+ CXXFLAGS="-S -fexceptions"
928 if AC_TRY_EVAL(ac_compile); then
929 if grep _Unwind_SjLj_Resume conftest.s >/dev/null 2>&1 ; then
930 enable_sjlj_exceptions=yes
931Index: gcc-4.5.3/libstdc++-v3/config/os/bionic/ctype_base.h
932===================================================================
933--- /dev/null
934+++ gcc-4.5.3/libstdc++-v3/config/os/bionic/ctype_base.h
935@@ -0,0 +1,57 @@
936+// Locale support -*- C++ -*-
937+
938+// Copyright (C) 2010 Free Software Foundation, Inc.
939+//
940+// This file is part of the GNU ISO C++ Library. This library is free
941+// software; you can redistribute it and/or modify it under the
942+// terms of the GNU General Public License as published by the
943+// Free Software Foundation; either version 3, or (at your option)
944+// any later version.
945+
946+// This library is distributed in the hope that it will be useful,
947+// but WITHOUT ANY WARRANTY; without even the implied warranty of
948+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
949+// GNU General Public License for more details.
950+
951+// Under Section 7 of GPL version 3, you are granted additional
952+// permissions described in the GCC Runtime Library Exception, version
953+// 3.1, as published by the Free Software Foundation.
954+
955+// You should have received a copy of the GNU General Public License and
956+// a copy of the GCC Runtime Library Exception along with this program;
957+// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
958+// <http://www.gnu.org/licenses/>.
959+
960+//
961+// ISO C++ 14882: 22.1 Locales
962+//
963+
964+// Information as gleaned from /usr/include/ctype.h, for solaris2.5.1
965+
966+// Support for Solaris 2.5.1
967+
968+_GLIBCXX_BEGIN_NAMESPACE(std)
969+
970+ /// @brief Base class for ctype.
971+ struct ctype_base
972+ {
973+ // Non-standard typedefs.
974+ typedef const int* __to_type;
975+
976+ // NB: Offsets into ctype<char>::_M_table force a particular size
977+ // on the mask type. Because of this, we don't use an enum.
978+ typedef char mask;
979+ static const mask upper = _U;
980+ static const mask lower = _L;
981+ static const mask alpha = _U | _L;
982+ static const mask digit = _N;
983+ static const mask xdigit = _X | _N;
984+ static const mask space = _S;
985+ static const mask print = _P | _U | _L | _N | _B;
986+ static const mask graph = _P | _U | _L | _N;
987+ static const mask cntrl = _C;
988+ static const mask punct = _P;
989+ static const mask alnum = _U | _L | _N;
990+ };
991+
992+_GLIBCXX_END_NAMESPACE
993Index: gcc-4.5.3/libstdc++-v3/config/os/bionic/ctype_inline.h
994===================================================================
995--- /dev/null
996+++ gcc-4.5.3/libstdc++-v3/config/os/bionic/ctype_inline.h
997@@ -0,0 +1,71 @@
998+// Locale support -*- C++ -*-
999+
1000+// Copyright (C) 2010 Free Software Foundation, Inc.
1001+//
1002+// This file is part of the GNU ISO C++ Library. This library is free
1003+// software; you can redistribute it and/or modify it under the
1004+// terms of the GNU General Public License as published by the
1005+// Free Software Foundation; either version 3, or (at your option)
1006+// any later version.
1007+
1008+// This library is distributed in the hope that it will be useful,
1009+// but WITHOUT ANY WARRANTY; without even the implied warranty of
1010+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1011+// GNU General Public License for more details.
1012+
1013+// Under Section 7 of GPL version 3, you are granted additional
1014+// permissions described in the GCC Runtime Library Exception, version
1015+// 3.1, as published by the Free Software Foundation.
1016+
1017+// You should have received a copy of the GNU General Public License and
1018+// a copy of the GCC Runtime Library Exception along with this program;
1019+// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
1020+// <http://www.gnu.org/licenses/>.
1021+
1022+/** @file ctype_inline.h
1023+ * This is an internal header file, included by other library headers.
1024+ * You should not attempt to use it directly.
1025+ */
1026+
1027+//
1028+// ISO C++ 14882: 22.1 Locales
1029+//
1030+
1031+// ctype bits to be inlined go here. Non-inlinable (ie virtual do_*)
1032+// functions go in ctype.cc
1033+
1034+_GLIBCXX_BEGIN_NAMESPACE(std)
1035+
1036+ bool
1037+ ctype<char>::
1038+ is(mask __m, char __c) const
1039+ { return _M_table[static_cast<unsigned char>(__c)] & __m; }
1040+
1041+ const char*
1042+ ctype<char>::
1043+ is(const char* __low, const char* __high, mask* __vec) const
1044+ {
1045+ while (__low < __high)
1046+ *__vec++ = _M_table[static_cast<unsigned char>(*__low++)];
1047+ return __high;
1048+ }
1049+
1050+ const char*
1051+ ctype<char>::
1052+ scan_is(mask __m, const char* __low, const char* __high) const
1053+ {
1054+ while (__low < __high && !this->is(__m, *__low))
1055+ ++__low;
1056+ return __low;
1057+ }
1058+
1059+ const char*
1060+ ctype<char>::
1061+ scan_not(mask __m, const char* __low, const char* __high) const
1062+ {
1063+ while (__low < __high && this->is(__m, *__low) != 0)
1064+ ++__low;
1065+ return __low;
1066+ }
1067+
1068+_GLIBCXX_END_NAMESPACE
1069Index: gcc-4.5.3/libstdc++-v3/config/os/bionic/ctype_noninline.h
1070===================================================================
1071--- /dev/null
1072+++ gcc-4.5.3/libstdc++-v3/config/os/bionic/ctype_noninline.h
1073@@ -0,0 +1,98 @@
1074+// Locale support -*- C++ -*-
1075+
1076+// Copyright (C) 2010 Free Software Foundation, Inc.
1077+//
1078+// This file is part of the GNU ISO C++ Library. This library is free
1079+// software; you can redistribute it and/or modify it under the
1080+// terms of the GNU General Public License as published by the
1081+// Free Software Foundation; either version 3, or (at your option)
1082+// any later version.
1083+
1084+// This library is distributed in the hope that it will be useful,
1085+// but WITHOUT ANY WARRANTY; without even the implied warranty of
1086+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1087+// GNU General Public License for more details.
1088+
1089+// Under Section 7 of GPL version 3, you are granted additional
1090+// permissions described in the GCC Runtime Library Exception, version
1091+// 3.1, as published by the Free Software Foundation.
1092+
1093+// You should have received a copy of the GNU General Public License and
1094+// a copy of the GCC Runtime Library Exception along with this program;
1095+// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
1096+// <http://www.gnu.org/licenses/>.
1097+
1098+/** @file ctype_noninline.h
1099+ * This is an internal header file, included by other library headers.
1100+ * You should not attempt to use it directly.
1101+ */
1102+
1103+//
1104+// ISO C++ 14882: 22.1 Locales
1105+//
1106+
1107+// Information as gleaned from /usr/include/ctype.h
1108+
1109+ const ctype_base::mask*
1110+ ctype<char>::classic_table() throw()
1111+ { return _ctype_ + 1; }
1112+
1113+ ctype<char>::ctype(__c_locale, const mask* __table, bool __del,
1114+ size_t __refs)
1115+ : facet(__refs), _M_del(__table != 0 && __del),
1116+ _M_toupper(NULL), _M_tolower(NULL),
1117+ _M_table(__table ? __table : classic_table())
1118+ {
1119+ memset(_M_widen, 0, sizeof(_M_widen));
1120+ _M_widen_ok = 0;
1121+ memset(_M_narrow, 0, sizeof(_M_narrow));
1122+ _M_narrow_ok = 0;
1123+ }
1124+
1125+ ctype<char>::ctype(const mask* __table, bool __del, size_t __refs)
1126+ : facet(__refs), _M_del(__table != 0 && __del),
1127+ _M_toupper(NULL), _M_tolower(NULL),
1128+ _M_table(__table ? __table : classic_table())
1129+ {
1130+ memset(_M_widen, 0, sizeof(_M_widen));
1131+ _M_widen_ok = 0;
1132+ memset(_M_narrow, 0, sizeof(_M_narrow));
1133+ _M_narrow_ok = 0;
1134+ }
1135+
1136+ char
1137+ ctype<char>::do_toupper(char __c) const
1138+ {
1139+ int __x = __c;
1140+ return (this->is(ctype_base::lower, __c) ? (__x - 'a' + 'A') : __x);
1141+ }
1142+
1143+ const char*
1144+ ctype<char>::do_toupper(char* __low, const char* __high) const
1145+ {
1146+ while (__low < __high)
1147+ {
1148+ *__low = this->do_toupper(*__low);
1149+ ++__low;
1150+ }
1151+ return __high;
1152+ }
1153+
1154+ char
1155+ ctype<char>::do_tolower(char __c) const
1156+ {
1157+ int __x = __c;
1158+ return (this->is(ctype_base::upper, __c) ? (__x - 'A' + 'a') : __x);
1159+ }
1160+
1161+ const char*
1162+ ctype<char>::do_tolower(char* __low, const char* __high) const
1163+ {
1164+ while (__low < __high)
1165+ {
1166+ *__low = this->do_tolower(*__low);
1167+ ++__low;
1168+ }
1169+ return __high;
1170+ }
1171+
1172Index: gcc-4.5.3/libstdc++-v3/config/os/bionic/os_defines.h
1173===================================================================
1174--- /dev/null
1175+++ gcc-4.5.3/libstdc++-v3/config/os/bionic/os_defines.h
1176@@ -0,0 +1,36 @@
1177+// Specific definitions for Bionic -*- C++ -*-
1178+
1179+// Copyright (C) 2010 Free Software Foundation, Inc.
1180+//
1181+// This file is part of the GNU ISO C++ Library. This library is free
1182+// software; you can redistribute it and/or modify it under the
1183+// terms of the GNU General Public License as published by the
1184+// Free Software Foundation; either version 3, or (at your option)
1185+// any later version.
1186+
1187+// This library is distributed in the hope that it will be useful,
1188+// but WITHOUT ANY WARRANTY; without even the implied warranty of
1189+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1190+// GNU General Public License for more details.
1191+
1192+// Under Section 7 of GPL version 3, you are granted additional
1193+// permissions described in the GCC Runtime Library Exception, version
1194+// 3.1, as published by the Free Software Foundation.
1195+
1196+// You should have received a copy of the GNU General Public License and
1197+// a copy of the GCC Runtime Library Exception along with this program;
1198+// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
1199+// <http://www.gnu.org/licenses/>.
1200+
1201+/** @file os_defines.h
1202+ * This is an internal header file, included by other library headers.
1203+ * You should not attempt to use it directly.
1204+ */
1205+
1206+#ifndef _GLIBCXX_OS_DEFINES
1207+#define _GLIBCXX_OS_DEFINES 1
1208+
1209+// System-specific #define, typedefs, corrections, etc, go here. This
1210+// file will come before all others.
1211+
1212+#endif
1213Index: gcc-4.5.3/libstdc++-v3/configure
1214===================================================================
1215--- gcc-4.5.3.orig/libstdc++-v3/configure
1216+++ gcc-4.5.3/libstdc++-v3/configure
1217@@ -5185,7 +5185,7 @@ fi
1218 ## (Right now, this only matters for enable_wchar_t, but nothing prevents
1219 ## other macros from doing the same. This should be automated.) -pme
1220
1221- # Check for uClibc since Linux platforms use different configuration
1222+ # Check for C library flavor since Linux platforms use different configuration
1223 # directories depending on the C library in use.
1224 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1225 /* end confdefs.h. */
1226@@ -5205,6 +5205,24 @@ fi
1227 rm -f conftest*
1228
1229
1230+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1231+/* end confdefs.h. */
1232+
1233+ #include <stdio.h>
1234+ #if __BIONIC__
1235+ _using_bionic
1236+ #endif
1237+
1238+_ACEOF
1239+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
1240+ $EGREP "_using_bionic" >/dev/null 2>&1; then :
1241+ bionic=yes
1242+else
1243+ bionic=no
1244+fi
1245+rm -f conftest*
1246+
1247+
1248 # Find platform-specific directories containing configuration info.
1249 # Also possibly modify flags used elsewhere, as needed by the platform.
1250
1251@@ -14897,7 +14915,7 @@ void foo()
1252 }
1253 EOF
1254 old_CXXFLAGS="$CXXFLAGS"
1255- CXXFLAGS=-S
1256+ CXXFLAGS="-S -fexceptions"
1257 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
1258 (eval $ac_compile) 2>&5
1259 ac_status=$?
1260Index: gcc-4.5.3/libstdc++-v3/configure.host
1261===================================================================
1262--- gcc-4.5.3.orig/libstdc++-v3/configure.host
1263+++ gcc-4.5.3/libstdc++-v3/configure.host
1264@@ -238,6 +238,8 @@ case "${host_os}" in
1265 gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu)
1266 if [ "$uclibc" = "yes" ]; then
1267 os_include_dir="os/uclibc"
1268+ elif [ "$bionic" = "yes" ]; then
1269+ os_include_dir="os/bionic"
1270 else
1271 os_include_dir="os/gnu-linux"
1272 fi