Add support for Bionic C library

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
This commit is contained in:
Maxim Kuvyrkov 2010-05-27 11:54:48 +00:00 committed by Maxim Kuvyrkov
parent 3ef0694cb1
commit 74c7025321
11 changed files with 123 additions and 53 deletions

View 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.

View 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"
;;

View 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)

View 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

View 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.
@ -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

View 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)

View 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)

View 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

View 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.

View File

@ -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 } */

View File

@ -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 } */