From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from elaine.keithp.com (home.keithp.com [63.227.221.253]) by sourceware.org (Postfix) with ESMTPS id 9ADA53839809; Wed, 24 Aug 2022 18:05:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9ADA53839809 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=keithp.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=keithp.com Received: from localhost (localhost [127.0.0.1]) by elaine.keithp.com (Postfix) with ESMTP id 999DE3F2FE8C; Wed, 24 Aug 2022 11:05:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=keithp.com; s=mail; t=1661364331; bh=zOq33TltWBt1OmAYxhl3hNiwjuYVZQmb7oQyGYwOAaY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e7NH6Qgh4XSgaXkg4A+x+qg8yDkGnuE0TprCfIcvMPzqui02qGvL+EdcyBH9ULMyv 97RXr1/gjNrUPYs0o3i5P4WAO7kLSRJt/kccWe2CZBywL/jr7VfuE86CP4DsrPKQu9 exEZafvfZ2yYUuZMrhsRylNSdoC+AguhL3wYMhGlqIM3k0Rq7rnUZBJiR9JU6U1RIf zn++ehrQMB5YWLm7PlwhSSyd8ppZtwDVxlKqEQHAR/GuNI3BO1xSIaFC/iXPl4vb8o puhjAymrASaXSix1qDQENfiDktmpP+gnF6crKxwRjBqP34frKlOoLk4FHvN9lAi6FH 8to6nbo/79H1g== X-Virus-Scanned: Debian amavisd-new at keithp.com Received: from elaine.keithp.com ([127.0.0.1]) by localhost (elaine.keithp.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id qfVaHE24WsGV; Wed, 24 Aug 2022 11:05:26 -0700 (PDT) Received: from keithp.com (koto.keithp.com [192.168.11.2]) by elaine.keithp.com (Postfix) with ESMTPSA id 4D8083F2FE50; Wed, 24 Aug 2022 11:05:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=keithp.com; s=mail; t=1661364326; bh=zOq33TltWBt1OmAYxhl3hNiwjuYVZQmb7oQyGYwOAaY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aaHI+trO+KPbUD4Hdl7r9Um3GEG0R4zTu12ke7cYNkYwSkh3q7XwEp5xzvm8rXogE +Pwj06MXrArIBuL+E3bQPzDiC6VmdJwEiXi+4SPIX+1mCVaecggp5pfDNmeijYTVTu Aw0Emo4aCAAwn/yhPzl2/9mmNGOrqc0xUUylDEDFFkdvykwS19nFZeIwXnBNnd9sIi yW0eEyCZTj82UIqKk8CkbH+hbOuAk9oNSrIBcTWlGJCauSrvZGdDHf+NNG2TDFN729 h+aT6BML8b2YQcRuHoHvrxHTG9PyZO8UtyG0zy5yHk8ZIxp5EeUL7Qa84JaA63wI5W VWyE8PePbagfA== Received: by keithp.com (Postfix, from userid 1000) id 0E1EF1E601CD; Wed, 24 Aug 2022 11:05:26 -0700 (PDT) From: Keith Packard To: gcc@gcc.gnu.org Cc: gcc-patches@gcc.gnu.org, Keith Packard Subject: [PATCH 1/3] picolibc: Allow default libc to be specified to configure Date: Wed, 24 Aug 2022 11:04:24 -0700 Message-Id: <20220824180426.820576-2-keithp@keithp.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220824180426.820576-1-keithp@keithp.com> References: <20220824180426.820576-1-keithp@keithp.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: The default C library is normally computed based on the target triplet. However, for embedded systems, it can be useful to leave the triplet alone while changing which C library is used by default. Other C libraries may still be available on the system so the compiler and can be used by specifying suitable include and library paths at build time. Signed-off-by: Keith Packard --- gcc/config.gcc | 42 ++++++++++++++++++++++++++++++++++-------- gcc/configure.ac | 4 ++++ 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/gcc/config.gcc b/gcc/config.gcc index 02f58970db0..f8b6da4f4e7 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -641,6 +641,8 @@ esac # Common C libraries. tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3 LIBC_MUSL=4" +default_libc="" + # 32-bit x86 processors supported by --with-arch=. Each processor # MUST be separated by exactly one space. x86_archs="athlon athlon-4 athlon-fx athlon-mp athlon-tbird \ @@ -847,16 +849,16 @@ case ${target} in esac case $target in *-*-*android*) - tm_defines="$tm_defines DEFAULT_LIBC=LIBC_BIONIC" + default_libc=LIBC_BIONIC ;; *-*-*uclibc* | *-*-uclinuxfdpiceabi) - tm_defines="$tm_defines DEFAULT_LIBC=LIBC_UCLIBC" + default_libc=LIBC_UCLIBC ;; *-*-*musl*) - tm_defines="$tm_defines DEFAULT_LIBC=LIBC_MUSL" + default_libc=LIBC_MUSL ;; *) - tm_defines="$tm_defines DEFAULT_LIBC=LIBC_GLIBC" + default_libc=LIBC_GLIBC ;; esac # Assume that glibc or uClibc or Bionic are being used and so __cxa_atexit @@ -949,7 +951,8 @@ case ${target} in case ${enable_threads} in "" | yes | posix) thread_file='posix' ;; esac - tm_defines="$tm_defines DEFAULT_LIBC=LIBC_UCLIBC SINGLE_LIBC" + tm_defines="$tm_defines SINGLE_LIBC" + default_libc=LIBC_UCLIBC ;; *-*-rdos*) use_gcc_stdint=wrap @@ -1606,13 +1609,13 @@ csky-*-*) case ${target} in csky-*-linux-gnu*) - tm_defines="$tm_defines DEFAULT_LIBC=LIBC_GLIBC" + default_libc=LIBC_GLIBC # Force .init_array support. The configure script cannot always # automatically detect that GAS supports it, yet we require it. gcc_cv_initfini_array=yes ;; csky-*-linux-uclibc*) - tm_defines="$tm_defines DEFAULT_LIBC=LIBC_UCLIBC" + default_libc=LIBC_UCLIBC default_use_cxa_atexit=no ;; *) @@ -3065,7 +3068,7 @@ powerpc*-wrs-vxworks7r*) tmake_file="${tmake_file} t-linux rs6000/t-linux64 rs6000/t-fprules rs6000/t-ppccomm" tmake_file="${tmake_file} rs6000/t-vxworks" - tm_defines="$tm_defines DEFAULT_LIBC=LIBC_GLIBC" + default_libc=LIBC_GLIBC extra_objs="$extra_objs linux.o rs6000-linux.o" ;; powerpc-wrs-vxworks*) @@ -5861,3 +5864,26 @@ i[34567]86-*-* | x86_64-*-*) fi ;; esac + +case "${with_default_libc}" in +glibc) + default_libc=LIBC_GLIBC + ;; +uclibc) + default_libc=LIBC_UCLIBC + ;; +bionic) + default_libc=LIBC_BIONIC + ;; +musl) + default_libc=LIBC_MUSL + ;; +esac + +case "$default_libc" in +"") + ;; +*) + tm_defines="$tm_defines DEFAULT_LIBC=$default_libc" + ;; +esac diff --git a/gcc/configure.ac b/gcc/configure.ac index 819b490d1b6..0b76613b635 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -2490,6 +2490,10 @@ if { { test x$host != x$target && test "x$with_sysroot" = x ; } || fi AC_SUBST(inhibit_libc) +AC_ARG_WITH(default-libc, + [AS_HELP_STRING([--with-default-libc], + [Use specified default C library])]) + # When building gcc with a cross-compiler, we need to adjust things so # that the generator programs are still built with the native compiler. # Also, we cannot run fixincludes. -- 2.36.1