From patchwork Wed Dec 8 16:33:35 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 74744 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 0060CB70A3 for ; Thu, 9 Dec 2010 03:33:46 +1100 (EST) Received: (qmail 24200 invoked by alias); 8 Dec 2010 16:33:45 -0000 Received: (qmail 24175 invoked by uid 22791); 8 Dec 2010 16:33:43 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL, BAYES_00, TW_XG, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 08 Dec 2010 16:33:38 +0000 Received: (qmail 28303 invoked from network); 8 Dec 2010 16:33:37 -0000 Received: from unknown (HELO digraph.polyomino.org.uk) (joseph@127.0.0.2) by mail.codesourcery.com with ESMTPA; 8 Dec 2010 16:33:37 -0000 Received: from jsm28 (helo=localhost) by digraph.polyomino.org.uk with local-esmtp (Exim 4.72) (envelope-from ) id 1PQMxT-0001pb-KE; Wed, 08 Dec 2010 16:33:35 +0000 Date: Wed, 8 Dec 2010 16:33:35 +0000 (UTC) From: "Joseph S. Myers" To: Thomas Schwinge cc: gcc-patches@gcc.gnu.org, maxim@codesourcery.com, thomas@codesourcery.com Subject: Re: [PATCH] glibc / uclibc / bionic switch vs. non-Linux, GNU-based systems In-Reply-To: <1291821876-23891-1-git-send-email-thomas@schwinge.name> Message-ID: References: <1291821876-23891-1-git-send-email-thomas@schwinge.name> MIME-Version: 1.0 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org On Wed, 8 Dec 2010, Thomas Schwinge wrote: > Hallo! > > This patch makes GNU/Hurd buildable again. Previously, I had made this > Linux libc switch depend on Linux kernel only, but when Maxim added > support for bionic on 2010-05-27 in r159917, then it broke again, and I'm > now finally giving in... Let the libc options be there at run-time; we > simply won't use them. This alternative patch limits use of linux.opt to those targets for which it is relevant - that is, *-*-linux* (systems using the Linux kernel and an MMU-based ABI), as those are the systems for which alternative libcs may be available withing a single compiler configuration. This patch works by defining SINGLE_LIBC (along with DEFAULT_LIBC) for the configurations without libc switching that might however use linux.h. In addition to those configurations fixed by your patch it also avoids problems with uClinux configurations that use linux.h needing to use linux.opt and define DEFAULT_LIBC individually; thus, it fixes the problems I recently noticed building for lm32-uclinux. It does not fix the underlying problem with linux.h being used for an ill-defined set of targets and needing splitting into "Linux kernel", "MMU-based Linux kernel" and "may use glibc" (or similar) parts. Tested building cc1 and xgcc for crosses to: i686-gnu i686-kfreebsd-gnu i686-knetbsd-gnu i686-kopensolaris-gnu bfin-uclinux moxie-uclinux lm32-uclinux m68k-uclinux alpha-linux-gnu powerpc-linux-gnu powerpc64-linux-gnu. OK to commit? 2010-12-08 Joseph Myers * config/alpha/linux.h (OPTION_GLIBC): Define differently if SINGLE_LIBC. * config/linux.h (OPTION_GLIBC, OPTION_UCLIBC, OPTION_BIONIC): Define differently if SINGLE_LIBC. * config/rs6000/linux.h (OPTION_GLIBC): Define differently if SINGLE_LIBC. * config/rs6000/linux64.h (OPTION_GLIBC): Define differently if SINGLE_LIBC. * config.gcc (*-*-linux* | frv-*-*linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu | *-*-gnu* | *-*-kopensolaris*-gnu): Define DEFAULT_LIBC and SINGLE_LIBC instead of OPTION_GLIBC. (*-*-uclinux*): Define DEFAULT_LIBC and SINGLE_LIBC. (bfin*-uclinux*, moxie-*-uclinux*, m68k-*-uclinux*): Don't define DEFAULT_LIBC or use linux.opt. diff -rupN --exclude=.svn gcc-mainline-3/gcc/config/alpha/linux.h gcc-mainline/gcc/config/alpha/linux.h --- gcc-mainline-3/gcc/config/alpha/linux.h 2010-11-19 13:20:56.000000000 -0800 +++ gcc-mainline/gcc/config/alpha/linux.h 2010-12-08 07:36:21.000000000 -0800 @@ -61,7 +61,11 @@ along with GCC; see the file COPYING3. #undef WCHAR_TYPE #define WCHAR_TYPE "int" +#ifdef SINGLE_LIBC +#define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC) +#else #define OPTION_GLIBC (linux_libc == LIBC_GLIBC) +#endif /* Determine whether the entire c99 runtime is present in the runtime library. */ diff -rupN --exclude=.svn gcc-mainline-3/gcc/config/linux.h gcc-mainline/gcc/config/linux.h --- gcc-mainline-3/gcc/config/linux.h 2010-12-06 06:39:42.000000000 -0800 +++ gcc-mainline/gcc/config/linux.h 2010-12-08 07:35:55.000000000 -0800 @@ -80,9 +80,15 @@ see the files COPYING3 and COPYING.RUNTI #define LIB_SPEC LINUX_TARGET_LIB_SPEC /* C libraries supported on Linux. */ +#ifdef SINGLE_LIBC +#define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC) +#define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC) +#define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC) +#else #define OPTION_GLIBC (linux_libc == LIBC_GLIBC) #define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC) #define OPTION_BIONIC (linux_libc == LIBC_BIONIC) +#endif #define LINUX_TARGET_OS_CPP_BUILTINS() \ do { \ diff -rupN --exclude=.svn gcc-mainline-3/gcc/config/rs6000/linux.h gcc-mainline/gcc/config/rs6000/linux.h --- gcc-mainline-3/gcc/config/rs6000/linux.h 2010-12-06 06:41:23.000000000 -0800 +++ gcc-mainline/gcc/config/rs6000/linux.h 2010-12-08 07:36:41.000000000 -0800 @@ -27,7 +27,11 @@ /* We use glibc _mcount for profiling. */ #define NO_PROFILE_COUNTERS 1 +#ifdef SINGLE_LIBC +#define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC) +#else #define OPTION_GLIBC (linux_libc == LIBC_GLIBC) +#endif /* glibc has float and long double forms of math functions. */ #undef TARGET_C99_FUNCTIONS diff -rupN --exclude=.svn gcc-mainline-3/gcc/config/rs6000/linux64.h gcc-mainline/gcc/config/rs6000/linux64.h --- gcc-mainline-3/gcc/config/rs6000/linux64.h 2010-12-06 06:41:42.000000000 -0800 +++ gcc-mainline/gcc/config/rs6000/linux64.h 2010-12-08 07:36:53.000000000 -0800 @@ -308,7 +308,11 @@ extern int dot_symbols; process. */ #define OS_MISSING_POWERPC64 !TARGET_64BIT +#ifdef SINGLE_LIBC +#define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC) +#else #define OPTION_GLIBC (linux_libc == LIBC_GLIBC) +#endif /* glibc has float and long double forms of math functions. */ #undef TARGET_C99_FUNCTIONS diff -rupN --exclude=.svn gcc-mainline-3/gcc/config.gcc gcc-mainline/gcc/config.gcc --- gcc-mainline-3/gcc/config.gcc 2010-12-06 03:31:49.000000000 -0800 +++ gcc-mainline/gcc/config.gcc 2010-12-08 07:49:50.000000000 -0800 @@ -562,7 +562,7 @@ case ${target} in *linux*) extra_options="$extra_options linux.opt";; *) - tm_defines="$tm_defines OPTION_GLIBC=1";; + tm_defines="$tm_defines DEFAULT_LIBC=LIBC_GLIBC SINGLE_LIBC";; esac case $target in *-*-*android*) @@ -657,6 +657,7 @@ case ${target} in ;; *-*-uclinux*) use_gcc_stdint=wrap + tm_defines="$tm_defines DEFAULT_LIBC=LIBC_UCLIBC SINGLE_LIBC" ;; *-*-solaris2*) extra_options="${extra_options} sol2.opt" @@ -906,8 +907,6 @@ 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} DEFAULT_LIBC=LIBC_UCLIBC" - extra_options="${extra_options} linux.opt" use_collect2=no ;; bfin*-linux-uclibc*) @@ -989,8 +988,6 @@ 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} DEFAULT_LIBC=LIBC_UCLIBC" - extra_options="${extra_options} linux.opt" ;; moxie-*-rtems*) tmake_file="${tmake_file} moxie/t-moxie moxie/t-moxie-softfp soft-fp/t-softfp t-rtems" @@ -1726,8 +1723,7 @@ m68k-*-uclinux*) # Motorola m68k/ColdFi 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 DEFAULT_LIBC=LIBC_UCLIBC" - extra_options="${extra_options} linux.opt" + tm_defines="${tm_defines} MOTOROLA=1" tmake_file="m68k/t-floatlib m68k/t-uclinux m68k/t-mlibs" ;; m68k-*-linux*) # Motorola m68k's running GNU/Linux