public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 0/6] Add support for Android
@ 2010-05-20 15:59 Maxim Kuvyrkov
  2010-05-20 16:03 ` [PATCH 1/6] Add *-linux-android* target Maxim Kuvyrkov
                   ` (6 more replies)
  0 siblings, 7 replies; 30+ messages in thread
From: Maxim Kuvyrkov @ 2010-05-20 15:59 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jing Yu

The following series of patches adds Android support to GCC.

These patches add new -mbionic option and reimplement existing arm-eabi 
-mandroid option on top of support for linux targets.  With these 
patches it is possible to build arm-linux-*eabi toolchain that targets 
both GNU/Linux and Android flavors of ARM Linux.

For convenience of Android developers, these patches add new 
arm-linux-androideabi target triplet.  The only difference between 
arm-linux-gnueabi and arm-linux-androideabi toolchains is that the 
latter has -mandroid enabled by default.

Android support is implemented by these patches in target-independent 
way, so it will be easy to add Android support to other *-linux-* 
targets as needed.  [One will only need to update 
{CC1,CC1PLUS,LINK,LIB}_SPECs to include 
ANDROID_{CC1,CC1PLUS,LINK,LIB}_SPECs.]

Currently, libstdc++ cannot be built with -fno-rtti, which -mandroid 
implies.  It is possible to build full libstdc++ for Android, but it 
requires certain hacks to libstdc++ build machinery.

The patches were tested on arm-linux-androideabi by building minimal 
Android systems and by bootstrapping GCC on x86_64-linux-gnu.  Jing Yu 
of Google tested these patches by building Android.

Each of the patches will be posted in a subthread.

0001-Add-linux-android.patch
0002-Add-support-for-Bionic-C-library.patch
0003-Support-compilation-for-Android-platform.patch
0004-Add-multilib-configuration-for-arm-linux-androideabi.patch
0005-Fix-gthr-posix.h-to-support-Bionic.patch
0006-Add-untested-support-for-Bionic-to-libstdc.patch


Your review and comments are appreciated.

Thank you,

-- 
Maxim Kuvyrkov
CodeSourcery
maxim@codesourcery.com
(650) 331-3385 x724

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [PATCH 1/6] Add *-linux-android* target
  2010-05-20 15:59 [PATCH 0/6] Add support for Android Maxim Kuvyrkov
@ 2010-05-20 16:03 ` Maxim Kuvyrkov
  2010-05-20 17:29   ` Joseph S. Myers
  2010-05-20 16:05 ` [PATCH 2/6] Add support for Bionic C library Maxim Kuvyrkov
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 30+ messages in thread
From: Maxim Kuvyrkov @ 2010-05-20 16:03 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jing Yu

[-- Attachment #1: Type: text/plain, Size: 165 bytes --]

This patch updates config.sub to recognize *linux-android*.

OK to check in?

Thank you,

-- 
Maxim Kuvyrkov
CodeSourcery
maxim@codesourcery.com
(650) 331-3385 x724

[-- Attachment #2: 0001-Add-linux-android.ChangeLog --]
[-- Type: text/plain, Size: 98 bytes --]

2010-05-20  Maxim Kuvyrkov  <maxim@codesourcery.com>

	* config.sub: Recognize *-linux-android*.


[-- Attachment #3: 0001-Add-linux-android.patch --]
[-- Type: text/plain, Size: 1924 bytes --]

From a05a33fec020bfd46385b95377ab1db854935daa Mon Sep 17 00:00:00 2001
From: Maxim Kuvyrkov <maxim@codesourcery.com>
Date: Mon, 3 May 2010 02:21:26 -0700
Subject: [PATCH 1/7] Add linux-android


Signed-off-by: Maxim Kuvyrkov <maxim@codesourcery.com>
---
 config.sub |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/config.sub b/config.sub
index ae35431..20acb6b 100755
--- a/config.sub
+++ b/config.sub
@@ -4,7 +4,7 @@
 #   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
 #   Free Software Foundation, Inc.
 
-timestamp='2010-03-22'
+timestamp='2010-04-23'
 
 # This file is (in principle) common to ALL GNU software.
 # The presence of a machine in this file suggests that SOME GNU software
@@ -124,8 +124,9 @@ esac
 # Here we must recognize all the valid KERNEL-OS combinations.
 maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
 case $maybe_os in
-  nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
-  uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
+  nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
+  linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
+  knetbsd*-gnu* | netbsd*-gnu* | \
   kopensolaris*-gnu* | \
   storm-chaos* | os2-emx* | rtmk-nova*)
     os=-$maybe_os
@@ -1307,7 +1308,8 @@ case $os in
 	      | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
 	      | -chorusos* | -chorusrdb* | -cegcc* \
 	      | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
-	      | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
+	      | -mingw32* | -linux-gnu* | -linux-android* \
+	      | -linux-newlib* | -linux-uclibc* \
 	      | -uxpv* | -beos* | -mpeix* | -udk* \
 	      | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
 	      | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
-- 
1.6.2.4


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [PATCH 2/6] Add support for Bionic C library
  2010-05-20 15:59 [PATCH 0/6] Add support for Android Maxim Kuvyrkov
  2010-05-20 16:03 ` [PATCH 1/6] Add *-linux-android* target Maxim Kuvyrkov
@ 2010-05-20 16:05 ` Maxim Kuvyrkov
  2010-05-20 16:06   ` Maxim Kuvyrkov
  2010-05-20 16:06 ` [PATCH 3/6] Support compilation for Android platform Maxim Kuvyrkov
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 30+ messages in thread
From: Maxim Kuvyrkov @ 2010-05-20 16:05 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jing Yu

This patch adds new -mbionic option to select Bionic C library.  The 
option is made similar to -mglibc and -muclibc.

OK to check in?

Thank you,

-- 
Maxim Kuvyrkov
CodeSourcery
maxim@codesourcery.com
(650) 331-3385 x724

^ permalink raw reply	[flat|nested] 30+ messages in thread

* [PATCH 3/6] Support compilation for Android platform
  2010-05-20 15:59 [PATCH 0/6] Add support for Android Maxim Kuvyrkov
  2010-05-20 16:03 ` [PATCH 1/6] Add *-linux-android* target Maxim Kuvyrkov
  2010-05-20 16:05 ` [PATCH 2/6] Add support for Bionic C library Maxim Kuvyrkov
@ 2010-05-20 16:06 ` Maxim Kuvyrkov
  2010-05-25 15:06   ` Mark Mitchell
  2010-05-20 16:07 ` [PATCH 4/6] Add multilib configuration for arm-linux-androideabi Maxim Kuvyrkov
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 30+ messages in thread
From: Maxim Kuvyrkov @ 2010-05-20 16:06 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jing Yu

[-- Attachment #1: Type: text/plain, Size: 2158 bytes --]

This patch builds up Android support on top of Linux.

This patch reimplements "-mandroid" option and adds it for all *linux* 
targets.  This option defines certain compilation conventions that 
Android platform follows.  One of the aspects of making -mandroid option 
architecture-independent is that it will be easy to later add support 
for Android on x86, SH and others.

When "-mandroid" option is specified ...

1. GCC preprocessor defines __ANDROID__ built-in macro.

2. GCC compilers enable -mbionic by default.

3. GCC compilers enable -fPIC by default.  Any of -fno-pic, -fno-PIC or 
-fpic override the default.

4. GCC C++ compiler enables -fno-exceptions and -fno-rtti by default. 
Specifying "-fexceptions" or "-frtti" overrides the respective default.

5. GCC driver passes Android-specific crtbegin*.o and crtend*.o objects 
to the linker.

6. GCC driver passes -ldl option to the linker unless `-static' option 
is given.

7. GCC driver passes -Bsymbolic option to the linker when building a 
shared library.

The patch also adds two service options: -tno-android-cc and 
-tno-android-ld.  The "-tno-android-cc" option overrides the 
/compilation/ effect of -mandroid -- items (2), (3) and (4) of the 
above.  The "-tno-android-ld" option overrides the /linking/ effect of 
-mandroid -- items (5), (6) and (7) of the above.

The "-tno-android-cc" option is used to build a "special" Android 
multilib that is suitable for Linux kernel development and C++ 
applications that require full C++ support.  The "-tno-android-ld" 
option is not presently used and was added for symmetry.

The "-mno-android" option disables all effects of implicitly or 
explicitly specified "-mandroid" option.  I.e., to build a GLIBC 
multilib for a arm-linux-androideabi toolchain one can use "-mglibc 
-mno-android".

Although Android support and "-mandroid" option are not specific to ARM, 
only ARM defines {CC1, CC1_PLUS, LINK, LIB}_SPEC to include definitions 
from config/linux-android.h.  For all other targets Android support is 
an effective no-op.

OK to check in?

Thank you,

-- 
Maxim Kuvyrkov
CodeSourcery
maxim@codesourcery.com
(650) 331-3385 x724

[-- Attachment #2: 0003-Support-compilation-for-Android-platform.ChangeLog --]
[-- Type: text/plain, Size: 1104 bytes --]

2010-05-20  Maxim Kuvyrkov  <maxim@codesourcery.com>

	Support compilation for Android platform.  Reimplement -mandroid.
	gcc/
	* config.gcc (*linux*): Include linux-android.h and linux-android.opt.
	(*android*): Set ANDROID_DEFAULT.
	(arm*-*-linux*): Include linux-android.h.
	(arm*-*-eabi*): Don't include previous -mandroid implementation.
	* config/arm/eabi.h: Remove, move Android-specific parts ...
	* config/linux-android.h: ... here.  New file.
	* config/arm/eabi.opt: Rename to ...
	* config/linux-android.opt: ... this.
	(mandroid): Allow -mno-android option.  Initialize based on
	ANDROID_DEFAULT.
	* config/linux.h (STARTFILE_SPEC, ENDFILE_SPEC, CC1_SPEC, LIB_SPEC):
	Move logic to corresponding LINUX_TARGET_* macros.
	(TARGET_OS_CPP_BUILTINS): Define __ANDROID__, when appropriate.
	* config/linux-eabi.h (LINK_SPEC, CC1_SPEC, CC1PLUS_SPEC, LIB_SPEC,)
	(STARTFILE_SPEC, ENDFILE_SPEC): Define to choose between Linux and
	Android definitions.
	(LINUX_TARGET_OS_CPP_BUILTINS): Define __ANDROID__ if TARGET_ANDROID.
	* doc/invoke.texi (-mandroid, -tno-android-cc, -tno-android-ld):
	Document.

[-- Attachment #3: 0003-Support-compilation-for-Android-platform.patch --]
[-- Type: text/plain, Size: 15872 bytes --]

From ec93ada0f51e7f9cfc0702eed0d895942e7b0cbb Mon Sep 17 00:00:00 2001
From: Maxim Kuvyrkov <maxim@codesourcery.com>
Date: Wed, 19 May 2010 02:07:39 -0700
Subject: [PATCH 3/7] Support compilation for Android platform


Signed-off-by: Maxim Kuvyrkov <maxim@codesourcery.com>
---
 gcc/config.gcc               |   21 ++++++-
 gcc/config/arm/eabi.h        |  125 ------------------------------------------
 gcc/config/arm/eabi.opt      |   23 --------
 gcc/config/arm/linux-eabi.h  |   25 ++++++++-
 gcc/config/linux-android.h   |   53 ++++++++++++++++++
 gcc/config/linux-android.opt |   23 ++++++++
 gcc/config/linux.h           |   22 +++++---
 gcc/doc/invoke.texi          |   26 ++++++++-
 8 files changed, 157 insertions(+), 161 deletions(-)
 delete mode 100644 gcc/config/arm/eabi.h
 delete mode 100644 gcc/config/arm/eabi.opt
 create mode 100644 gcc/config/linux-android.h
 create mode 100644 gcc/config/linux-android.opt

diff --git a/gcc/config.gcc b/gcc/config.gcc
index b67fdff..d799caa 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -534,6 +534,22 @@ case ${target} in
   default_use_cxa_atexit=yes
   use_gcc_tgmath=no
   use_gcc_stdint=wrap
+  # Add Android userspace support to Linux targets.
+  case $target in
+    *linux*)
+      tm_file="$tm_file linux-android.h"
+      extra_options="$extra_options linux-android.opt"
+      ;;
+  esac
+  # Enable compilation for Android by default for *android* targets.
+  case $target in
+    *-*-*android*)
+      tm_defines="$tm_defines ANDROID_DEFAULT=1"
+      ;;
+    *)
+      tm_defines="$tm_defines ANDROID_DEFAULT=0"
+      ;;
+  esac
   ;;
 *-*-netbsd*)
   tmake_file="t-slibgcc-elf-ver t-libc-ok t-netbsd t-libgcc-pic"
@@ -717,7 +733,7 @@ arm*-*-netbsd*)
 	use_collect2=yes
 	;;
 arm*-*-linux*)			# ARM GNU/Linux with ELF
-	tm_file="dbxelf.h elfos.h linux.h glibc-stdint.h arm/elf.h arm/linux-gas.h arm/linux-elf.h"
+	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"
 	case $target in
 	arm*b-*)
 		tm_defines="${tm_defines} TARGET_BIG_ENDIAN_DEFAULT=1"
@@ -774,9 +790,8 @@ arm*-*-eabi* | arm*-*-symbianelf* )
 	tmake_file="arm/t-arm arm/t-arm-elf"
 	case ${target} in
 	arm*-*-eabi*)
-	  tm_file="$tm_file arm/eabi.h newlib-stdint.h"
+	  tm_file="$tm_file newlib-stdint.h"
 	  tmake_file="${tmake_file} arm/t-bpabi"
-	  extra_options="${extra_options} arm/eabi.opt"
 	  use_gcc_stdint=wrap
 	  ;;
 	arm*-*-symbianelf*)
diff --git a/gcc/config/arm/eabi.h b/gcc/config/arm/eabi.h
deleted file mode 100644
index c7d1d3e..0000000
--- a/gcc/config/arm/eabi.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/* Configuration file for ARM EABI targets.
-   Copyright (C) 2008
-   Free Software Foundation, Inc.
-   Contributed by Doug Kwan (dougkwan@google.com)
-
-   This file is part of GCC.
-
-   GCC is free software; you can redistribute it and/or modify it
-   under the terms of the GNU General Public License as published
-   by the Free Software Foundation; either version 3, or (at your
-   option) any later version.
-
-   GCC is distributed in the hope that it will be useful, but WITHOUT
-   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
-   License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with GCC; see the file COPYING3.  If not see
-   <http://www.gnu.org/licenses/>.  */
-
-/* This file contains macro overrides for EABI targets.  */
-
-#undef TARGET_OS_CPP_BUILTINS
-#define TARGET_OS_CPP_BUILTINS()			\
-  do							\
-    {							\
-      TARGET_BPABI_CPP_BUILTINS ();			\
-      if (TARGET_ANDROID)				\
-	builtin_define ("__ANDROID__");			\
-    }							\
-  while (false)
-
-#undef SUBSUBTARGET_EXTRA_SPECS
-#define SUBSUBTARGET_EXTRA_SPECS \
-  { "link_android",		ANDROID_LINK_SPEC },		\
-  { "link_default",		BPABI_LINK_SPEC },		\
-  { "cc1_android",		ANDROID_CC1_SPEC },		\
-  { "cc1_default",		CC1_DEFAULT_SPEC },		\
-  { "cc1plus_android",		ANDROID_CC1PLUS_SPEC },		\
-  { "cc1plus_default",		CC1PLUS_DEFAULT_SPEC },		\
-  { "lib_android",		ANDROID_LIB_SPEC },		\
-  { "lib_default",		LIB_DEFAULT_SPEC },		\
-  { "startfile_android",	ANDROID_STARTFILE_SPEC },	\
-  { "startfile_default",	UNKNOWN_ELF_STARTFILE_SPEC },	\
-  { "endfile_android",		ANDROID_ENDFILE_SPEC },		\
-  { "endfile_default",		UNKNOWN_ELF_ENDFILE_SPEC },	\
-
-#undef ANDROID_LINK_SPEC
-#define ANDROID_LINK_SPEC \
-"%{mbig-endian:-EB} %{mlittle-endian:-EL} "		\
-"%{static:-Bstatic} %{shared:-shared} %{symbolic:-Bsymbolic} "	\
-"%{!static:" \
-   "%{shared: -Bsymbolic} " \
-   "%{!shared:" \
-      "%{rdynamic:-export-dynamic} " \
-      "%{!dynamic-linker:-dynamic-linker /system/bin/linker}}} " \
-"-X" SUBTARGET_EXTRA_LINK_SPEC
-
-/* Override LINK_SPEC in bpabi.h. */
-#undef LINK_SPEC
-#define LINK_SPEC \
-"%{mandroid: %(link_android) ;" \
-"          : %(link_default)}"
-
-/* Android uses -fno-exceptions by default. */
-#undef ANDROID_CC1_SPEC
-#define ANDROID_CC1_SPEC "%{!fexceptions:-fno-exceptions}"
-
-/* Default CC1_SPEC as in arm.h. */
-#undef CC1_DEFAULT_SPEC
-#define CC1_DEFAULT_SPEC ""
-
-#undef CC1_SPEC
-#define CC1_SPEC \
-"%{mandroid: %(cc1_android) ;" \
-"          : %(cc1_default)}"
-
-/* Android uses -fno-rtti by default. */
-#undef ANDROID_CC1PLUS_SPEC
-#define ANDROID_CC1PLUS_SPEC "%{!frtti:-fno-rtti}"
-
-/* Default CC1PLUS_SPEC as in gcc.c. */
-#undef CC1PLUS_DEFAULT_SPEC
-#define CC1PLUS_DEFAULT_SPEC ""
-
-#undef CC1PLUS_SPEC
-#define CC1PLUS_SPEC \
-"%{mandroid: %(cc1plus_android) ;" \
-"          : %(cc1plus_default)}"
-
-#undef ANDROID_LIB_SPEC
-#define ANDROID_LIB_SPEC	"-lc %{!static:-ldl}"
-
-/* Default LIB_SPEC as in gcc.c. */
-#undef LIB_DEFAULT_SPEC
-#define LIB_DEFAULT_SPEC \
-"%{!shared:%{g*:-lg} %{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}}"
-
-#undef LIB_SPEC
-#define LIB_SPEC \
-"%{mandroid: %(lib_android) ;" \
-"          : %(lib_default)}"
-
-#undef ANDROID_STARTFILE_SPEC
-#define ANDROID_STARTFILE_SPEC \
-"%{!shared:" \
-   "%{static: crtbegin_static%O%s ;" \
-   "        : crtbegin_dynamic%O%s}}"
-
-/* Override STARTFILE_SPEC in unknown-elf.h. */
-#undef STARTFILE_SPEC
-#define STARTFILE_SPEC \
-"%{mandroid: %(startfile_android) ;" \
-"          : %(startfile_default)}"
-
-#undef ANDROID_ENDFILE_SPEC
-#define ANDROID_ENDFILE_SPEC	"%{!shared:crtend_android%O%s}"
-
-/* Override ENDFILE_SPEC in unknown-elf.h. */
-#undef ENDFILE_SPEC
-#define ENDFILE_SPEC \
-"%{mandroid: %(endfile_android) ;" \
-"          : %(endfile_default)}"
-
diff --git a/gcc/config/arm/eabi.opt b/gcc/config/arm/eabi.opt
deleted file mode 100644
index 2cda98d..0000000
--- a/gcc/config/arm/eabi.opt
+++ /dev/null
@@ -1,23 +0,0 @@
-; EABI specific options for ARM port of the compiler.
-
-; Copyright (C) 2008 Free Software Foundation, Inc.
-;
-; This file is part of GCC.
-;
-; GCC is free software; you can redistribute it and/or modify it under
-; the terms of the GNU General Public License as published by the Free
-; Software Foundation; either version 3, or (at your option) any later
-; version.
-;
-; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
-; WARRANTY; without even the implied warranty of MERCHANTABILITY or
-; FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-; for more details.
-;
-; You should have received a copy of the GNU General Public License
-; along with GCC; see the file COPYING3.  If not see
-; <http://www.gnu.org/licenses/>.
-
-mandroid
-Target Report RejectNegative Mask(ANDROID)
-Generate code for the Android operating system.
diff --git a/gcc/config/arm/linux-eabi.h b/gcc/config/arm/linux-eabi.h
index fce1ed1..e69035e 100644
--- a/gcc/config/arm/linux-eabi.h
+++ b/gcc/config/arm/linux-eabi.h
@@ -66,7 +66,30 @@
 /* At this point, bpabi.h will have clobbered LINK_SPEC.  We want to
    use the GNU/Linux version, not the generic BPABI version.  */
 #undef  LINK_SPEC
-#define LINK_SPEC LINUX_TARGET_LINK_SPEC BE8_LINK_SPEC
+#define LINK_SPEC BE8_LINK_SPEC						\
+  LINUX_OR_ANDROID_LD (LINUX_TARGET_LINK_SPEC,				\
+		       LINUX_TARGET_LINK_SPEC " " ANDROID_LINK_SPEC)
+
+#undef  CC1_SPEC
+#define CC1_SPEC						\
+  LINUX_OR_ANDROID_CC (LINUX_TARGET_CC1_SPEC,			\
+		       LINUX_TARGET_CC1_SPEC " " ANDROID_CC1_SPEC)
+
+#define CC1PLUS_SPEC \
+  LINUX_OR_ANDROID_CC ("", ANDROID_CC1PLUS_SPEC)
+
+#undef  LIB_SPEC
+#define LIB_SPEC						\
+  LINUX_OR_ANDROID_LD (LINUX_TARGET_LIB_SPEC,			\
+		       LINUX_TARGET_LIB_SPEC " " ANDROID_LIB_SPEC)
+
+#undef	STARTFILE_SPEC
+#define STARTFILE_SPEC \
+  LINUX_OR_ANDROID_LD (LINUX_TARGET_STARTFILE_SPEC, ANDROID_STARTFILE_SPEC)
+
+#undef	ENDFILE_SPEC
+#define ENDFILE_SPEC \
+  LINUX_OR_ANDROID_LD (LINUX_TARGET_ENDFILE_SPEC, ANDROID_ENDFILE_SPEC)
 
 /* Use the default LIBGCC_SPEC, not the version in linux-elf.h, as we
    do not use -lfloat.  */
diff --git a/gcc/config/linux-android.h b/gcc/config/linux-android.h
new file mode 100644
index 0000000..433fd9d
--- /dev/null
+++ b/gcc/config/linux-android.h
@@ -0,0 +1,53 @@
+/* Configuration file for Linux Android targets.
+   Copyright (C) 2010
+   Free Software Foundation, Inc.
+   Contributed by CodeSourcery, Inc.
+
+   This file is part of GCC.
+
+   GCC is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published
+   by the Free Software Foundation; either version 3, or (at your
+   option) any later version.
+
+   GCC is distributed in the hope that it will be useful, but WITHOUT
+   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
+   License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with GCC; see the file COPYING3.  If not see
+   <http://www.gnu.org/licenses/>.  */
+
+#if ANDROID_DEFAULT
+# define NOANDROID "mno-android"
+#else
+# define NOANDROID "!mandroid"
+#endif
+
+#define LINUX_OR_ANDROID_CC(LINUX_SPEC, ANDROID_SPEC) \
+  "%{" NOANDROID "|tno-android-cc:" LINUX_SPEC ";:" ANDROID_SPEC "}"
+
+#define LINUX_OR_ANDROID_LD(LINUX_SPEC, ANDROID_SPEC) \
+  "%{" NOANDROID "|tno-android-ld:" LINUX_SPEC ";:" ANDROID_SPEC "}"
+
+#define ANDROID_LINK_SPEC \
+  "%{shared: -Bsymbolic}"
+
+#define ANDROID_CC1_SPEC						\
+  "%{!mglibc:%{!muclibc:%{!mbionic: -mbionic}}} "			\
+  "%{!fno-pic:%{!fno-PIC:%{!fpic:%{!fPIC: -fPIC}}}}"
+
+#define ANDROID_CC1PLUS_SPEC						\
+  "%{!fexceptions:%{!fno-exceptions: -fno-exceptions}} "		\
+  "%{!frtti:%{!fno-rtti: -fno-rtti}}"
+
+#define ANDROID_LIB_SPEC \
+  "%{!static: -ldl}"
+
+#define ANDROID_STARTFILE_SPEC						\
+  "%{!shared:"								\
+  "  %{static: crtbegin_static%O%s;: crtbegin_dynamic%O%s}}"
+
+#define ANDROID_ENDFILE_SPEC \
+  "%{!shared: crtend_android%O%s}"
diff --git a/gcc/config/linux-android.opt b/gcc/config/linux-android.opt
new file mode 100644
index 0000000..ee92bc0
--- /dev/null
+++ b/gcc/config/linux-android.opt
@@ -0,0 +1,23 @@
+; Android specific options.
+
+; Copyright (C) 2010 Free Software Foundation, Inc.
+;
+; This file is part of GCC.
+;
+; GCC is free software; you can redistribute it and/or modify it under
+; the terms of the GNU General Public License as published by the Free
+; Software Foundation; either version 3, or (at your option) any later
+; version.
+;
+; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+; WARRANTY; without even the implied warranty of MERCHANTABILITY or
+; FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+; for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with GCC; see the file COPYING3.  If not see
+; <http://www.gnu.org/licenses/>.
+
+mandroid
+Target Report Mask(ANDROID) Var(flag_android) Init(ANDROID_DEFAULT ? OPTION_MASK_ANDROID : 0)
+Generate code for the Android platform.
diff --git a/gcc/config/linux.h b/gcc/config/linux.h
index f86cc7b..241e656 100644
--- a/gcc/config/linux.h
+++ b/gcc/config/linux.h
@@ -42,16 +42,17 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    provides part of the support for getting C++ file-scope static
    object constructed before entering `main'.  */
    
-#undef	STARTFILE_SPEC
 #if defined HAVE_LD_PIE
-#define STARTFILE_SPEC \
+#define LINUX_TARGET_STARTFILE_SPEC \
   "%{!shared: %{pg|p|profile:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}} \
    crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
 #else
-#define STARTFILE_SPEC \
+#define LINUX_TARGET_STARTFILE_SPEC \
   "%{!shared: %{pg|p|profile:gcrt1.o%s;:crt1.o%s}} \
    crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
 #endif
+#undef  STARTFILE_SPEC
+#define STARTFILE_SPEC LINUX_TARGET_STARTFILE_SPEC
 
 /* Provide a ENDFILE_SPEC appropriate for GNU/Linux.  Here we tack on
    the GNU/Linux magical crtend.o file (see crtstuff.c) which
@@ -59,24 +60,27 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    object constructed before entering `main', followed by a normal
    GNU/Linux "finalizer" file, `crtn.o'.  */
 
-#undef	ENDFILE_SPEC
-#define ENDFILE_SPEC \
+#define LINUX_TARGET_ENDFILE_SPEC \
   "%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
+#undef  ENDFILE_SPEC
+#define ENDFILE_SPEC LINUX_TARGET_ENDFILE_SPEC
 
 /* This is for -profile to use -lc_p instead of -lc.  */
+#define LINUX_TARGET_CC1_SPEC "%{profile:-p}"
 #ifndef CC1_SPEC
-#define CC1_SPEC "%{profile:-p}"
+#define CC1_SPEC LINUX_TARGET_CC1_SPEC
 #endif
 
 /* The GNU C++ standard library requires that these macros be defined.  */
 #undef CPLUSPLUS_CPP_SPEC
 #define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
 
-#undef	LIB_SPEC
-#define LIB_SPEC \
+#define LINUX_TARGET_LIB_SPEC \
   "%{pthread:-lpthread} \
    %{shared:-lc} \
    %{!shared:%{mieee-fp:-lieee} %{profile:-lc_p}%{!profile:-lc}}"
+#undef  LIB_SPEC
+#define LIB_SPEC LINUX_TARGET_LIB_SPEC
 
 /* C libraries supported on Linux.  */
 #define OPTION_GLIBC  (linux_libc == LIBC_GLIBC)
@@ -92,6 +96,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 	builtin_assert ("system=linux");			\
 	builtin_assert ("system=unix");				\
 	builtin_assert ("system=posix");			\
+	if (OPTION_ANDROID)					\
+	  builtin_define ("__ANDROID__");			\
     } while (0)
 
 #if defined(HAVE_LD_EH_FRAME_HDR)
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index a75196e..fa5337d 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -559,7 +559,8 @@ Objective-C and Objective-C++ Dialects}.
 -mcpu=@var{cpu}}
 
 @emph{GNU/Linux Options}
-@gccoptlist{-muclibc}
+@gccoptlist{-mglibc -muclibc -mbionic -mandroid @gol
+-tno-android-cc -tno-android-ld}
 
 @emph{H8/300 Options}
 @gccoptlist{-mrelax  -mh  -ms  -mn  -mint32  -malign-300}
@@ -11474,6 +11475,29 @@ Use uClibc C library.  This is the default on
 @opindex mbionic
 Use Bionic C library.  This is the default on
 @samp{*-*-linux-*android*} targets.
+
+@item -mandroid
+@opindex mandroid
+Compile code compatible with Android platform.  This is the default on
+@samp{*-*-linux-*android*} targets.
+
+When compiling, this option enables @option{-mbionic}, @option{-fPIC},
+@option{-fno-exceptions} and @option{-fno-rtti} by default.  When linking,
+this option makes the GCC driver pass Android-specific options to the linker.
+Finally, this option causes the preprocessor macro @code{__ANDROID__}
+to be defined.
+
+@item -tno-android-cc
+@opindex tno-android-cc
+Disable compilation effects of @option{-mandroid}, i.e., do not enable
+@option{-mbionic}, @option{-fPIC}, @option{-fno-exceptions} and
+@option{-fno-rtti} by default.
+
+@item -tno-android-ld
+@opindex tno-android-ld
+Disable linking effects of @option{-mandroid}, i.e., pass standard Linux
+linking options to the linker.
+
 @end table
 
 @node H8/300 Options
-- 
1.6.2.4


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 2/6] Add support for Bionic C library
  2010-05-20 16:05 ` [PATCH 2/6] Add support for Bionic C library Maxim Kuvyrkov
@ 2010-05-20 16:06   ` Maxim Kuvyrkov
  2010-05-25 15:00     ` Mark Mitchell
  2010-06-13 18:58     ` mips-linux bootstrap broken was: " Laurent GUERBY
  0 siblings, 2 replies; 30+ messages in thread
From: Maxim Kuvyrkov @ 2010-05-20 16:06 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jing Yu

[-- Attachment #1: Type: text/plain, Size: 298 bytes --]

On 5/20/10 8:03 PM, Maxim Kuvyrkov wrote:
> This patch adds new -mbionic option to select Bionic C library.  The
> option is made similar to -mglibc and -muclibc.
>
> OK to check in?
>
> Thank you,

And here is the patch.

-- 
Maxim Kuvyrkov
CodeSourcery
maxim@codesourcery.com
(650) 331-3385 x724

[-- Attachment #2: 0002-Add-support-for-Bionic-C-library.ChangeLog --]
[-- Type: text/plain, Size: 1306 bytes --]

2010-05-20  Maxim Kuvyrkov  <maxim@codesourcery.com>

	Add support for Bionic C library
	gcc/
	* config.gcc (LIBC_GLIBC, LIBC_BIONIC, LIBC_UCLIBC): New tm_define
	macro.
	(DEFAULT_LIBC): New tm_define macro set to one of LIBC_*.
	(bfin*-uclinux, moxie-*-uclinux*, m68k-*-uclinux*): Update.

	* config/linux.h (OPTION_GLIBC, OPTION_UCLIBC, OPTION_BIONIC): Define.
	(LINUX_TARGET_OS_CPP_BUILTINS): Define __gnu_linux__ only for GLIBC.
	(CHOOSE_DYNAMIC_LINKER1, CHOOSE_DYNAMIC_LINKER): Make it easier
	to support multiple C libraries.  Handle Bionic.
	(BIONIC_DYNAMIC_LINKER, BIONIC_DYNAMIC_LINKER32,)
	(BIONIC_DYNAMIC_LINKER64): Define.
	(LINUX_DYNAMIC_LINKER, LINUX_DYNAMIC_LINKER32, LINUX_DYNAMIC_LINKER64):
	Update.
	(TARGET_HAS_SINCOS): Enable for Bionic.

	* config/linux.opt: Rewrite to handle more than 2 C libraries.  Make
	the last option specified on command line take effect.
	(linux_uclibc): Rename to linux_libc, initialize using DEFAULT_LIBC.
	(mbionic): New.
	(mglibc, muclibc): Update.

	* config/alpha/linux-elf.h, config/rs6000/linux64.h,
	* config/rs6000/sysv4.h (CHOOSE_DYNAMIC_LINKER): Update to use
	DEFAULT_LIBC.

	* doc/invoke.texi (-mglibc, -muclibc): Update.
	(-mbionic): Document.

	gcc/testsuite/
	* gcc.dg/glibc-uclibc-1.c, gcc.dg/glibc-uclibc-2.c: Remove, no longer
	necessary.

[-- Attachment #3: 0002-Add-support-for-Bionic-C-library.patch --]
[-- Type: text/plain, Size: 13333 bytes --]

From 13a59e1e70923a7bd17de58b742290cb78cd2b88 Mon Sep 17 00:00:00 2001
From: Maxim Kuvyrkov <maxim@codesourcery.com>
Date: Wed, 19 May 2010 06:04:06 -0700
Subject: [PATCH 2/7] Add support for Bionic C library


Signed-off-by: Maxim Kuvyrkov <maxim@codesourcery.com>
---
 gcc/config.gcc                        |   24 +++++++++-----
 gcc/config/alpha/linux-elf.h          |    8 +++--
 gcc/config/linux.h                    |   54 +++++++++++++++++++++++---------
 gcc/config/linux.opt                  |   14 +++++---
 gcc/config/rs6000/linux64.h           |    8 +++--
 gcc/config/rs6000/sysv4.h             |    8 +++--
 gcc/doc/invoke.texi                   |   11 +++++--
 gcc/testsuite/gcc.dg/glibc-uclibc-1.c |    6 ----
 gcc/testsuite/gcc.dg/glibc-uclibc-2.c |    6 ----
 9 files changed, 86 insertions(+), 53 deletions(-)
 delete mode 100644 gcc/testsuite/gcc.dg/glibc-uclibc-1.c
 delete mode 100644 gcc/testsuite/gcc.dg/glibc-uclibc-2.c

diff --git a/gcc/config.gcc b/gcc/config.gcc
index 2c4d121..b67fdff 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -508,23 +508,29 @@ case ${target} in
     *-*-gnu*)
       tmake_file="$tmake_file t-gnu";;
   esac
-  # glibc / uclibc switch.  uclibc isn't usable for GNU/Hurd and neither for
-  # GNU/k*BSD.
+  # Common C libraries.
+  tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3"
+  # glibc / uclibc / bionic switch.
+  # uclibc and bionic aren't usable for GNU/Hurd and neither for GNU/k*BSD.
   case $target in
     *linux*)
       extra_options="$extra_options linux.opt";;
     *)
       tm_defines="$tm_defines OPTION_GLIBC=1";;
   esac
-  case ${target} in
+  case $target in
+    *-*-*android*)
+      tm_defines="$tm_defines DEFAULT_LIBC=LIBC_BIONIC"
+      ;;
     *-*-*uclibc*)
-      tm_defines="${tm_defines} UCLIBC_DEFAULT=1"
+      tm_defines="$tm_defines DEFAULT_LIBC=LIBC_UCLIBC"
       ;;
     *)
-      tm_defines="${tm_defines} UCLIBC_DEFAULT=0"
+      tm_defines="$tm_defines DEFAULT_LIBC=LIBC_GLIBC"
       ;;
   esac
-  # Assume that glibc or uClibc are being used and so __cxa_atexit is provided.
+  # Assume that glibc or uClibc or Bionic are being used and so __cxa_atexit
+  # is provided.
   default_use_cxa_atexit=yes
   use_gcc_tgmath=no
   use_gcc_stdint=wrap
@@ -826,7 +832,7 @@ bfin*-elf*)
 bfin*-uclinux*)
 	tm_file="${tm_file} dbxelf.h elfos.h bfin/elf.h linux.h glibc-stdint.h bfin/uclinux.h"
 	tmake_file=bfin/t-bfin-uclinux
-	tm_defines="${tm_defines} UCLIBC_DEFAULT=1"
+	tm_defines="${tm_defines} DEFAULT_LIBC=LIBC_UCLIBC"
 	extra_options="${extra_options} linux.opt"
 	use_collect2=no
 	;;
@@ -907,7 +913,7 @@ moxie-*-uclinux*)
 	tm_file="dbxelf.h elfos.h svr4.h ${tm_file} linux.h glibc-stdint.h moxie/uclinux.h"
 	extra_parts="crti.o crtn.o crtbegin.o crtend.o"
 	tmake_file="${tmake_file} moxie/t-moxie moxie/t-moxie-softfp soft-fp/t-softfp"
-	tm_defines="${tm_defines} UCLIBC_DEFAULT=1"
+	tm_defines="${tm_defines} DEFAULT_LIBC=LIBC_UCLIBC"
 	extra_options="${extra_options} linux.opt"
 	;;
 h8300-*-rtems*)
@@ -1620,7 +1626,7 @@ m68k-*-uclinux*)		# Motorola m68k/ColdFire running uClinux
 	default_m68k_cpu=68020
 	default_cf_cpu=5206
 	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"
- 	tm_defines="${tm_defines} MOTOROLA=1 UCLIBC_DEFAULT=1"
+ 	tm_defines="${tm_defines} MOTOROLA=1 DEFAULT_LIBC=LIBC_UCLIBC"
 	extra_options="${extra_options} linux.opt"
 	tmake_file="m68k/t-floatlib m68k/t-uclinux m68k/t-mlibs"
 	;;
diff --git a/gcc/config/alpha/linux-elf.h b/gcc/config/alpha/linux-elf.h
index c48fc93..262404b 100644
--- a/gcc/config/alpha/linux-elf.h
+++ b/gcc/config/alpha/linux-elf.h
@@ -29,10 +29,12 @@ along with GCC; see the file COPYING3.  If not see
 
 #define GLIBC_DYNAMIC_LINKER	"/lib/ld-linux.so.2"
 #define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
-#if UCLIBC_DEFAULT
-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:%{muclibc:%e-mglibc and -muclibc used together}" G ";:" U "}"
+#if DEFAULT_LIBC == LIBC_UCLIBC
+#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
+#elif DEFAULT_LIBC == LIBC_GLIBC
+#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}"
 #else
-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:%{mglibc:%e-mglibc and -muclibc used together}" U ";:" G "}"
+#error "Unsupported DEFAULT_LIBC"
 #endif
 #define LINUX_DYNAMIC_LINKER \
   CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER)
diff --git a/gcc/config/linux.h b/gcc/config/linux.h
index e567e9a..f86cc7b 100644
--- a/gcc/config/linux.h
+++ b/gcc/config/linux.h
@@ -1,6 +1,6 @@
 /* Definitions for Linux-based GNU systems with ELF format
    Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2003, 2004, 2005, 2006,
-   2007, 2009 Free Software Foundation, Inc.
+   2007, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Eric Youngdale.
    Modified for stabs-in-ELF by H.J. Lu (hjl@lucon.org).
 
@@ -78,9 +78,15 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    %{shared:-lc} \
    %{!shared:%{mieee-fp:-lieee} %{profile:-lc_p}%{!profile:-lc}}"
 
+/* C libraries supported on Linux.  */
+#define OPTION_GLIBC  (linux_libc == LIBC_GLIBC)
+#define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC)
+#define OPTION_BIONIC (linux_libc == LIBC_BIONIC)
+
 #define LINUX_TARGET_OS_CPP_BUILTINS()				\
     do {							\
-	builtin_define ("__gnu_linux__");			\
+	if (OPTION_GLIBC)					\
+	  builtin_define ("__gnu_linux__");			\
 	builtin_define_std ("linux");				\
 	builtin_define_std ("unix");				\
 	builtin_assert ("system=linux");			\
@@ -105,13 +111,24 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #endif
 
 /* Determine which dynamic linker to use depending on whether GLIBC or
-   uClibc is the default C library and whether -muclibc or -mglibc has
-   been passed to change the default.  */
-#if UCLIBC_DEFAULT
-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:%{muclibc:%e-mglibc and -muclibc used together}" G ";:" U "}"
+   uClibc or Bionic is the default C library and whether
+   -muclibc or -mglibc or -mbionic has been passed to change the default.  */
+
+#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LD1, LD2, LD3)	\
+  "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:" LD1 "}}"
+
+#if DEFAULT_LIBC == LIBC_GLIBC
+#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
+  CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", G, U, B)
+#elif DEFAULT_LIBC == LIBC_UCLIBC
+#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
+  CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", U, G, B)
+#elif DEFAULT_LIBC == LIBC_BIONIC
+#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
+  CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", B, G, U)
 #else
-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:%{mglibc:%e-mglibc and -muclibc used together}" U ";:" G "}"
-#endif
+#error "Unsupported DEFAULT_LIBC"
+#endif /* DEFAULT_LIBC */
 
 /* For most targets the following definitions suffice;
    GLIBC_DYNAMIC_LINKER must be defined for each target using them, or
@@ -120,18 +137,25 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
 #define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0"
 #define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0"
-#define LINUX_DYNAMIC_LINKER \
-  CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER)
-#define LINUX_DYNAMIC_LINKER32 \
-  CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32)
-#define LINUX_DYNAMIC_LINKER64 \
-  CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64)
+#define BIONIC_DYNAMIC_LINKER "/system/bin/linker"
+#define BIONIC_DYNAMIC_LINKER32 "/system/bin/linker"
+#define BIONIC_DYNAMIC_LINKER64 "/system/bin/linker64"
+
+#define LINUX_DYNAMIC_LINKER						\
+  CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER,	\
+			 BIONIC_DYNAMIC_LINKER)
+#define LINUX_DYNAMIC_LINKER32						\
+  CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, \
+			 BIONIC_DYNAMIC_LINKER32)
+#define LINUX_DYNAMIC_LINKER64						\
+  CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, \
+			 BIONIC_DYNAMIC_LINKER64)
 
 /* Determine whether the entire c99 runtime
    is present in the runtime library.  */
 #define TARGET_C99_FUNCTIONS (OPTION_GLIBC)
 
 /* Whether we have sincos that follows the GNU extension.  */
-#define TARGET_HAS_SINCOS (OPTION_GLIBC)
+#define TARGET_HAS_SINCOS (OPTION_GLIBC | OPTION_BIONIC)
 
 #define TARGET_POSIX_IO
diff --git a/gcc/config/linux.opt b/gcc/config/linux.opt
index a9b40f0..9ace3e3 100644
--- a/gcc/config/linux.opt
+++ b/gcc/config/linux.opt
@@ -1,6 +1,6 @@
 ; Processor-independent options for GNU/Linux.
 ;
-; Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc.
+; Copyright (C) 2006, 2007, 2009, 2010 Free Software Foundation, Inc.
 ; Contributed by CodeSourcery.
 ;
 ; This file is part of GCC.
@@ -19,10 +19,14 @@
 ; along with GCC; see the file COPYING3.  If not see
 ; <http://www.gnu.org/licenses/>.
 
+mbionic
+Target Report RejectNegative Var(linux_libc,LIBC_BIONIC) Init(DEFAULT_LIBC) Negative(mglibc)
+Use Bionic C library
+
 mglibc
-Target RejectNegative Report InverseMask(UCLIBC, GLIBC) Var(linux_uclibc) Init(UCLIBC_DEFAULT ? OPTION_MASK_UCLIBC : 0)
-Use GNU libc instead of uClibc
+Target Report RejectNegative Var(linux_libc,LIBC_GLIBC) VarExists Negative(muclibc)
+Use GNU C library
 
 muclibc
-Target RejectNegative Report Mask(UCLIBC) Var(linux_uclibc) VarExists
-Use uClibc instead of GNU libc
+Target Report RejectNegative Var(linux_libc,LIBC_UCLIBC) VarExists Negative(mbionic)
+Use uClibc C library
diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h
index da7bca3..502342c 100644
--- a/gcc/config/rs6000/linux64.h
+++ b/gcc/config/rs6000/linux64.h
@@ -352,10 +352,12 @@ extern int dot_symbols;
 #define GLIBC_DYNAMIC_LINKER64 "/lib64/ld64.so.1"
 #define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0"
 #define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0"
-#if UCLIBC_DEFAULT
-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:%{muclibc:%e-mglibc and -muclibc used together}" G ";:" U "}"
+#if DEFAULT_LIBC == LIBC_UCLIBC
+#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
+#elif DEFAULT_LIBC == LIBC_GLIBC
+#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}"
 #else
-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:%{mglibc:%e-mglibc and -muclibc used together}" U ";:" G "}"
+#error "Unsupported DEFAULT_LIBC"
 #endif
 #define LINUX_DYNAMIC_LINKER32 \
   CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32)
diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h
index 8d19ad7..2e6fbc7 100644
--- a/gcc/config/rs6000/sysv4.h
+++ b/gcc/config/rs6000/sysv4.h
@@ -903,10 +903,12 @@ SVR4_ASM_SPEC \
 
 #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
 #define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
-#if UCLIBC_DEFAULT
-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:%{muclibc:%e-mglibc and -muclibc used together}" G ";:" U "}"
+#if DEFAULT_LIBC == LIBC_UCLIBC
+#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
+#elif DEFAULT_LIBC == LIBC_GLIBC
+#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}"
 #else
-#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:%{mglibc:%e-mglibc and -muclibc used together}" U ";:" G "}"
+#error "Unsupported DEFAULT_LIBC"
 #endif
 #define LINUX_DYNAMIC_LINKER \
   CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER)
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 6afc713..a75196e 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -11462,13 +11462,18 @@ These @samp{-m} options are defined for GNU/Linux targets:
 @table @gcctabopt
 @item -mglibc
 @opindex mglibc
-Use the GNU C library instead of uClibc.  This is the default except
-on @samp{*-*-linux-*uclibc*} targets.
+Use the GNU C library.  This is the default except
+on @samp{*-*-linux-*uclibc*} and @samp{*-*-linux-*android*} targets.
 
 @item -muclibc
 @opindex muclibc
-Use uClibc instead of the GNU C library.  This is the default on
+Use uClibc C library.  This is the default on
 @samp{*-*-linux-*uclibc*} targets.
+
+@item -mbionic
+@opindex mbionic
+Use Bionic C library.  This is the default on
+@samp{*-*-linux-*android*} targets.
 @end table
 
 @node H8/300 Options
diff --git a/gcc/testsuite/gcc.dg/glibc-uclibc-1.c b/gcc/testsuite/gcc.dg/glibc-uclibc-1.c
deleted file mode 100644
index a376404..0000000
--- a/gcc/testsuite/gcc.dg/glibc-uclibc-1.c
+++ /dev/null
@@ -1,6 +0,0 @@
-/* Test -mglibc and -muclibc not allowed together.  */
-/* Origin: Joseph Myers <joseph@codesourcery.com> */
-/* { dg-do link { target *-*-linux* } } */
-/* { dg-options "-mglibc -muclibc" } */
-
-/* { dg-message "-mglibc and -muclibc used together" "" { target *-*-* } 0 } */
diff --git a/gcc/testsuite/gcc.dg/glibc-uclibc-2.c b/gcc/testsuite/gcc.dg/glibc-uclibc-2.c
deleted file mode 100644
index cb52260..0000000
--- a/gcc/testsuite/gcc.dg/glibc-uclibc-2.c
+++ /dev/null
@@ -1,6 +0,0 @@
-/* Test -mglibc and -muclibc not allowed together.  */
-/* Origin: Joseph Myers <joseph@codesourcery.com> */
-/* { dg-do link { target *-*-linux* } } */
-/* { dg-options "-muclibc -mglibc" } */
-
-/* { dg-message "-mglibc and -muclibc used together" "" { target *-*-* } 0 } */
-- 
1.6.2.4


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [PATCH 4/6] Add multilib configuration for arm-linux-androideabi
  2010-05-20 15:59 [PATCH 0/6] Add support for Android Maxim Kuvyrkov
                   ` (2 preceding siblings ...)
  2010-05-20 16:06 ` [PATCH 3/6] Support compilation for Android platform Maxim Kuvyrkov
@ 2010-05-20 16:07 ` Maxim Kuvyrkov
  2010-05-28 15:24   ` Mark Mitchell
  2010-05-20 16:08 ` [PATCH 5/6] Fix gthr-posix.h to support Bionic Maxim Kuvyrkov
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 30+ messages in thread
From: Maxim Kuvyrkov @ 2010-05-20 16:07 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jing Yu

[-- Attachment #1: Type: text/plain, Size: 684 bytes --]

This patch defines multilibs for arm-linux-androideabi.  The multilib 
configuration defines 4 multilibs:

     ".;"
     "armv7-a;@march=armv7-a"
     "thumb;@mthumb"
     "armv7-a/thumb;@march=armv7-a@mthumb"

The default and thumb multilibs are built for whatever processor or ARM 
subarchitecture one defines with "--with-arch=" configure switch.

The "special" axis of multilibs (disabled by default) is built with 
"-tno-android-cc" option.  These multilibs are intended for building the 
Linux kernel and select Android applications that require C++ RTTI and 
EH support.

OK to check in?

Thank you,

-- 
Maxim Kuvyrkov
CodeSourcery
maxim@codesourcery.com
(650) 331-3385 x724

[-- Attachment #2: 0004-Add-multilib-configuration-for-arm-linux-androideabi.ChangeLog --]
[-- Type: text/plain, Size: 174 bytes --]

2010-05-20  Maxim Kuvyrkov  <maxim@codesourcery.com>

	gcc/
	* config/arm/t-linux-androideabi: New.
	* config.gcc (arm*-*-linux-androideabi): Include multilib configuration.

[-- Attachment #3: 0004-Add-multilib-configuration-for-arm-linux-androideabi.patch --]
[-- Type: text/plain, Size: 1781 bytes --]

From bd34d1214d98c8bcba632b5e629e90a154974384 Mon Sep 17 00:00:00 2001
From: Maxim Kuvyrkov <maxim@codesourcery.com>
Date: Wed, 19 May 2010 02:16:25 -0700
Subject: [PATCH 4/7] Add multilib configuration for arm-linux-androideabi


Signed-off-by: Maxim Kuvyrkov <maxim@codesourcery.com>
---
 gcc/config.gcc                     |    6 ++++++
 gcc/config/arm/t-linux-androideabi |   10 ++++++++++
 2 files changed, 16 insertions(+), 0 deletions(-)
 create mode 100644 gcc/config/arm/t-linux-androideabi

diff --git a/gcc/config.gcc b/gcc/config.gcc
index d799caa..d50107b 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -744,6 +744,12 @@ arm*-*-linux*)			# ARM GNU/Linux with ELF
 	arm*-*-linux-*eabi)
 	    tm_file="$tm_file arm/bpabi.h arm/linux-eabi.h"
 	    tmake_file="$tmake_file arm/t-arm-elf arm/t-bpabi arm/t-linux-eabi t-slibgcc-libgcc"
+	    # Define multilib configuration for arm-linux-androideabi.
+	    case ${target} in
+	    *-androideabi)
+		tmake_file="$tmake_file arm/t-linux-androideabi"
+		;;
+	    esac
   	    # The BPABI long long divmod functions return a 128-bit value in
 	    # registers r0-r3.  Correctly modeling that requires the use of
 	    # TImode.
diff --git a/gcc/config/arm/t-linux-androideabi b/gcc/config/arm/t-linux-androideabi
new file mode 100644
index 0000000..8f1307c
--- /dev/null
+++ b/gcc/config/arm/t-linux-androideabi
@@ -0,0 +1,10 @@
+MULTILIB_OPTIONS     = march=armv7-a mthumb
+MULTILIB_DIRNAMES    = armv7-a thumb
+MULTILIB_EXCEPTIONS  =
+MULTILIB_MATCHES     =
+MULTILIB_OSDIRNAMES  =
+
+# The "special" multilib can be used to build native applications for Android,
+# as opposed to native shared libraries that are then called via JNI.
+#MULTILIB_OPTIONS    += tno-android-cc
+#MULTILIB_DIRNAMES   += special
-- 
1.6.2.4


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [PATCH 5/6] Fix gthr-posix.h to support Bionic
  2010-05-20 15:59 [PATCH 0/6] Add support for Android Maxim Kuvyrkov
                   ` (3 preceding siblings ...)
  2010-05-20 16:07 ` [PATCH 4/6] Add multilib configuration for arm-linux-androideabi Maxim Kuvyrkov
@ 2010-05-20 16:08 ` Maxim Kuvyrkov
  2010-05-25 15:06   ` Mark Mitchell
  2010-05-20 16:10 ` [PATCH 6/6] Add [untested] support for Bionic to libstdc++ Maxim Kuvyrkov
  2010-05-29 17:33 ` [PATCH 0/6] Add support for Android Gerald Pfeifer
  6 siblings, 1 reply; 30+ messages in thread
From: Maxim Kuvyrkov @ 2010-05-20 16:08 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jing Yu

[-- Attachment #1: Type: text/plain, Size: 242 bytes --]

Bionic C library explicitly does not support thread cancellation.  This 
patch workarounds dependency of gthr-posix.h on pthread_cancel.

OK to check in?

Thank you,

-- 
Maxim Kuvyrkov
CodeSourcery
maxim@codesourcery.com
(650) 331-3385 x724

[-- Attachment #2: 0005-Fix-gthr-posix.h-to-support-Bionic.ChangeLog --]
[-- Type: text/plain, Size: 237 bytes --]

2010-05-20  Maxim Kuvyrkov  <maxim@codesourcery.com>

	gcc/
	* gthr-posix.h (pthread_cancel): Don't declare if compiling against
	Bionic C library.
	(__gthread_active_p): Check for pthread_create if compiling against
	Bionic C library.


[-- Attachment #3: 0005-Fix-gthr-posix.h-to-support-Bionic.patch --]
[-- Type: text/plain, Size: 1176 bytes --]

From 9fd6bcfe09e4dbe607b3cc5f533f414b519890a0 Mon Sep 17 00:00:00 2001
From: Maxim Kuvyrkov <maxim@codesourcery.com>
Date: Tue, 4 May 2010 02:25:50 -0700
Subject: [PATCH 5/7] Fix gthr-posix.h to support Bionic


Signed-off-by: Maxim Kuvyrkov <maxim@codesourcery.com>
---
 gcc/gthr-posix.h |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/gcc/gthr-posix.h b/gcc/gthr-posix.h
index 61b4dda..a7ce311 100644
--- a/gcc/gthr-posix.h
+++ b/gcc/gthr-posix.h
@@ -124,7 +124,9 @@ __gthrw(pthread_join)
 __gthrw(pthread_equal)
 __gthrw(pthread_self)
 __gthrw(pthread_detach)
+#ifndef __BIONIC__
 __gthrw(pthread_cancel)
+#endif
 __gthrw(sched_yield)
 
 __gthrw(pthread_mutex_lock)
@@ -238,7 +240,15 @@ static inline int
 __gthread_active_p (void)
 {
   static void *const __gthread_active_ptr
-    = __extension__ (void *) &__gthrw_(pthread_cancel);
+    = __extension__ (void *) &__gthrw_(
+/* Android's C library does not provide pthread_cancel, check for
+   `pthread_create' instead.  */
+#ifndef __BIONIC__
+				       pthread_cancel
+#else
+				       pthread_create
+#endif
+				       );
   return __gthread_active_ptr != 0;
 }
 
-- 
1.6.2.4


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [PATCH 6/6] Add [untested] support for Bionic to libstdc++
  2010-05-20 15:59 [PATCH 0/6] Add support for Android Maxim Kuvyrkov
                   ` (4 preceding siblings ...)
  2010-05-20 16:08 ` [PATCH 5/6] Fix gthr-posix.h to support Bionic Maxim Kuvyrkov
@ 2010-05-20 16:10 ` Maxim Kuvyrkov
  2010-06-01  9:36   ` [PATCH 6/6] Add " Maxim Kuvyrkov
  2010-05-29 17:33 ` [PATCH 0/6] Add support for Android Gerald Pfeifer
  6 siblings, 1 reply; 30+ messages in thread
From: Maxim Kuvyrkov @ 2010-05-20 16:10 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jing Yu

[-- Attachment #1: Type: text/plain, Size: 169 bytes --]

This patch adds lightly tested support for Bionic to libstdc++.

OK to check in?

Thank you,

-- 
Maxim Kuvyrkov
CodeSourcery
maxim@codesourcery.com
(650) 331-3385 x724

[-- Attachment #2: 0006-Add-untested-support-for-Bionic-to-libstdc.ChangeLog --]
[-- Type: text/plain, Size: 416 bytes --]

2010-05-20  Maxim Kuvyrkov  <maxim@codesourcery.com>

	libstdc++-v3/
	* acinclude.m4: Support Bionic C library.
	Explicitly specify -fexceptions for exception check.
	* configure.host: Support Bionic C library.
	* configure: Regenerate.
	* config/os/bionic/ctype_base.h, config/os/bionic/ctype_inline.h,
	* config/os/bionic/ctype_noincline.h, config/os/bionic/os_defines.h:
	New files, based on config/os/newlib/*.


[-- Attachment #3: 0006-Add-untested-support-for-Bionic-to-libstdc.patch --]
[-- Type: text/plain, Size: 15576 bytes --]

From 3f8980a5aa4cf3d2d5e6f5cc138246adadf905d0 Mon Sep 17 00:00:00 2001
From: Maxim Kuvyrkov <maxim@codesourcery.com>
Date: Wed, 5 May 2010 10:46:10 -0700
Subject: [PATCH 6/7] Add [untested] support for Bionic to libstdc++


Signed-off-by: Maxim Kuvyrkov <maxim@codesourcery.com>
---
 libstdc++-v3/acinclude.m4                       |   11 ++-
 libstdc++-v3/config/os/bionic/ctype_base.h      |   57 +++++++++++++
 libstdc++-v3/config/os/bionic/ctype_inline.h    |   71 ++++++++++++++++
 libstdc++-v3/config/os/bionic/ctype_noninline.h |   98 +++++++++++++++++++++++
 libstdc++-v3/config/os/bionic/os_defines.h      |   36 ++++++++
 libstdc++-v3/configure                          |   38 +++++++---
 libstdc++-v3/configure.host                     |    2 +
 7 files changed, 301 insertions(+), 12 deletions(-)
 create mode 100644 libstdc++-v3/config/os/bionic/ctype_base.h
 create mode 100644 libstdc++-v3/config/os/bionic/ctype_inline.h
 create mode 100644 libstdc++-v3/config/os/bionic/ctype_noninline.h
 create mode 100644 libstdc++-v3/config/os/bionic/os_defines.h

diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index f54517f..1ccde58 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -95,7 +95,7 @@ AC_DEFUN([GLIBCXX_CONFIGURE], [
   ## (Right now, this only matters for enable_wchar_t, but nothing prevents
   ## other macros from doing the same.  This should be automated.)  -pme
 
-  # Check for uClibc since Linux platforms use different configuration
+  # Check for C library flavor since Linux platforms use different configuration
   # directories depending on the C library in use.
   AC_EGREP_CPP([_using_uclibc], [
   #include <stdio.h>
@@ -104,6 +104,13 @@ AC_DEFUN([GLIBCXX_CONFIGURE], [
   #endif
   ], uclibc=yes, uclibc=no)
 
+  AC_EGREP_CPP([_using_bionic], [
+  #include <stdio.h>
+  #if __BIONIC__
+    _using_bionic
+  #endif
+  ], bionic=yes, bionic=no)
+
   # Find platform-specific directories containing configuration info.
   # Also possibly modify flags used elsewhere, as needed by the platform.
   GLIBCXX_CHECK_HOST
@@ -2752,7 +2759,7 @@ void foo()
 }
 EOF
     old_CXXFLAGS="$CXXFLAGS"
-    CXXFLAGS=-S
+    CXXFLAGS="-S -fexceptions"
     if AC_TRY_EVAL(ac_compile); then
       if grep _Unwind_SjLj_Resume conftest.s >/dev/null 2>&1 ; then
         enable_sjlj_exceptions=yes
diff --git a/libstdc++-v3/config/os/bionic/ctype_base.h b/libstdc++-v3/config/os/bionic/ctype_base.h
new file mode 100644
index 0000000..15f0063
--- /dev/null
+++ b/libstdc++-v3/config/os/bionic/ctype_base.h
@@ -0,0 +1,57 @@
+// Locale support -*- C++ -*-
+
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+// <http://www.gnu.org/licenses/>.
+
+//
+// ISO C++ 14882: 22.1  Locales
+//
+
+// Information as gleaned from /usr/include/ctype.h, for solaris2.5.1
+
+// Support for Solaris 2.5.1
+
+_GLIBCXX_BEGIN_NAMESPACE(std)
+
+  /// @brief  Base class for ctype.
+  struct ctype_base
+  {
+    // Non-standard typedefs.
+    typedef const int* 		__to_type;
+
+    // NB: Offsets into ctype<char>::_M_table force a particular size
+    // on the mask type. Because of this, we don't use an enum.
+    typedef char 		mask;
+    static const mask upper    	= _U;
+    static const mask lower 	= _L;
+    static const mask alpha 	= _U | _L;
+    static const mask digit 	= _N;
+    static const mask xdigit 	= _X | _N;
+    static const mask space 	= _S;
+    static const mask print 	= _P | _U | _L | _N | _B;
+    static const mask graph 	= _P | _U | _L | _N;
+    static const mask cntrl 	= _C;
+    static const mask punct 	= _P;
+    static const mask alnum 	= _U | _L | _N;
+  };
+
+_GLIBCXX_END_NAMESPACE
diff --git a/libstdc++-v3/config/os/bionic/ctype_inline.h b/libstdc++-v3/config/os/bionic/ctype_inline.h
new file mode 100644
index 0000000..2c88eb6
--- /dev/null
+++ b/libstdc++-v3/config/os/bionic/ctype_inline.h
@@ -0,0 +1,71 @@
+// Locale support -*- C++ -*-
+
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+// <http://www.gnu.org/licenses/>.
+
+/** @file ctype_inline.h
+ *  This is an internal header file, included by other library headers.
+ *  You should not attempt to use it directly.
+ */
+
+//
+// ISO C++ 14882: 22.1  Locales
+//
+
+// ctype bits to be inlined go here. Non-inlinable (ie virtual do_*)
+// functions go in ctype.cc
+
+_GLIBCXX_BEGIN_NAMESPACE(std)
+
+  bool
+  ctype<char>::
+  is(mask __m, char __c) const
+  { return _M_table[static_cast<unsigned char>(__c)] & __m; }
+
+  const char*
+  ctype<char>::
+  is(const char* __low, const char* __high, mask* __vec) const
+  {
+    while (__low < __high)
+      *__vec++ = _M_table[static_cast<unsigned char>(*__low++)];
+    return __high;
+  }
+
+  const char*
+  ctype<char>::
+  scan_is(mask __m, const char* __low, const char* __high) const
+  {
+    while (__low < __high && !this->is(__m, *__low))
+      ++__low;
+    return __low;
+  }
+
+  const char*
+  ctype<char>::
+  scan_not(mask __m, const char* __low, const char* __high) const
+  {
+    while (__low < __high && this->is(__m, *__low) != 0)
+      ++__low;
+    return __low;
+  }
+
+_GLIBCXX_END_NAMESPACE
diff --git a/libstdc++-v3/config/os/bionic/ctype_noninline.h b/libstdc++-v3/config/os/bionic/ctype_noninline.h
new file mode 100644
index 0000000..55eecd8
--- /dev/null
+++ b/libstdc++-v3/config/os/bionic/ctype_noninline.h
@@ -0,0 +1,98 @@
+// Locale support -*- C++ -*-
+
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+// <http://www.gnu.org/licenses/>.
+
+/** @file ctype_noninline.h
+ *  This is an internal header file, included by other library headers.
+ *  You should not attempt to use it directly.
+ */
+
+//
+// ISO C++ 14882: 22.1  Locales
+//
+
+// Information as gleaned from /usr/include/ctype.h
+
+  const ctype_base::mask*
+  ctype<char>::classic_table() throw()
+  { return _ctype_ + 1; }
+
+  ctype<char>::ctype(__c_locale, const mask* __table, bool __del,
+		     size_t __refs)
+  : facet(__refs), _M_del(__table != 0 && __del),
+  _M_toupper(NULL), _M_tolower(NULL),
+  _M_table(__table ? __table : classic_table())
+  {
+    memset(_M_widen, 0, sizeof(_M_widen));
+    _M_widen_ok = 0;
+    memset(_M_narrow, 0, sizeof(_M_narrow));
+    _M_narrow_ok = 0;
+  }
+
+  ctype<char>::ctype(const mask* __table, bool __del, size_t __refs)
+  : facet(__refs), _M_del(__table != 0 && __del),
+  _M_toupper(NULL), _M_tolower(NULL),
+  _M_table(__table ? __table : classic_table())
+  {
+    memset(_M_widen, 0, sizeof(_M_widen));
+    _M_widen_ok = 0;
+    memset(_M_narrow, 0, sizeof(_M_narrow));
+    _M_narrow_ok = 0;
+  }
+
+  char
+  ctype<char>::do_toupper(char __c) const
+  {
+    int __x = __c;
+    return (this->is(ctype_base::lower, __c) ? (__x - 'a' + 'A') : __x);
+  }
+
+  const char*
+  ctype<char>::do_toupper(char* __low, const char* __high) const
+  {
+    while (__low < __high)
+      {
+	*__low = this->do_toupper(*__low);
+	++__low;
+      }
+    return __high;
+  }
+
+  char
+  ctype<char>::do_tolower(char __c) const
+  {
+    int __x = __c;
+    return (this->is(ctype_base::upper, __c) ? (__x - 'A' + 'a') : __x);
+  }
+
+  const char*
+  ctype<char>::do_tolower(char* __low, const char* __high) const
+  {
+    while (__low < __high)
+      {
+	*__low = this->do_tolower(*__low);
+	++__low;
+      }
+    return __high;
+  }
+
diff --git a/libstdc++-v3/config/os/bionic/os_defines.h b/libstdc++-v3/config/os/bionic/os_defines.h
new file mode 100644
index 0000000..832592a
--- /dev/null
+++ b/libstdc++-v3/config/os/bionic/os_defines.h
@@ -0,0 +1,36 @@
+// Specific definitions for Bionic  -*- C++ -*-
+
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+// <http://www.gnu.org/licenses/>.
+
+/** @file os_defines.h
+ *  This is an internal header file, included by other library headers.
+ *  You should not attempt to use it directly.
+ */
+
+#ifndef _GLIBCXX_OS_DEFINES
+#define _GLIBCXX_OS_DEFINES 1
+
+// System-specific #define, typedefs, corrections, etc, go here.  This
+// file will come before all others.
+
+#endif
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index df45a86..d0db77a 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -5186,7 +5186,7 @@ fi
   ## (Right now, this only matters for enable_wchar_t, but nothing prevents
   ## other macros from doing the same.  This should be automated.)  -pme
 
-  # Check for uClibc since Linux platforms use different configuration
+  # Check for C library flavor since Linux platforms use different configuration
   # directories depending on the C library in use.
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
@@ -5206,6 +5206,24 @@ fi
 rm -f conftest*
 
 
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+  #include <stdio.h>
+  #if __BIONIC__
+    _using_bionic
+  #endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "_using_bionic" >/dev/null 2>&1; then :
+  bionic=yes
+else
+  bionic=no
+fi
+rm -f conftest*
+
+
   # Find platform-specific directories containing configuration info.
   # Also possibly modify flags used elsewhere, as needed by the platform.
 
@@ -11442,7 +11460,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11445 "configure"
+#line 11463 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11548,7 +11566,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11551 "configure"
+#line 11569 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -14888,7 +14906,7 @@ fi
     #
     # Fake what AC_TRY_COMPILE does.  XXX Look at redoing this new-style.
     cat > conftest.$ac_ext << EOF
-#line 14891 "configure"
+#line 14909 "configure"
 struct S { ~S(); };
 void bar();
 void foo()
@@ -14898,7 +14916,7 @@ void foo()
 }
 EOF
     old_CXXFLAGS="$CXXFLAGS"
-    CXXFLAGS=-S
+    CXXFLAGS="-S -fexceptions"
     if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
@@ -15256,7 +15274,7 @@ $as_echo "$glibcxx_cv_atomic_long_long" >&6; }
   # Fake what AC_TRY_COMPILE does.
 
     cat > conftest.$ac_ext << EOF
-#line 15259 "configure"
+#line 15277 "configure"
 int main()
 {
   typedef bool atomic_type;
@@ -15293,7 +15311,7 @@ $as_echo "$glibcxx_cv_atomic_bool" >&6; }
     rm -f conftest*
 
     cat > conftest.$ac_ext << EOF
-#line 15296 "configure"
+#line 15314 "configure"
 int main()
 {
   typedef short atomic_type;
@@ -15330,7 +15348,7 @@ $as_echo "$glibcxx_cv_atomic_short" >&6; }
     rm -f conftest*
 
     cat > conftest.$ac_ext << EOF
-#line 15333 "configure"
+#line 15351 "configure"
 int main()
 {
   // NB: _Atomic_word not necessarily int.
@@ -15368,7 +15386,7 @@ $as_echo "$glibcxx_cv_atomic_int" >&6; }
     rm -f conftest*
 
     cat > conftest.$ac_ext << EOF
-#line 15371 "configure"
+#line 15389 "configure"
 int main()
 {
   typedef long long atomic_type;
@@ -15444,7 +15462,7 @@ $as_echo "$as_me: WARNING: Performance of certain classes will degrade as a resu
   # unnecessary for this test.
 
     cat > conftest.$ac_ext << EOF
-#line 15447 "configure"
+#line 15465 "configure"
 int main()
 {
   _Decimal32 d1;
diff --git a/libstdc++-v3/configure.host b/libstdc++-v3/configure.host
index c1f2736..5cd2a21 100644
--- a/libstdc++-v3/configure.host
+++ b/libstdc++-v3/configure.host
@@ -238,6 +238,8 @@ case "${host_os}" in
   gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu)
     if [ "$uclibc" = "yes" ]; then
       os_include_dir="os/uclibc"
+    elif [ "$bionic" = "yes" ]; then
+      os_include_dir="os/bionic"
     else
       os_include_dir="os/gnu-linux"
     fi
-- 
1.6.2.4


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 1/6] Add *-linux-android* target
  2010-05-20 16:03 ` [PATCH 1/6] Add *-linux-android* target Maxim Kuvyrkov
@ 2010-05-20 17:29   ` Joseph S. Myers
  2010-05-25 14:11     ` Maxim Kuvyrkov
  0 siblings, 1 reply; 30+ messages in thread
From: Joseph S. Myers @ 2010-05-20 17:29 UTC (permalink / raw)
  To: Maxim Kuvyrkov; +Cc: gcc-patches, Jing Yu

On Thu, 20 May 2010, Maxim Kuvyrkov wrote:

> This patch updates config.sub to recognize *linux-android*.

config.sub patches need to go to config-patches@gnu.org.  Once accepted 
upstream, you can commit the latest version from config.git to both gcc 
and src repositories without needing further approval (see svnwrite.html 
and codingconventions.html).

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 1/6] Add *-linux-android* target
  2010-05-20 17:29   ` Joseph S. Myers
@ 2010-05-25 14:11     ` Maxim Kuvyrkov
  0 siblings, 0 replies; 30+ messages in thread
From: Maxim Kuvyrkov @ 2010-05-25 14:11 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: gcc-patches, Jing Yu

On 5/20/10 8:28 PM, Joseph S. Myers wrote:
> On Thu, 20 May 2010, Maxim Kuvyrkov wrote:
>
>> This patch updates config.sub to recognize *linux-android*.
>
> config.sub patches need to go to config-patches@gnu.org.  Once accepted
> upstream, you can commit the latest version from config.git to both gcc
> and src repositories without needing further approval (see svnwrite.html
> and codingconventions.html).

Thanks for the pointer.

Ben Elliston merged the patch to config.git and I updated config.sub and 
config.guess in GCC.

-- 
Maxim Kuvyrkov
CodeSourcery
maxim@codesourcery.com
(650) 331-3385 x724

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 2/6] Add support for Bionic C library
  2010-05-20 16:06   ` Maxim Kuvyrkov
@ 2010-05-25 15:00     ` Mark Mitchell
  2010-06-13 18:58     ` mips-linux bootstrap broken was: " Laurent GUERBY
  1 sibling, 0 replies; 30+ messages in thread
From: Mark Mitchell @ 2010-05-25 15:00 UTC (permalink / raw)
  To: Maxim Kuvyrkov; +Cc: gcc-patches, Jing Yu

Maxim Kuvyrkov wrote:

>> This patch adds new -mbionic option to select Bionic C library.  The
>> option is made similar to -mglibc and -muclibc.
>>
>> OK to check in?

OK.

-- 
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 3/6] Support compilation for Android platform
  2010-05-20 16:06 ` [PATCH 3/6] Support compilation for Android platform Maxim Kuvyrkov
@ 2010-05-25 15:06   ` Mark Mitchell
  0 siblings, 0 replies; 30+ messages in thread
From: Mark Mitchell @ 2010-05-25 15:06 UTC (permalink / raw)
  To: Maxim Kuvyrkov; +Cc: gcc-patches, Jing Yu

Maxim Kuvyrkov wrote:

> This patch reimplements "-mandroid" option and adds it for all *linux*
> targets.

I like that idea.

> OK to check in?

OK.

-- 
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 5/6] Fix gthr-posix.h to support Bionic
  2010-05-20 16:08 ` [PATCH 5/6] Fix gthr-posix.h to support Bionic Maxim Kuvyrkov
@ 2010-05-25 15:06   ` Mark Mitchell
  2010-05-25 15:23     ` Jakub Jelinek
  0 siblings, 1 reply; 30+ messages in thread
From: Mark Mitchell @ 2010-05-25 15:06 UTC (permalink / raw)
  To: Maxim Kuvyrkov; +Cc: gcc-patches, Jing Yu

Maxim Kuvyrkov wrote:
> Bionic C library explicitly does not support thread cancellation.  This
> patch workarounds dependency of gthr-posix.h on pthread_cancel.
> 
> OK to check in?

+    = __extension__ (void *) &__gthrw_(
+/* Android's C library does not provide pthread_cancel, check for
+   `pthread_create' instead.  */
+#ifndef __BIONIC__
+				       pthread_cancel
+#else
+				       pthread_create
+#endif
+				       );

Is there a reason not to use pthread_create on all platforms?   I
understand that you were being conservative; you didn't want to change
behavior on any other system.  That makes sense, but I'm wondering if
there's a way to avoid having a conditional here?  As I understand it,
we just need *some* function that has a non-NULL value when POSIX
threads are available?

Thanks,

-- 
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 5/6] Fix gthr-posix.h to support Bionic
  2010-05-25 15:06   ` Mark Mitchell
@ 2010-05-25 15:23     ` Jakub Jelinek
  2010-05-25 20:44       ` Mark Mitchell
  0 siblings, 1 reply; 30+ messages in thread
From: Jakub Jelinek @ 2010-05-25 15:23 UTC (permalink / raw)
  To: Mark Mitchell; +Cc: Maxim Kuvyrkov, gcc-patches, Jing Yu

On Tue, May 25, 2010 at 07:55:12AM -0700, Mark Mitchell wrote:
> Maxim Kuvyrkov wrote:
> > Bionic C library explicitly does not support thread cancellation.  This
> > patch workarounds dependency of gthr-posix.h on pthread_cancel.
> > 
> > OK to check in?
> 
> +    = __extension__ (void *) &__gthrw_(
> +/* Android's C library does not provide pthread_cancel, check for
> +   `pthread_create' instead.  */
> +#ifndef __BIONIC__
> +				       pthread_cancel
> +#else
> +				       pthread_create
> +#endif
> +				       );
> 
> Is there a reason not to use pthread_create on all platforms?   I

Yes.  See http://gcc.gnu.org/ml/gcc-patches/2005-01/msg00704.html

	Jakub

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 5/6] Fix gthr-posix.h to support Bionic
  2010-05-25 15:23     ` Jakub Jelinek
@ 2010-05-25 20:44       ` Mark Mitchell
  0 siblings, 0 replies; 30+ messages in thread
From: Mark Mitchell @ 2010-05-25 20:44 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Maxim Kuvyrkov, gcc-patches, Jing Yu

Jakub Jelinek wrote:

>> Is there a reason not to use pthread_create on all platforms?   I
> 
> Yes.  See http://gcc.gnu.org/ml/gcc-patches/2005-01/msg00704.html

What about using pthread_join or pthread_self or pthread_once?

This isn't a huge deal; just seems nice not to have to conditionalize
this.  Maxim, if nothing better emerges, your patch is OK in 24 hours.

Thanks,

-- 
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 4/6] Add multilib configuration for arm-linux-androideabi
  2010-05-20 16:07 ` [PATCH 4/6] Add multilib configuration for arm-linux-androideabi Maxim Kuvyrkov
@ 2010-05-28 15:24   ` Mark Mitchell
  0 siblings, 0 replies; 30+ messages in thread
From: Mark Mitchell @ 2010-05-28 15:24 UTC (permalink / raw)
  To: Maxim Kuvyrkov; +Cc: gcc-patches, Jing Yu

Maxim Kuvyrkov wrote:

> This patch defines multilibs for arm-linux-androideabi.  The multilib
> configuration defines 4 multilibs:
> 
>     ".;"
>     "armv7-a;@march=armv7-a"
>     "thumb;@mthumb"
>     "armv7-a/thumb;@march=armv7-a@mthumb"
> 
> The default and thumb multilibs are built for whatever processor or ARM
> subarchitecture one defines with "--with-arch=" configure switch.

Since the ARM maintainers haven't commented specifically, this patch is
OK.

(I think that in general what set of multilibs are built for a given
triplet isn't too big a deal; even though we put these things into the
GCC source code, the set of multilibs is *logically* a configure-time
option, not a source-code option.  In practice, people who don't like
the set of multilibs edit the code before building the compiler.)

-- 
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 0/6] Add support for Android
  2010-05-20 15:59 [PATCH 0/6] Add support for Android Maxim Kuvyrkov
                   ` (5 preceding siblings ...)
  2010-05-20 16:10 ` [PATCH 6/6] Add [untested] support for Bionic to libstdc++ Maxim Kuvyrkov
@ 2010-05-29 17:33 ` Gerald Pfeifer
  2010-05-30 15:23   ` Maxim Kuvyrkov
  6 siblings, 1 reply; 30+ messages in thread
From: Gerald Pfeifer @ 2010-05-29 17:33 UTC (permalink / raw)
  To: Maxim Kuvyrkov; +Cc: gcc-patches, Jing Yu

Hi Maxim,

On Thu, 20 May 2010, Maxim Kuvyrkov wrote:
> The following series of patches adds Android support to GCC.

would you mind adding a note on this to gcc-4.6/changes.html, too?

(I assume it's not sufficiently large for a news item on the main
page, correct?)

Gerald

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 0/6] Add support for Android
  2010-05-29 17:33 ` [PATCH 0/6] Add support for Android Gerald Pfeifer
@ 2010-05-30 15:23   ` Maxim Kuvyrkov
  0 siblings, 0 replies; 30+ messages in thread
From: Maxim Kuvyrkov @ 2010-05-30 15:23 UTC (permalink / raw)
  To: Gerald Pfeifer; +Cc: gcc-patches, Jing Yu

[-- Attachment #1: Type: text/plain, Size: 376 bytes --]

On 5/29/10 8:57 PM, Gerald Pfeifer wrote:
> Hi Maxim,
>
> On Thu, 20 May 2010, Maxim Kuvyrkov wrote:
>> The following series of patches adds Android support to GCC.
>
> would you mind adding a note on this to gcc-4.6/changes.html, too?

Here is what I checked in; feel free to copy-edit.

Thank you,

-- 
Maxim Kuvyrkov
CodeSourcery
maxim@codesourcery.com
(650) 331-3385 x724

[-- Attachment #2: wwwdocs.patch --]
[-- Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 6/6] Add support for Bionic to libstdc++
  2010-05-20 16:10 ` [PATCH 6/6] Add [untested] support for Bionic to libstdc++ Maxim Kuvyrkov
@ 2010-06-01  9:36   ` Maxim Kuvyrkov
  2010-06-01  9:45     ` Paolo Carlini
  0 siblings, 1 reply; 30+ messages in thread
From: Maxim Kuvyrkov @ 2010-06-01  9:36 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jing Yu, Paolo Carlini, libstdc++

[-- Attachment #1: Type: text/plain, Size: 822 bytes --]

On 5/20/10 8:07 PM, Maxim Kuvyrkov wrote:
> This patch adds lightly tested support for Bionic to libstdc++.

Here are a few additional notes and an updated patch; the only change is 
removal of the explicit "-fexceptions" option from the libstdc++'s 
configure exception test.

The explicit "-fexceptions" was a leftover from my experiments on 
building libstdc++ without exceptions and RTTI, which are the defaults 
when compiling for Android.

The patch is quite simple, the main bulk of the changes -- 
config/os/bionic/* -- is a copy of config/os/newlib/* with minor 
adjustments to remove unnecessary handling of Cygwin.

The patch was tested by Jing Yu and is on par with current libstdc++ 
support in Android.

OK to check in?

Thank you,

-- 
Maxim Kuvyrkov
CodeSourcery
maxim@codesourcery.com
(650) 331-3385 x724

[-- Attachment #2: 0006-Add-support-for-Bionic-to-libstdc.ChangeLog --]
[-- Type: text/plain, Size: 333 bytes --]

2010-05-20  Maxim Kuvyrkov  <maxim@codesourcery.com>

	libstdc++-v3/
	* acinclude.m4, configure.host: Support Bionic C library.
	* configure: Regenerate.
	* config/os/bionic/ctype_base.h, config/os/bionic/ctype_inline.h,
	* config/os/bionic/ctype_noincline.h, config/os/bionic/os_defines.h:
	New files, based on config/os/newlib/*.


[-- Attachment #3: 0006-Add-support-for-Bionic-to-libstdc.patch --]
[-- Type: text/plain, Size: 14998 bytes --]

From 6087b475e3e03915e14ba7871d92150d638a5772 Mon Sep 17 00:00:00 2001
From: Maxim Kuvyrkov <maxim@codesourcery.com>
Date: Tue, 1 Jun 2010 02:25:50 -0700
Subject: [PATCH 6/6] Add support for Bionic to libstdc++

---
 libstdc++-v3/acinclude.m4                       |    9 ++-
 libstdc++-v3/config/os/bionic/ctype_base.h      |   57 +++++++++++++
 libstdc++-v3/config/os/bionic/ctype_inline.h    |   71 ++++++++++++++++
 libstdc++-v3/config/os/bionic/ctype_noninline.h |   98 +++++++++++++++++++++++
 libstdc++-v3/config/os/bionic/os_defines.h      |   36 ++++++++
 libstdc++-v3/configure                          |   36 ++++++--
 libstdc++-v3/configure.host                     |    2 +
 7 files changed, 299 insertions(+), 10 deletions(-)
 create mode 100644 libstdc++-v3/config/os/bionic/ctype_base.h
 create mode 100644 libstdc++-v3/config/os/bionic/ctype_inline.h
 create mode 100644 libstdc++-v3/config/os/bionic/ctype_noninline.h
 create mode 100644 libstdc++-v3/config/os/bionic/os_defines.h

diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index f54517f..042a504 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -95,7 +95,7 @@ AC_DEFUN([GLIBCXX_CONFIGURE], [
   ## (Right now, this only matters for enable_wchar_t, but nothing prevents
   ## other macros from doing the same.  This should be automated.)  -pme
 
-  # Check for uClibc since Linux platforms use different configuration
+  # Check for C library flavor since Linux platforms use different configuration
   # directories depending on the C library in use.
   AC_EGREP_CPP([_using_uclibc], [
   #include <stdio.h>
@@ -104,6 +104,13 @@ AC_DEFUN([GLIBCXX_CONFIGURE], [
   #endif
   ], uclibc=yes, uclibc=no)
 
+  AC_EGREP_CPP([_using_bionic], [
+  #include <stdio.h>
+  #if __BIONIC__
+    _using_bionic
+  #endif
+  ], bionic=yes, bionic=no)
+
   # Find platform-specific directories containing configuration info.
   # Also possibly modify flags used elsewhere, as needed by the platform.
   GLIBCXX_CHECK_HOST
diff --git a/libstdc++-v3/config/os/bionic/ctype_base.h b/libstdc++-v3/config/os/bionic/ctype_base.h
new file mode 100644
index 0000000..15f0063
--- /dev/null
+++ b/libstdc++-v3/config/os/bionic/ctype_base.h
@@ -0,0 +1,57 @@
+// Locale support -*- C++ -*-
+
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+// <http://www.gnu.org/licenses/>.
+
+//
+// ISO C++ 14882: 22.1  Locales
+//
+
+// Information as gleaned from /usr/include/ctype.h, for solaris2.5.1
+
+// Support for Solaris 2.5.1
+
+_GLIBCXX_BEGIN_NAMESPACE(std)
+
+  /// @brief  Base class for ctype.
+  struct ctype_base
+  {
+    // Non-standard typedefs.
+    typedef const int* 		__to_type;
+
+    // NB: Offsets into ctype<char>::_M_table force a particular size
+    // on the mask type. Because of this, we don't use an enum.
+    typedef char 		mask;
+    static const mask upper    	= _U;
+    static const mask lower 	= _L;
+    static const mask alpha 	= _U | _L;
+    static const mask digit 	= _N;
+    static const mask xdigit 	= _X | _N;
+    static const mask space 	= _S;
+    static const mask print 	= _P | _U | _L | _N | _B;
+    static const mask graph 	= _P | _U | _L | _N;
+    static const mask cntrl 	= _C;
+    static const mask punct 	= _P;
+    static const mask alnum 	= _U | _L | _N;
+  };
+
+_GLIBCXX_END_NAMESPACE
diff --git a/libstdc++-v3/config/os/bionic/ctype_inline.h b/libstdc++-v3/config/os/bionic/ctype_inline.h
new file mode 100644
index 0000000..2c88eb6
--- /dev/null
+++ b/libstdc++-v3/config/os/bionic/ctype_inline.h
@@ -0,0 +1,71 @@
+// Locale support -*- C++ -*-
+
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+// <http://www.gnu.org/licenses/>.
+
+/** @file ctype_inline.h
+ *  This is an internal header file, included by other library headers.
+ *  You should not attempt to use it directly.
+ */
+
+//
+// ISO C++ 14882: 22.1  Locales
+//
+
+// ctype bits to be inlined go here. Non-inlinable (ie virtual do_*)
+// functions go in ctype.cc
+
+_GLIBCXX_BEGIN_NAMESPACE(std)
+
+  bool
+  ctype<char>::
+  is(mask __m, char __c) const
+  { return _M_table[static_cast<unsigned char>(__c)] & __m; }
+
+  const char*
+  ctype<char>::
+  is(const char* __low, const char* __high, mask* __vec) const
+  {
+    while (__low < __high)
+      *__vec++ = _M_table[static_cast<unsigned char>(*__low++)];
+    return __high;
+  }
+
+  const char*
+  ctype<char>::
+  scan_is(mask __m, const char* __low, const char* __high) const
+  {
+    while (__low < __high && !this->is(__m, *__low))
+      ++__low;
+    return __low;
+  }
+
+  const char*
+  ctype<char>::
+  scan_not(mask __m, const char* __low, const char* __high) const
+  {
+    while (__low < __high && this->is(__m, *__low) != 0)
+      ++__low;
+    return __low;
+  }
+
+_GLIBCXX_END_NAMESPACE
diff --git a/libstdc++-v3/config/os/bionic/ctype_noninline.h b/libstdc++-v3/config/os/bionic/ctype_noninline.h
new file mode 100644
index 0000000..55eecd8
--- /dev/null
+++ b/libstdc++-v3/config/os/bionic/ctype_noninline.h
@@ -0,0 +1,98 @@
+// Locale support -*- C++ -*-
+
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+// <http://www.gnu.org/licenses/>.
+
+/** @file ctype_noninline.h
+ *  This is an internal header file, included by other library headers.
+ *  You should not attempt to use it directly.
+ */
+
+//
+// ISO C++ 14882: 22.1  Locales
+//
+
+// Information as gleaned from /usr/include/ctype.h
+
+  const ctype_base::mask*
+  ctype<char>::classic_table() throw()
+  { return _ctype_ + 1; }
+
+  ctype<char>::ctype(__c_locale, const mask* __table, bool __del,
+		     size_t __refs)
+  : facet(__refs), _M_del(__table != 0 && __del),
+  _M_toupper(NULL), _M_tolower(NULL),
+  _M_table(__table ? __table : classic_table())
+  {
+    memset(_M_widen, 0, sizeof(_M_widen));
+    _M_widen_ok = 0;
+    memset(_M_narrow, 0, sizeof(_M_narrow));
+    _M_narrow_ok = 0;
+  }
+
+  ctype<char>::ctype(const mask* __table, bool __del, size_t __refs)
+  : facet(__refs), _M_del(__table != 0 && __del),
+  _M_toupper(NULL), _M_tolower(NULL),
+  _M_table(__table ? __table : classic_table())
+  {
+    memset(_M_widen, 0, sizeof(_M_widen));
+    _M_widen_ok = 0;
+    memset(_M_narrow, 0, sizeof(_M_narrow));
+    _M_narrow_ok = 0;
+  }
+
+  char
+  ctype<char>::do_toupper(char __c) const
+  {
+    int __x = __c;
+    return (this->is(ctype_base::lower, __c) ? (__x - 'a' + 'A') : __x);
+  }
+
+  const char*
+  ctype<char>::do_toupper(char* __low, const char* __high) const
+  {
+    while (__low < __high)
+      {
+	*__low = this->do_toupper(*__low);
+	++__low;
+      }
+    return __high;
+  }
+
+  char
+  ctype<char>::do_tolower(char __c) const
+  {
+    int __x = __c;
+    return (this->is(ctype_base::upper, __c) ? (__x - 'A' + 'a') : __x);
+  }
+
+  const char*
+  ctype<char>::do_tolower(char* __low, const char* __high) const
+  {
+    while (__low < __high)
+      {
+	*__low = this->do_tolower(*__low);
+	++__low;
+      }
+    return __high;
+  }
+
diff --git a/libstdc++-v3/config/os/bionic/os_defines.h b/libstdc++-v3/config/os/bionic/os_defines.h
new file mode 100644
index 0000000..832592a
--- /dev/null
+++ b/libstdc++-v3/config/os/bionic/os_defines.h
@@ -0,0 +1,36 @@
+// Specific definitions for Bionic  -*- C++ -*-
+
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+// <http://www.gnu.org/licenses/>.
+
+/** @file os_defines.h
+ *  This is an internal header file, included by other library headers.
+ *  You should not attempt to use it directly.
+ */
+
+#ifndef _GLIBCXX_OS_DEFINES
+#define _GLIBCXX_OS_DEFINES 1
+
+// System-specific #define, typedefs, corrections, etc, go here.  This
+// file will come before all others.
+
+#endif
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index df45a86..59916ed 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -5186,7 +5186,7 @@ fi
   ## (Right now, this only matters for enable_wchar_t, but nothing prevents
   ## other macros from doing the same.  This should be automated.)  -pme
 
-  # Check for uClibc since Linux platforms use different configuration
+  # Check for C library flavor since Linux platforms use different configuration
   # directories depending on the C library in use.
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
@@ -5206,6 +5206,24 @@ fi
 rm -f conftest*
 
 
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+  #include <stdio.h>
+  #if __BIONIC__
+    _using_bionic
+  #endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "_using_bionic" >/dev/null 2>&1; then :
+  bionic=yes
+else
+  bionic=no
+fi
+rm -f conftest*
+
+
   # Find platform-specific directories containing configuration info.
   # Also possibly modify flags used elsewhere, as needed by the platform.
 
@@ -11442,7 +11460,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11445 "configure"
+#line 11463 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11548,7 +11566,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11551 "configure"
+#line 11569 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -14888,7 +14906,7 @@ fi
     #
     # Fake what AC_TRY_COMPILE does.  XXX Look at redoing this new-style.
     cat > conftest.$ac_ext << EOF
-#line 14891 "configure"
+#line 14909 "configure"
 struct S { ~S(); };
 void bar();
 void foo()
@@ -15256,7 +15274,7 @@ $as_echo "$glibcxx_cv_atomic_long_long" >&6; }
   # Fake what AC_TRY_COMPILE does.
 
     cat > conftest.$ac_ext << EOF
-#line 15259 "configure"
+#line 15277 "configure"
 int main()
 {
   typedef bool atomic_type;
@@ -15293,7 +15311,7 @@ $as_echo "$glibcxx_cv_atomic_bool" >&6; }
     rm -f conftest*
 
     cat > conftest.$ac_ext << EOF
-#line 15296 "configure"
+#line 15314 "configure"
 int main()
 {
   typedef short atomic_type;
@@ -15330,7 +15348,7 @@ $as_echo "$glibcxx_cv_atomic_short" >&6; }
     rm -f conftest*
 
     cat > conftest.$ac_ext << EOF
-#line 15333 "configure"
+#line 15351 "configure"
 int main()
 {
   // NB: _Atomic_word not necessarily int.
@@ -15368,7 +15386,7 @@ $as_echo "$glibcxx_cv_atomic_int" >&6; }
     rm -f conftest*
 
     cat > conftest.$ac_ext << EOF
-#line 15371 "configure"
+#line 15389 "configure"
 int main()
 {
   typedef long long atomic_type;
@@ -15444,7 +15462,7 @@ $as_echo "$as_me: WARNING: Performance of certain classes will degrade as a resu
   # unnecessary for this test.
 
     cat > conftest.$ac_ext << EOF
-#line 15447 "configure"
+#line 15465 "configure"
 int main()
 {
   _Decimal32 d1;
diff --git a/libstdc++-v3/configure.host b/libstdc++-v3/configure.host
index c1f2736..5cd2a21 100644
--- a/libstdc++-v3/configure.host
+++ b/libstdc++-v3/configure.host
@@ -238,6 +238,8 @@ case "${host_os}" in
   gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu)
     if [ "$uclibc" = "yes" ]; then
       os_include_dir="os/uclibc"
+    elif [ "$bionic" = "yes" ]; then
+      os_include_dir="os/bionic"
     else
       os_include_dir="os/gnu-linux"
     fi
-- 
1.6.2.4


^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 6/6] Add support for Bionic to libstdc++
  2010-06-01  9:36   ` [PATCH 6/6] Add " Maxim Kuvyrkov
@ 2010-06-01  9:45     ` Paolo Carlini
  2010-06-07 16:22       ` NightStrike
  0 siblings, 1 reply; 30+ messages in thread
From: Paolo Carlini @ 2010-06-01  9:45 UTC (permalink / raw)
  To: Maxim Kuvyrkov; +Cc: gcc-patches, Jing Yu, libstdc++

On 06/01/2010 11:36 AM, Maxim Kuvyrkov wrote:
> OK to check in?
OK, thanks!

Paolo.

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 6/6] Add support for Bionic to libstdc++
  2010-06-01  9:45     ` Paolo Carlini
@ 2010-06-07 16:22       ` NightStrike
  2010-06-07 16:30         ` Jonathan Wakely
  2010-06-07 16:33         ` Maxim Kuvyrkov
  0 siblings, 2 replies; 30+ messages in thread
From: NightStrike @ 2010-06-07 16:22 UTC (permalink / raw)
  To: Paolo Carlini; +Cc: Maxim Kuvyrkov, gcc-patches, Jing Yu, libstdc++

On Tue, Jun 1, 2010 at 5:44 AM, Paolo Carlini <paolo.carlini@oracle.com> wrote:
> On 06/01/2010 11:36 AM, Maxim Kuvyrkov wrote:
>> OK to check in?
> OK, thanks!
>
> Paolo.
>
>

Was this checked in?

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 6/6] Add support for Bionic to libstdc++
  2010-06-07 16:22       ` NightStrike
@ 2010-06-07 16:30         ` Jonathan Wakely
  2010-06-07 16:44           ` NightStrike
  2010-06-07 16:33         ` Maxim Kuvyrkov
  1 sibling, 1 reply; 30+ messages in thread
From: Jonathan Wakely @ 2010-06-07 16:30 UTC (permalink / raw)
  To: NightStrike
  Cc: Paolo Carlini, Maxim Kuvyrkov, gcc-patches, Jing Yu, libstdc++

On 7 June 2010 17:22, NightStrike wrote:
> On Tue, Jun 1, 2010 at 5:44 AM, Paolo Carlini <paolo.carlini@oracle.com> wrote:
>> On 06/01/2010 11:36 AM, Maxim Kuvyrkov wrote:
>>> OK to check in?
>> OK, thanks!
>>
>> Paolo.
>>
>>
>
> Was this checked in?

Yes: http://gcc.gnu.org/viewcvs?view=revision&revision=160096

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 6/6] Add support for Bionic to libstdc++
  2010-06-07 16:22       ` NightStrike
  2010-06-07 16:30         ` Jonathan Wakely
@ 2010-06-07 16:33         ` Maxim Kuvyrkov
  2010-06-07 16:44           ` NightStrike
  1 sibling, 1 reply; 30+ messages in thread
From: Maxim Kuvyrkov @ 2010-06-07 16:33 UTC (permalink / raw)
  To: NightStrike; +Cc: Paolo Carlini, gcc-patches, Jing Yu, libstdc++

On 6/7/10 8:22 PM, NightStrike wrote:
> On Tue, Jun 1, 2010 at 5:44 AM, Paolo Carlini<paolo.carlini@oracle.com>  wrote:
>> On 06/01/2010 11:36 AM, Maxim Kuvyrkov wrote:
>>> OK to check in?
>> OK, thanks!
>>
>> Paolo.
>>
>>
>
> Was this checked in?

Yes.  Revisions 160096 and 160097.

-- 
Maxim Kuvyrkov
CodeSourcery
maxim@codesourcery.com
(650) 331-3385 x724

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 6/6] Add support for Bionic to libstdc++
  2010-06-07 16:30         ` Jonathan Wakely
@ 2010-06-07 16:44           ` NightStrike
  0 siblings, 0 replies; 30+ messages in thread
From: NightStrike @ 2010-06-07 16:44 UTC (permalink / raw)
  To: Jonathan Wakely
  Cc: Paolo Carlini, Maxim Kuvyrkov, gcc-patches, Jing Yu, libstdc++

On Mon, Jun 7, 2010 at 12:30 PM, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
> On 7 June 2010 17:22, NightStrike wrote:
>> On Tue, Jun 1, 2010 at 5:44 AM, Paolo Carlini <paolo.carlini@oracle.com> wrote:
>>> On 06/01/2010 11:36 AM, Maxim Kuvyrkov wrote:
>>>> OK to check in?
>>> OK, thanks!
>>>
>>> Paolo.
>>>
>>>
>>
>> Was this checked in?
>
> Yes: http://gcc.gnu.org/viewcvs?view=revision&revision=160096
>

Thanks!

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: [PATCH 6/6] Add support for Bionic to libstdc++
  2010-06-07 16:33         ` Maxim Kuvyrkov
@ 2010-06-07 16:44           ` NightStrike
  0 siblings, 0 replies; 30+ messages in thread
From: NightStrike @ 2010-06-07 16:44 UTC (permalink / raw)
  To: Maxim Kuvyrkov; +Cc: Paolo Carlini, gcc-patches, Jing Yu, libstdc++

On Mon, Jun 7, 2010 at 12:33 PM, Maxim Kuvyrkov <maxim@codesourcery.com> wrote:
> On 6/7/10 8:22 PM, NightStrike wrote:
>>
>> On Tue, Jun 1, 2010 at 5:44 AM, Paolo Carlini<paolo.carlini@oracle.com>
>>  wrote:
>>>
>>> On 06/01/2010 11:36 AM, Maxim Kuvyrkov wrote:
>>>>
>>>> OK to check in?
>>>
>>> OK, thanks!
>>>
>>> Paolo.
>>>
>>>
>>
>> Was this checked in?
>
> Yes.  Revisions 160096 and 160097.
>
> --
> Maxim Kuvyrkov
> CodeSourcery
> maxim@codesourcery.com
> (650) 331-3385 x724
>

Thanks!

^ permalink raw reply	[flat|nested] 30+ messages in thread

* mips-linux bootstrap broken was: [PATCH 2/6] Add support for Bionic C library
  2010-05-20 16:06   ` Maxim Kuvyrkov
  2010-05-25 15:00     ` Mark Mitchell
@ 2010-06-13 18:58     ` Laurent GUERBY
  2010-06-14  9:22       ` Maxim Kuvyrkov
  1 sibling, 1 reply; 30+ messages in thread
From: Laurent GUERBY @ 2010-06-13 18:58 UTC (permalink / raw)
  To: Maxim Kuvyrkov; +Cc: gcc-patches, Jing Yu, Mark Mitchell

On Thu, 2010-05-20 at 20:06 +0400, Maxim Kuvyrkov wrote:
> On 5/20/10 8:03 PM, Maxim Kuvyrkov wrote:
> > This patch adds new -mbionic option to select Bionic C library.  The
> > option is made similar to -mglibc and -muclibc.
> >
> > OK to check in?
> >
> > Thank you,
> 
> And here is the patch.

Hi Maxim,

I think your patch broke bootstrap on mips64el-linux platforms:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44456

<<
gcc -mabi=n32   -g -fkeep-inline-functions -DIN_GCC   -W -Wall
-Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes
-Wmissing-format-attribute -pedantic -Wno-long-long -Wno-variadic-macros
-Wno-overlength-strings\
 -Wold-style-definition -Wc++-compat -fno-common  -DHAVE_CONFIG_H -I. -I.
-I../../trunk/gcc -I../../trunk/gcc/. -I../../trunk/gcc/../include
-I../../trunk/gcc/../libcpp/include -I/opt/cfarm/gmp-4.2.4-n32/include
-I/opt/cfarm/mpfr-2.4.1-\
n32/include -I/opt/cfarm/mpc-0.8-n32/include  -I../../trunk/gcc/../libdecnumber
-I../../trunk/gcc/../libdecnumber/dpd -I../libdecnumber     \
  -DSTANDARD_STARTFILE_PREFIX=\"../../../\"
-DSTANDARD_EXEC_PREFIX=\"/n/42/guerby/install-trunk-159959/lib/gcc/\"
-DSTANDARD_LIBEXEC_PREFIX=\"/n/42/guerby/install-trunk-159959/libexec/gcc/\"
-DDEFAULT_TARGET_VERSION=\"4.6.0\" -DDEFAULT_\
TARGET_MACHINE=\"mips64el-unknown-linux-gnu\"
-DSTANDARD_BINDIR_PREFIX=\"/n/42/guerby/install-trunk-159959/bin/\"
-DTOOLDIR_BASE_PREFIX=\"../../../../\"  `test "X${SHLIB_LINK}" = "X" || test
"yes" != "yes" || echo "-DENABLE_SHARED_LIBGC\
C"` -DCONFIGURE_SPECS="\"\"" \
  -c ../../trunk/gcc/gcc.c -o gcc.o)
../../trunk/gcc/gcc.c:827:32: error: macro "CHOOSE_DYNAMIC_LINKER" requires 3
arguments, but only 2 given
../../trunk/gcc/gcc.c:827: error: expected ',' or ';' before ')' token
make[3]: *** [gcc.o] Error 1
make[3]: Leaving directory `/home/guerby/build/gcc'
make[2]: *** [all-stage1-gcc] Error 2
make[2]: Leaving directory `/home/guerby/build'
make[1]: *** [stage1-bubble] Error 2
make[1]: Leaving directory `/home/guerby/build'
make: *** [bootstrap] Error 2
>>

Do you know how to fix this?

Thanks in advance,

Laurent



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: mips-linux bootstrap broken was: [PATCH 2/6] Add support for Bionic C library
  2010-06-13 18:58     ` mips-linux bootstrap broken was: " Laurent GUERBY
@ 2010-06-14  9:22       ` Maxim Kuvyrkov
  2010-06-15 21:17         ` Richard Sandiford
  0 siblings, 1 reply; 30+ messages in thread
From: Maxim Kuvyrkov @ 2010-06-14  9:22 UTC (permalink / raw)
  To: Laurent GUERBY; +Cc: gcc-patches, Jing Yu, Mark Mitchell, Richard Sandiford

[-- Attachment #1: Type: text/plain, Size: 973 bytes --]

On 6/13/10 10:16 PM, Laurent GUERBY wrote:
> On Thu, 2010-05-20 at 20:06 +0400, Maxim Kuvyrkov wrote:
>> On 5/20/10 8:03 PM, Maxim Kuvyrkov wrote:
>>> This patch adds new -mbionic option to select Bionic C library.  The
>>> option is made similar to -mglibc and -muclibc.
>>>
>>> OK to check in?
>>>
>>> Thank you,
>>
>> And here is the patch.
>
> Hi Maxim,
>
> I think your patch broke bootstrap on mips64el-linux platforms:
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44456
...
 > ../../trunk/gcc/gcc.c:827:32: error: macro "CHOOSE_DYNAMIC_LINKER" 
requires 3
 > arguments, but only 2 given
 > ../../trunk/gcc/gcc.c:827: error: expected ',' or ';' before ')' token
 > make[3]: *** [gcc.o] Error 1
 > make[3]: Leaving directory `/home/guerby/build/gcc'

Laurent,

Does the attached patch fix the bootstrap for you?


Richard,

OK to check in the patch if Laurent reports success?

Thank you,

-- 
Maxim Kuvyrkov
CodeSourcery
maxim@codesourcery.com
(650) 331-3385 x724

[-- Attachment #2: fsf-gcc-bionic-mips64.ChangeLog --]
[-- Type: text/plain, Size: 149 bytes --]

2010-06-14  Maxim Kuvyrkov  <maxim@codesourcery.com>

	* config/mips/linux64.h (BIONIC_DYNAMIC_LINKERN32): Define.
	(CHOOSE_DYNAMIC_LINKER): Update.

[-- Attachment #3: fsf-gcc-bionic-mips64.patch --]
[-- Type: text/plain, Size: 720 bytes --]

Index: config/mips/linux64.h
===================================================================
--- config/mips/linux64.h	(revision 160712)
+++ config/mips/linux64.h	(working copy)
@@ -39,8 +39,10 @@ along with GCC; see the file COPYING3.  
 #define GLIBC_DYNAMIC_LINKER64 "/lib64/ld.so.1"
 #define GLIBC_DYNAMIC_LINKERN32 "/lib32/ld.so.1"
 #define UCLIBC_DYNAMIC_LINKERN32 "/lib32/ld-uClibc.so.0"
+#define BIONIC_DYNAMIC_LINKERN32 "/system/bin/linker32"
 #define LINUX_DYNAMIC_LINKERN32 \
-  CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERN32, UCLIBC_DYNAMIC_LINKERN32)
+  CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERN32, UCLIBC_DYNAMIC_LINKERN32, \
+			 BIONIC_DYNAMIC_LINKERN32)
 
 #undef LINK_SPEC
 #define LINK_SPEC "\

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: mips-linux bootstrap broken was: [PATCH 2/6] Add support for Bionic C library
  2010-06-14  9:22       ` Maxim Kuvyrkov
@ 2010-06-15 21:17         ` Richard Sandiford
  2010-06-16  3:46           ` Laurent GUERBY
  2010-06-16  8:08           ` Maxim Kuvyrkov
  0 siblings, 2 replies; 30+ messages in thread
From: Richard Sandiford @ 2010-06-15 21:17 UTC (permalink / raw)
  To: Maxim Kuvyrkov; +Cc: Laurent GUERBY, gcc-patches, Jing Yu, Mark Mitchell

Maxim Kuvyrkov <maxim@codesourcery.com> writes:
> OK to check in the patch if Laurent reports success?

Yeah, it's OK, thanks.

I'm curious though.  Is this choice of path speculative at the moment,
or is there already a bi-arch 64-bit system?  If it's speculative,
how confident are you that that path would be used?  Is linker32
the standard name for all multiarch targets?

Richard

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: mips-linux bootstrap broken was: [PATCH 2/6] Add support for Bionic C library
  2010-06-15 21:17         ` Richard Sandiford
@ 2010-06-16  3:46           ` Laurent GUERBY
  2010-06-16  8:08           ` Maxim Kuvyrkov
  1 sibling, 0 replies; 30+ messages in thread
From: Laurent GUERBY @ 2010-06-16  3:46 UTC (permalink / raw)
  To: Richard Sandiford; +Cc: Maxim Kuvyrkov, gcc-patches, Jing Yu, Mark Mitchell

On Tue, 2010-06-15 at 21:34 +0100, Richard Sandiford wrote:
> Maxim Kuvyrkov <maxim@codesourcery.com> writes:
> > OK to check in the patch if Laurent reports success?
> 
> Yeah, it's OK, thanks.
> 
> I'm curious though.  Is this choice of path speculative at the moment,
> or is there already a bi-arch 64-bit system?  If it's speculative,
> how confident are you that that path would be used?  Is linker32
> the standard name for all multiarch targets?

Maxim patch restores bootstrap and check looks good:

http://gcc.gnu.org/ml/gcc-testresults/2010-06/msg01585.html

Laurent



^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: mips-linux bootstrap broken was: [PATCH 2/6] Add support for Bionic C library
  2010-06-15 21:17         ` Richard Sandiford
  2010-06-16  3:46           ` Laurent GUERBY
@ 2010-06-16  8:08           ` Maxim Kuvyrkov
  1 sibling, 0 replies; 30+ messages in thread
From: Maxim Kuvyrkov @ 2010-06-16  8:08 UTC (permalink / raw)
  To: Laurent GUERBY, gcc-patches, Jing Yu, Mark Mitchell, rdsandiford

On 6/16/10 12:34 AM, Richard Sandiford wrote:
> Maxim Kuvyrkov<maxim@codesourcery.com>  writes:
>> OK to check in the patch if Laurent reports success?
>
> Yeah, it's OK, thanks.
>
> I'm curious though.  Is this choice of path speculative at the moment,
> or is there already a bi-arch 64-bit system?   If it's speculative,
> how confident are you that that path would be used?  Is linker32
> the standard name for all multiarch targets?

It is speculative.  There is no 64-bit Android port to my knowledge, 
much less a bi-arch port, so there's no standard naming scheme.  I'm not 
terribly concerned about the naming as we can amend the linker name when 
64-bit and biarch ports come out.

Thank you,

-- 
Maxim Kuvyrkov
CodeSourcery
maxim@codesourcery.com
(650) 331-3385 x724

^ permalink raw reply	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2010-06-16  5:59 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-20 15:59 [PATCH 0/6] Add support for Android Maxim Kuvyrkov
2010-05-20 16:03 ` [PATCH 1/6] Add *-linux-android* target Maxim Kuvyrkov
2010-05-20 17:29   ` Joseph S. Myers
2010-05-25 14:11     ` Maxim Kuvyrkov
2010-05-20 16:05 ` [PATCH 2/6] Add support for Bionic C library Maxim Kuvyrkov
2010-05-20 16:06   ` Maxim Kuvyrkov
2010-05-25 15:00     ` Mark Mitchell
2010-06-13 18:58     ` mips-linux bootstrap broken was: " Laurent GUERBY
2010-06-14  9:22       ` Maxim Kuvyrkov
2010-06-15 21:17         ` Richard Sandiford
2010-06-16  3:46           ` Laurent GUERBY
2010-06-16  8:08           ` Maxim Kuvyrkov
2010-05-20 16:06 ` [PATCH 3/6] Support compilation for Android platform Maxim Kuvyrkov
2010-05-25 15:06   ` Mark Mitchell
2010-05-20 16:07 ` [PATCH 4/6] Add multilib configuration for arm-linux-androideabi Maxim Kuvyrkov
2010-05-28 15:24   ` Mark Mitchell
2010-05-20 16:08 ` [PATCH 5/6] Fix gthr-posix.h to support Bionic Maxim Kuvyrkov
2010-05-25 15:06   ` Mark Mitchell
2010-05-25 15:23     ` Jakub Jelinek
2010-05-25 20:44       ` Mark Mitchell
2010-05-20 16:10 ` [PATCH 6/6] Add [untested] support for Bionic to libstdc++ Maxim Kuvyrkov
2010-06-01  9:36   ` [PATCH 6/6] Add " Maxim Kuvyrkov
2010-06-01  9:45     ` Paolo Carlini
2010-06-07 16:22       ` NightStrike
2010-06-07 16:30         ` Jonathan Wakely
2010-06-07 16:44           ` NightStrike
2010-06-07 16:33         ` Maxim Kuvyrkov
2010-06-07 16:44           ` NightStrike
2010-05-29 17:33 ` [PATCH 0/6] Add support for Android Gerald Pfeifer
2010-05-30 15:23   ` Maxim Kuvyrkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).