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: 64317 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 296EC385B519 for ; Sun, 5 Feb 2023 07:12:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 296EC385B519 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675581133; 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=UJqJiwrkfC30rZCbsfjjTmAVEclVBkuEy3yW72hUiiwE5elv793GGFEp3Hm4PYGXw hAxeLOJxothGdJSgGSZjcaSkPMCJlxMPPjbiTrA98PJb6uSsiPARMZiP8GtFH+lS8Y QIeaS7iWq7KH1XY4mBPKv7C6S5shu9f/mcwnW4PE= 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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" 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.