From: mkuvyrkov Date: Thu, 27 May 2010 11:54:48 +0000 (+0000) Subject: Add support for Bionic C library X-Git-Url: http://git.sourceforge.jp/view?p=pf3gnuchains%2Fgcc-fork.git;a=commitdiff_plain;h=66fd9df95192d57d2a8720028f2b4ebd1aeff874 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159917 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b752ec0de67..4c4163e7e30 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,35 @@ +2010-05-27 Maxim Kuvyrkov + + 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 * c-common.h (c_register_addr_space): Add prototype. diff --git a/gcc/config.gcc b/gcc/config.gcc index 56f84e18c31..d3fcaca39ca 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*) @@ -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" ;; diff --git a/gcc/config/alpha/linux-elf.h b/gcc/config/alpha/linux-elf.h index c48fc93503c..262404b233b 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 e567e9a9178..f86cc7bbaea 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 a9b40f0899e..9ace3e39b13 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 ; . +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 da7bca3037c..502342c3de6 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 8d19ad7ad63..2e6fbc7cbd2 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 e9b3eab1f33..20fa3477210 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 77efe9c0c89..cdcbc2fe8a6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-05-27 Maxim Kuvyrkov + + * gcc.dg/glibc-uclibc-1.c, gcc.dg/glibc-uclibc-2.c: Remove, no longer + necessary. + 2010-05-26 Jan Hubicka * 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 index a3764046b0d..00000000000 --- 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 */ -/* { 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 cb52260730b..00000000000 --- 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 */ -/* { dg-do link { target *-*-linux* } } */ -/* { dg-options "-muclibc -mglibc" } */ - -/* { dg-message "-mglibc and -muclibc used together" "" { target *-*-* } 0 } */