Add support for Bionic C library
authorMaxim Kuvyrkov <maxim@codesourcery.com>
Thu, 27 May 2010 11:54:48 +0000 (11:54 +0000)
committerMaxim Kuvyrkov <mkuvyrkov@gcc.gnu.org>
Thu, 27 May 2010 11:54:48 +0000 (11:54 +0000)
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.

From-SVN: r159917

gcc/ChangeLog
gcc/config.gcc
gcc/config/alpha/linux-elf.h
gcc/config/linux.h
gcc/config/linux.opt
gcc/config/rs6000/linux64.h
gcc/config/rs6000/sysv4.h
gcc/doc/invoke.texi
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/glibc-uclibc-1.c [deleted file]
gcc/testsuite/gcc.dg/glibc-uclibc-2.c [deleted file]

index b752ec0de67318d1889dbab387251666fad1e1f4..4c4163e7e30e322952fec7b6f6009a5f750d78c4 100644 (file)
@@ -1,3 +1,35 @@
+2010-05-27  Maxim Kuvyrkov  <maxim@codesourcery.com>
+
+       Add support for Bionic C library
+
+       * 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.
+
 2010-05-27  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
        * c-common.h (c_register_addr_space): Add prototype.
index 56f84e18c3111a47459606f720732d92ed1846ff..d3fcaca39cace4fb308ab79bc61b096524416e5b 100644 (file)
@@ -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*)
@@ -1632,7 +1638,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"
        ;;
index c48fc93503cac58e52e977b3cfd3efe445957bdf..262404b233bd3ffb7b0591c3b060246699a64795 100644 (file)
@@ -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)
index e567e9a9178d06d7dd12ffcc1d463ce13c6c9fbd..f86cc7bbaea2cc16e8bebc5bbb1275a08ca24653 100644 (file)
@@ -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
index a9b40f0899e548c13d41725aab1db6e55ef7694d..9ace3e39b13c63a5aba034cdca69e485e86c3d8b 100644 (file)
@@ -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.
 ; 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
index da7bca3037c23fcf9fbd21c59eee5f89b12ef80d..502342c3de6e4921430e56de99b894954b433fed 100644 (file)
@@ -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)
index 8d19ad7ad63dfd3f406bac5d8a34fc83aecf90ae..2e6fbc7cbd243958f10597388742945781043edc 100644 (file)
@@ -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)
index e9b3eab1f335cbebeb99fe1919545800f63d9db2..20fa3477210f5c9e4f23fff4e77ac8c043e837ef 100644 (file)
@@ -11477,13 +11477,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
index 77efe9c0c8962e4f1b3d85c33293c78a06543e74..cdcbc2fe8a673fe1e2b193913370feb40ba062ed 100644 (file)
@@ -1,3 +1,8 @@
+2010-05-27  Maxim Kuvyrkov  <maxim@codesourcery.com>
+
+       * gcc.dg/glibc-uclibc-1.c, gcc.dg/glibc-uclibc-2.c: Remove, no longer
+       necessary.
+
 2010-05-26  Jan Hubicka  <jh@suse.cz>
 
        * gcc.dg/lto/materialize-1_0.c: New file.
diff --git a/gcc/testsuite/gcc.dg/glibc-uclibc-1.c b/gcc/testsuite/gcc.dg/glibc-uclibc-1.c
deleted file mode 100644 (file)
index a376404..0000000
+++ /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 (file)
index cb52260..0000000
+++ /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 } */