From patchwork Sun Feb 5 07:10:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Packard X-Patchwork-Id: 52872 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1668503wrn; Sat, 4 Feb 2023 23:12:46 -0800 (PST) X-Google-Smtp-Source: AK7set8rtnN7p2MsJuXC2rxN9NlBldwy6nyq8l9wn3sXK+cr0aTI446jmpZQAXmqDkK0puMdiXNd X-Received: by 2002:a50:ab59:0:b0:4a2:71eb:b1e4 with SMTP id t25-20020a50ab59000000b004a271ebb1e4mr16621119edc.31.1675581165921; Sat, 04 Feb 2023 23:12:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675581165; cv=none; d=google.com; s=arc-20160816; b=gejM7FhTloPdpXxD4L25TYWkLJwO2V+y9XgoLK7WSTvL4p8wBOyWrUT2/eThma9IVc A2CT2HbuVRhj2yPlBxjnP2tWM6H1+uhSazhh33mdMYsHF+mp7an4DaZ494UiNdhwn80q vHhsD18qFGuv7asqyAy1akraIBhkpC2S6SXqzHh6r5S0l9l+RSA4+mOp3WD8i/yDoJ84 PGF58VSFwNsHIpSt+DE3tJ1WeFiCgbwDuMqP8oY1dWK4PInVyfi9lcm9MKNTKsBSogqN Do4wkUi/xgk8Lg6SgNwyhjzUJVfrpQ9/zOcgRBfrQq8DJdcSREp5RUN/Kh0DkC5QlQN4 5pZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=hTPY9KfOYVoCLYO69+9xdVXKzixQ5FgCYskEjKznk5Y=; b=STzL/Gpu6sfeACOjEs/s8WmegIylDLWJS3zCg+bHI9MPPRLzUv17hg/TwIQpwOm6p4 9VPKtI9YwtbOCV0ihZFBgpO7yWkKHfYoEyqRHC4Ebjf7+Li13RlllwaWnit16DlkhxJc hNkfToL1KRIpf4D3+8MJLdDSrcBF+3XmyKY58nFK8D7bg6cjw2b4YXvxeXKJnSSb6O+v IYg4kM54q5utl8dhkQYjm91uOUrE8aoRWNXXfhrCOgWyxgjzltsPYih/yME5WEY7ckoj ltxMEP1aMZYS9NryTBYyGHLKbIkNOEtZvHbT/cx5lYP9LlY+KlwdFTIyNIAgUGweBEXF vNKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=iCG5aP4R; 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 v18-20020aa7d812000000b004aa99250f07si5160415edq.398.2023.02.04.23.12.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Feb 2023 23:12:45 -0800 (PST) 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=iCG5aP4R; 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 C6894385559A for ; Sun, 5 Feb 2023 07:12:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C6894385559A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675581148; bh=hTPY9KfOYVoCLYO69+9xdVXKzixQ5FgCYskEjKznk5Y=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=iCG5aP4RKrAnNzLE8AoWsqKHRF5juwMxRPXIZp5JaDpFUqhBcV1HHgmSfI7KTOsTw grAliGQRVLNV8Of6eTfE8sD2khtg37W9ybtA7k0xaVSKe89ZuPiqj/AOqO+S9IQw9H xDjfIa/0BDt7M7rAMFwo4XYCHypk3KqabHtr8B+8= 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 CD1143858C54 for ; Sun, 5 Feb 2023 07:10:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CD1143858C54 Received: from localhost (localhost [127.0.0.1]) by elaine.keithp.com (Postfix) with ESMTP id D57883F33F09; Sat, 4 Feb 2023 23:10:45 -0800 (PST) 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 iBBFBFeCp84i; Sat, 4 Feb 2023 23:10:43 -0800 (PST) Received: from keithp.com (koto.keithp.com [192.168.11.2]) by elaine.keithp.com (Postfix) with ESMTPSA id EE2CC3F33F08; Sat, 4 Feb 2023 23:10:42 -0800 (PST) Received: by keithp.com (Postfix, from userid 1000) id 9C2D31E600C8; Sat, 4 Feb 2023 23:10:42 -0800 (PST) To: gcc-patches@gcc.gnu.org Cc: Keith Packard , Andrew Pinski , Kito Cheng , Richard Sandiford , Sebastian Huber Subject: [PATCH 1/3] Allow default libc to be specified to configure Date: Sat, 4 Feb 2023 23:10:34 -0800 Message-Id: <0fc05b2872263eec6df97393edb4912dcf6d3cc6.1675579641.git.keithp@keithp.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: References: <20220903060707.1622470-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 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 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?1742927749288427462?= X-GMAIL-MSGID: =?utf-8?q?1756974196299671431?= 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. If an unknown --with-default-libc= value is provided, emit an error and stop. Signed-off-by: Keith Packard --- gcc/config.gcc | 48 ++++++++++++++++++++++++++++++++++++++++-------- gcc/configure.ac | 4 ++++ 2 files changed, 44 insertions(+), 8 deletions(-) diff --git a/gcc/config.gcc b/gcc/config.gcc index f0958e1c959..0679a76bebb 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -663,6 +663,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 \ @@ -869,16 +871,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 @@ -987,7 +989,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 @@ -1651,13 +1654,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 ;; *) @@ -3037,7 +3040,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*) @@ -5862,3 +5865,32 @@ 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 + ;; +"") + ;; +*) + echo "Unknown libc in --with-default-libc=$with_default_libc" 1>&2 + exit 1 + ;; +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 62bc908b991..c30e3c7ae72 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -2481,6 +2481,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 Sun Feb 5 07:10:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Packard X-Patchwork-Id: 52870 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1668246wrn; Sat, 4 Feb 2023 23:11:41 -0800 (PST) X-Google-Smtp-Source: AK7set+2QnwLovNkkb+0su24SxFou4c9bgqpO3d046lDBNmnrIf2Sw4uT+Oq3rOyvXLCFHCO4fbw X-Received: by 2002:a50:8e50:0:b0:4a2:3636:141d with SMTP id 16-20020a508e50000000b004a23636141dmr17006839edx.29.1675581101806; Sat, 04 Feb 2023 23:11:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675581101; cv=none; d=google.com; s=arc-20160816; b=EUMLarPcLaGJYQmd7RJ2dyu6UQfPR8FGkWq9KRcV5Q/+uM7qfiUovC3NK+bYpPRSxV q94raf51awMoF5l44CD5U6bxWGy9DTv0by6dbMptsBceLKPSAc7jo+OijZLb7eUJxiwB 0j5tNW9KhHKP/Qbzg822KMskllIM4/m3lCYnwIB+JZOSNLpMYZFVGg7GE2eNiN67J+Zx qhsyKxYy6qhuk8NfYQ51Wt91H0jw6dlQJXvhEfRHlWsY7szo1MYA0pwDRZLJDRt0KwK/ cbU+UsvLN1TwvmoV5obMKBFNeqGxif/5+Xm7qqpY+kKGfdwiCu0fg3dR5ctEaQNLMepg 2jVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=f/k/Ov/w8X3RoClet5DZ/WD4HZwXvfoQgXvSwlgvU9s=; b=RUlNMK6pMszoW+1T4QM8s+5a9SHNdXW/w8c1NxR2C7WqU/foNMXfNg3fKzdkm+Y76g c0+/dZ4TXZxBVO4TQMpbASO+5tjeOg8n3Z5cZ+qyoKqU7zHqOXHOsJrb0eti1tN7YahX r8u6jEjjOcjPhnP/QB82i+VNvTDHT54fALIq8tPFvUx6FA6vPoiBrnmsCOgkFwRGGy78 omP9+dTEbLTwVCtqF/acwH1T2BA09iZyqnYW3CawSHCU1EDSuxy/57LTGBEd9Xp1o3SP WgkqlAgjvUjO46lOvQ/W7ExOZZW90vVKSp3Lz/mRgT191tsv1V2sHFgrlMZUMjYNwT6l ECFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=b6YG5uMz; 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 c10-20020aa7d60a000000b004aaa8293201si1413412edr.355.2023.02.04.23.11.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Feb 2023 23:11:41 -0800 (PST) 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=b6YG5uMz; 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 2ABEE385B536 for ; Sun, 5 Feb 2023 07:11:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2ABEE385B536 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675581090; bh=f/k/Ov/w8X3RoClet5DZ/WD4HZwXvfoQgXvSwlgvU9s=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=b6YG5uMzO6hPcwR6loMF3Q/wTYZXz6wSg4sujlvAR6V4d8YtJG8P5r6OeltxRGYgU Xmbuu73PS1LwOM2dK3SrglnmnXlKz1QZxjyULPKwosx8CliwZJHIAdwfpGOtS04M/N v1KbxqFYmtj4F3jW48s6VtCb+BlmmeF0Y0BRLjdg= 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 ED8663858D28 for ; Sun, 5 Feb 2023 07:10:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org ED8663858D28 Received: from localhost (localhost [127.0.0.1]) by elaine.keithp.com (Postfix) with ESMTP id 7C2BE3F33F0C; Sat, 4 Feb 2023 23:10:43 -0800 (PST) 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 2CZbTYxftdt3; Sat, 4 Feb 2023 23:10:43 -0800 (PST) Received: from keithp.com (koto.keithp.com [192.168.11.2]) by elaine.keithp.com (Postfix) with ESMTPSA id F39B83F33F09; Sat, 4 Feb 2023 23:10:42 -0800 (PST) Received: by keithp.com (Postfix, from userid 1000) id A2A771E600C9; Sat, 4 Feb 2023 23:10:42 -0800 (PST) To: gcc-patches@gcc.gnu.org Cc: Keith Packard , Andrew Pinski , Kito Cheng , Richard Sandiford , Sebastian Huber Subject: [PATCH 2/3] Add newlib and picolibc as default C library choices Date: Sat, 4 Feb 2023 23:10:35 -0800 Message-Id: <7fa04bf66973de28961edeef470266caeaa348fc.1675579641.git.keithp@keithp.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: References: <20220903060707.1622470-1-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 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 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?1742927633521251042?= X-GMAIL-MSGID: =?utf-8?q?1756974129199302492?= Signed-off-by: Keith Packard --- gcc/config.gcc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/gcc/config.gcc b/gcc/config.gcc index 0679a76bebb..84bca8df615 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -661,7 +661,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="" @@ -5879,6 +5879,15 @@ bionic) musl) default_libc=LIBC_MUSL ;; +newlib) + # Newlib configurations don't set the DEFAULT_LIBC variable, so + # avoid changing those by allowing --with-default-libc=newlib but + # not actually setting the DEFAULT_LIBC variable. + default_libc= + ;; +picolibc) + default_libc=LIBC_PICOLIBC + ;; "") ;; *) From patchwork Sun Feb 5 07:10:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Packard X-Patchwork-Id: 52871 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1668498wrn; Sat, 4 Feb 2023 23:12:44 -0800 (PST) X-Google-Smtp-Source: AK7set9QaEV3KHmLPlYChUbE1PalaanpVIq+/NQKIZ1XHpXQeWt+NkuHIGv37EJXWF48+kVx9MfY X-Received: by 2002:a05:6402:1c95:b0:4a2:1d3e:93c7 with SMTP id cy21-20020a0564021c9500b004a21d3e93c7mr13902827edb.13.1675581164656; Sat, 04 Feb 2023 23:12:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675581164; cv=none; d=google.com; s=arc-20160816; b=KL6C4VSDmZ44T7815+B+GG5N8QZQiNviMhVcLUR0/VkUJJ4zmVhRPtV4nbM39JH4Yh lC147r4vCYOyrNNqNOIma9XcGq3i0K3huDXQzPc+BCQYY66YT5Y4NVfZygL6BwAf5eTL Hlzd67Xx54SPNiiDX9vBbyh3opZjSCdP3jR0B2QMaluMXhMJSpnyQdmI+9P2eCIjMJqK nkSdMlLtOJsTHY9BBsy4S3P/i+1x/CtMpPqTYN2rd+Ml7hErMeG2iBXj7c/N7S8w9A5F cXB90yeeEruThIFM7nKuxR1LZunn5GKa3blocJ147ImjXqwFfeDse3qQF91aDdWCor0C T3cQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=AdWveKcxbJnuJJ6rsvuTMWS+OK0yiz9hysjAACsGN58=; b=Wx3O86jhJxmkw0aHxO6fxMSJ+XFa7YFCeMlgjZ1ERbm/n6/qGbCJRl6RYSsbiDxcnF tb63SEL1nc65L3h+8uIZlfgZnWGKhJegwsmMkbjyhW6sMa1ZbNniTxJ9Y+xiM3GMtG1U bmoTD8MLAYBzEWgA9dz43cIgTszmL7VesPakF4CRz0WcnGuXO6BV8SszVNgqL2WPUcwT D5BfpxVct8FnQGe8IO/dpb8lGO6K53J44EFfAtohWumFU5gGOQSROAeFUgwgExg9rb9N j2KE99KaXb6s8Z3WazsxXenOI2cKOwi614NfMLwXm5sngCY0IOec1AUOjCc8pA38lGCE pvlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=gL9e2f2s; 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 q23-20020a056402033700b004aaa25000a1si3898515edw.46.2023.02.04.23.12.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Feb 2023 23:12:44 -0800 (PST) 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=gL9e2f2s; 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 ABFA53858C31 for ; Sun, 5 Feb 2023 07:12:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ABFA53858C31 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675581147; bh=AdWveKcxbJnuJJ6rsvuTMWS+OK0yiz9hysjAACsGN58=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=gL9e2f2so2zxKhM2vjN+t50xChIQT41T/ksF1J0/5sMxKsBER9BcZ6obokYMxX/xY cNRl/Ovc/wc9UIeQLC18nzP0FG+ayLciTGdf5rxginQGIx7eUKNx+K0Zg/K0rZW5g3 mzIOMZ9VeXlCwOudF/Mvf/umm0MwkFnNt9n/o+H8= 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 EDAB03858C50 for ; Sun, 5 Feb 2023 07:10:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EDAB03858C50 Received: from localhost (localhost [127.0.0.1]) by elaine.keithp.com (Postfix) with ESMTP id 8EEBE3F33F0D; Sat, 4 Feb 2023 23:10:43 -0800 (PST) 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 DmTgeJ40EDfF; Sat, 4 Feb 2023 23:10:43 -0800 (PST) Received: from keithp.com (koto.keithp.com [192.168.11.2]) by elaine.keithp.com (Postfix) with ESMTPSA id 08A563F33F0B; Sat, 4 Feb 2023 23:10:43 -0800 (PST) Received: by keithp.com (Postfix, from userid 1000) id A951B1E600CC; Sat, 4 Feb 2023 23:10:42 -0800 (PST) To: gcc-patches@gcc.gnu.org Cc: Keith Packard , Andrew Pinski , Kito Cheng , Richard Sandiford , Sebastian Huber Subject: [PATCH 3/3] Add '--oslib=' option when default C library is picolibc Date: Sat, 4 Feb 2023 23:10:36 -0800 Message-Id: <266bf8d1221b5472760ee51eb292ac67a94f91b2.1675579641.git.keithp@keithp.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: References: <20220903060707.1622470-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, KAM_SHORT, SPF_HELO_NONE, SPF_PASS, TXREP 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 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?1742927689991202040?= X-GMAIL-MSGID: =?utf-8?q?1756974195287404848?= This option allows targets to insert an OS library after the C library in the LIB_PATH spec file fragment. This library maps a few POSIX APIs used by picolibc to underlying system capabilities. For example, picolibc provides 'libsemihost' on various targets which maps these APIs to semihosting capabilities. This would be used with this option by specifying --oslib=semihost Signed-off-by: Keith Packard --- gcc/config.gcc | 7 +++++++ gcc/config/picolibc.h | 32 ++++++++++++++++++++++++++++++++ gcc/config/picolibc.opt | 26 ++++++++++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 gcc/config/picolibc.h create mode 100644 gcc/config/picolibc.opt diff --git a/gcc/config.gcc b/gcc/config.gcc index 84bca8df615..e2863efd680 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -5903,3 +5903,10 @@ case "$default_libc" in tm_defines="$tm_defines DEFAULT_LIBC=$default_libc" ;; esac + +case "$default_libc" in + LIBC_PICOLIBC) + extra_options="${extra_options} picolibc.opt" + tm_file="${tm_file} picolibc.h" + ;; +esac diff --git a/gcc/config/picolibc.h b/gcc/config/picolibc.h new file mode 100644 index 00000000000..144f11ebcf2 --- /dev/null +++ b/gcc/config/picolibc.h @@ -0,0 +1,32 @@ +/* Configuration common to all targets running Picolibc. + Copyright (C) 2023 Free Software Foundation, Inc. + + This file is part of GCC. + + GCC is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 3, or (at your + option) any later version. + + GCC is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. + + Under Section 7 of GPL version 3, you are granted additional + permissions described in the GCC Runtime Library Exception, version + 3.1, as published by the Free Software Foundation. + + You should have received a copy of the GNU General Public License and + a copy of the GCC Runtime Library Exception along with this program; + see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + . */ + +#undef LIB_SPEC +#define LIB_SPEC "--start-group -lc %{-oslib=*:-l%*} %(libgcc) --end-group" + +#undef STARTFILE_SPEC +#define STARTFILE_SPEC "crt0%O%s" + +#undef ENDFILE_SPEC +#define ENDFILE_SPEC "" diff --git a/gcc/config/picolibc.opt b/gcc/config/picolibc.opt new file mode 100644 index 00000000000..194b3362b03 --- /dev/null +++ b/gcc/config/picolibc.opt @@ -0,0 +1,26 @@ +; Processor-independent options for picolibc. +; +; Copyright (C) 2022 Free Software Foundation, Inc. +; +; This file is part of GCC. +; +; GCC is free software; you can redistribute it and/or modify it under +; the terms of the GNU General Public License as published by the Free +; Software Foundation; either version 3, or (at your option) any later +; version. +; +; GCC is distributed in the hope that it will be useful, but WITHOUT ANY +; WARRANTY; without even the implied warranty of MERCHANTABILITY or +; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +; for more details. +; +; You should have received a copy of the GNU General Public License +; along with GCC; see the file COPYING3. If not see +; . + +-oslib +Driver Separate Alias(-oslib=) + +-oslib= +Driver Joined +Specify an OS support library to load after libc.