From patchwork Wed Aug 24 18:04:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Packard X-Patchwork-Id: 742 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:ecc5:0:0:0:0:0 with SMTP id s5csp1542811wro; Wed, 24 Aug 2022 11:08:03 -0700 (PDT) X-Google-Smtp-Source: AA6agR6kI5bdhD+NgFHznOGLWLf8/rOwlSU1Y25a96ENd9+pXTq+TPe8bwGFmwUQFUFPAZHDLQyX X-Received: by 2002:a17:907:7604:b0:73d:5de2:476c with SMTP id jx4-20020a170907760400b0073d5de2476cmr80785ejc.673.1661364483370; Wed, 24 Aug 2022 11:08:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661364483; cv=none; d=google.com; s=arc-20160816; b=jmxw7b4UMjKqWCBTtzBYTtk/xzvFsCjJnEBaMNDtQtqCgfU1SFOrNnvBsMFOg+tZpx 9Qsx6wYpxuf8RauIbPc5bYH3xKz+qrob0gdIuRO+wZwIuqDqOqBEOFG3641sMts5gw7K Jgot0Y/afbMo55VQTafq2xcnPhAH5OKCyXCsKd0lVMYNkIppGE3jQ8UA2EXY9uwe0529 32Q7ZhOe7OCisKTwE0gme5rSSJGaCB5slFmvJcoNZ6PrT7UTkjd3z+r3InGG5o2vE1mb hvjH9K8BRy7hXesuRYV1Kcyv3JAS4WbmrxnJGzxpBKZ6F03BLCRmzu2m22rS0PDiDCaz 3oSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=uLn1Rz3mf4A2S0rQapPqitT42XzLBfYd7iRMFb8hIpA=; b=xf5RolD5PYaQ3nRRIq5N/5FsCfEwngaToXL9bEyfZ51axgzLy6hgfAGdlGQT+LJK4E z9d4eVr3Uh0RmuO7RbScGi8W83LhWcOJrnlS7+7PTpWiMu9PiAH4tVpgpYQOcEBsV317 UnXHAngkzeF1H3iEytHVjyJLiMEuTArx1+r6JywELbWYWYqWjQX0X1ttnZgU5GWeXzUR nCBifRcmjM2RkgWMYru/b9w7AJWu32rFreYUdpQyCbZPxhe+Bl9vtTZ4t9QVFLMfJfrF hSDnBy7wxRa3Ef3VDNhbFfK8k5N6mnJq628jcXuYmK0frbfxZwNMeA19e29XP8boLyMI 7Xww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=UZwH7oNF; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id gs44-20020a1709072d2c00b0072b13aacd47si2691147ejc.194.2022.08.24.11.08.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Aug 2022 11:08:03 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=UZwH7oNF; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3692C38286E4 for ; Wed, 24 Aug 2022 18:06:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3692C38286E4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1661364383; bh=uLn1Rz3mf4A2S0rQapPqitT42XzLBfYd7iRMFb8hIpA=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=UZwH7oNFl/SM/NNrOsSRh2Y4kA2xhAV7EBtdQmZH3a+HZztN9+Vhvoe+TpyNGMiW8 D5f2evb0jOaM4r9aff5+T5bA43PWuBC38etUkwPtcxG+EZBZoAQK2Rqq6c+HVLBs80 6hPIcmMFJHaA5ob9dsmTMxpd1vLCtBuyeqQagIi8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 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) 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) Received: by keithp.com (Postfix, from userid 1000) id 0E1EF1E601CD; Wed, 24 Aug 2022 11:05:26 -0700 (PDT) To: gcc@gcc.gnu.org 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 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Keith Packard via Gcc-patches From: Keith Packard Reply-To: Keith Packard Cc: gcc-patches@gcc.gnu.org Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1742066924674341457?= X-GMAIL-MSGID: =?utf-8?q?1742066924674341457?= 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. From patchwork Wed Aug 24 18:04:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Packard X-Patchwork-Id: 741 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:ecc5:0:0:0:0:0 with SMTP id s5csp1542701wro; Wed, 24 Aug 2022 11:07:44 -0700 (PDT) X-Google-Smtp-Source: AA6agR6eqKFHZVy8OulnWA+NGW6FtcPOpLajMbuwdjKn9fBgjnLpjDdIv6DSWUbcDqfJjyCLU7V/ X-Received: by 2002:a05:6402:50ce:b0:447:d71:8405 with SMTP id h14-20020a05640250ce00b004470d718405mr191332edb.31.1661364464386; Wed, 24 Aug 2022 11:07:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661364464; cv=none; d=google.com; s=arc-20160816; b=FTA6M6SDecT8Lgdkuy/F2tEQzwIFNVDjdtVsqopF3/l1lVqFBkCEq1d15byV4kUGqC dKY4uf8Mk6yg4Vy4tDyp7XFVV3a/1QnCx+d785ZL9ZAvL0vinC8jSiPSOWawEMJ5OOUF okXNUjXHAEFPuu3gO2Er9WILgGc3/A0Eo8u519jzQ87AlEax/jPwDyt+cLa7I5a5KOR0 zIKpBXhOpBTr5zhu2zIJ9Eflbz9ELsmJrAy7l1buCPpA6fTpnNwf0DDACnSsgyaunjAk j+UYMsnsEsT2MfRGRbgiYxeiw84Ic83F8Ua8+z+Qy37qFHmJHB8zEHW4ssQT+MQVDMco 7uog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=dPMNq2qgRZH/uZRx3MHP9B7fh6QFs1jKjSG02kjQdp0=; b=Z8FbioISz8LkpIh+y3nT6iLMiln9qelUKGTrymJv0TtmTYU5bLYJXXjAOQMubkigEP 279ITny2XLyMu9Mrq7J3GYBcLktnwVtp2DbfUXZo89r9uhRCe4GAjlu8boej/bDZtBap LiAsVE+JZzfjPYXxmy1Och9a+oKcku8u0LLOMYHKNYIUd4yQepJ+NICG62LU0u/Ursfq arJ+zAO683IVt7l0w39zRD7ehnFV03f69/ylnJXLRKnxtKZ45XfSd6cTze8H3nHnuUQs JO9VaIV93GfdhsTmknq8mWaXR7X/RARDfSmsW22gS1bkz52JwpBI1bpsSA1gND3osYM+ Tbcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=QTyAz3Dp; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id s2-20020a17090699c200b00726b4f91300si2491770ejn.269.2022.08.24.11.07.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Aug 2022 11:07:44 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=QTyAz3Dp; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 09E183887B40 for ; Wed, 24 Aug 2022 18:06:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 09E183887B40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1661364374; bh=dPMNq2qgRZH/uZRx3MHP9B7fh6QFs1jKjSG02kjQdp0=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=QTyAz3Dp2s71vqrpVjM71nt9bIkCuwnr2nAi5mRfB+bm2uUIty3EYTgK5Yx4hFg2R nhT8BrJ5PVMgPoczBkng4Bc6/Id4d+rCNjMpp4yYxFrZhgyzHodLd1vkhLgsk5chIe EUo0e4NcMDOHCwZsDp2uZc9m/b38eBfHc+bCem2M= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from elaine.keithp.com (home.keithp.com [63.227.221.253]) by sourceware.org (Postfix) with ESMTPS id 17D27384BC20; Wed, 24 Aug 2022 18:05:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 17D27384BC20 Received: from localhost (localhost [127.0.0.1]) by elaine.keithp.com (Postfix) with ESMTP id 8D27C3F2FE8C; Wed, 24 Aug 2022 11:05:26 -0700 (PDT) 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 Ny2s6hf7e8xr; 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 5D8633F2FE55; Wed, 24 Aug 2022 11:05:26 -0700 (PDT) Received: by keithp.com (Postfix, from userid 1000) id 10C011E601CE; Wed, 24 Aug 2022 11:05:26 -0700 (PDT) To: gcc@gcc.gnu.org Subject: [PATCH 2/3] picolibc: Add newlib and picolibc as default C library choices Date: Wed, 24 Aug 2022 11:04:25 -0700 Message-Id: <20220824180426.820576-3-keithp@keithp.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220824180426.820576-2-keithp@keithp.com> References: <20220824180426.820576-1-keithp@keithp.com> <20220824180426.820576-2-keithp@keithp.com> MIME-Version: 1.0 X-Spam-Status: No, score=-10.6 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Keith Packard via Gcc-patches From: Keith Packard Reply-To: Keith Packard Cc: gcc-patches@gcc.gnu.org Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1742066904598403192?= X-GMAIL-MSGID: =?utf-8?q?1742066904598403192?= Signed-off-by: Keith Packard --- gcc/config.gcc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gcc/config.gcc b/gcc/config.gcc index f8b6da4f4e7..0aa4bd6c3dd 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -639,7 +639,7 @@ case ${target} in esac # Common C libraries. -tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3 LIBC_MUSL=4" +tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3 LIBC_MUSL=4 LIBC_NEWLIB=5 LIBC_PICOLIBC=6" default_libc="" @@ -5878,6 +5878,12 @@ bionic) musl) default_libc=LIBC_MUSL ;; +newlib) + default_libc=LIBC_NEWLIB + ;; +picolibc) + default_libc=LIBC_PICOLIBC + ;; esac case "$default_libc" in