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 31D90384B838; Wed, 24 Aug 2022 18:05:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 31D90384B838 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 2C3F23F2FE50; Wed, 24 Aug 2022 11:05:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=keithp.com; s=mail; t=1661364332; bh=B7VY7rdUkEczip1nga30LAOfwNAnB00PLANRkcyezXI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L64kXTmPR0QV1bFT6JovW1iHcuUNdd2cvc7OV0CjDv8EXYzQ/A7kRLFftqD8xsobS ufxtYDD6Kb1Cq55ozC1KynRrx1rv80kQAepiUwLDJCTGSqQ6F9g6Vum3eQn3LMN3xy tJrTU+RMSL/9MXsu8Xf+IYr03TtNeFp9DhGYIoFV0STKQegDT2Uqd40oVO/BnXNtZK 6tsH98UqX3VSNPfBUnyQBoFwIRzV4A29mDb3j06ZPtvPLFLBrmKrAN7gBjkAAkjEaA uB++9AK0XH92POlJvQfWE3XtS2F04DifWn+zGEYqY7NlKV4v8NgeTVxMKMZx+P2Jfd RCixre9Et4J2g== 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 CnVcd6vuuyjG; Wed, 24 Aug 2022 11:05:31 -0700 (PDT) Received: from keithp.com (koto.keithp.com [192.168.11.2]) by elaine.keithp.com (Postfix) with ESMTPSA id 705F13F2FE56; 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=B7VY7rdUkEczip1nga30LAOfwNAnB00PLANRkcyezXI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TVeCA1gMSCLuqKlRYCqAFa4ofNHzRC6hD8h+HlEVo6CFrGPhEgrh/Vwva8AAMnDVh IITL27C+i53Tl9qz+FqdOQuSy3nBc8ZFBM+Lv5B6y5T5FWhXSxw3T001YEZAkGx8Wr YoNJYKg1IpeV7CJXIpxrtslHPKG9KoJcH8vzOBlgCyRULxR++TTZ06W2Y/7Oke73cG BwdjYeiN/CjZq0edcXqdIyqPSWeRzPkjJAw1EjEe2ZtzFW9024kvJzBlfUXZYKBPyQ vLOo7C2XzdPg5s3awsLD8FgrQRZu/8inUWp4vEP2NQLQjnXSeB1Ma5gCmdQg/+FIl6 m6+f1hD6a2Idw== Received: by keithp.com (Postfix, from userid 1000) id 13E291E601CF; 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 3/3] picolibc: Add '--oslib=' option when default C library is picolibc Date: Wed, 24 Aug 2022 11:04:26 -0700 Message-Id: <20220824180426.820576-4-keithp@keithp.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220824180426.820576-3-keithp@keithp.com> References: <20220824180426.820576-1-keithp@keithp.com> <20220824180426.820576-2-keithp@keithp.com> <20220824180426.820576-3-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,KAM_SHORT,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: 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 This patch enables --oslib= on arm, nds32, riscv and sh. Signed-off-by: Keith Packard --- gcc/config.gcc | 6 ++++++ gcc/config/arm/elf.h | 5 +++++ gcc/config/nds32/elf.h | 4 ++++ gcc/config/picolibc.opt | 26 ++++++++++++++++++++++++++ gcc/config/riscv/elf.h | 4 ++++ gcc/config/sh/embed-elf.h | 5 +++++ 6 files changed, 50 insertions(+) create mode 100644 gcc/config/picolibc.opt diff --git a/gcc/config.gcc b/gcc/config.gcc index 0aa4bd6c3dd..80740d8f04e 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -5893,3 +5893,9 @@ 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" + ;; +esac diff --git a/gcc/config/arm/elf.h b/gcc/config/arm/elf.h index 3d111433ede..d83ee4a1a8c 100644 --- a/gcc/config/arm/elf.h +++ b/gcc/config/arm/elf.h @@ -150,3 +150,8 @@ #undef L_floatundisf #endif +#if defined(DEFAULT_LIBC) && defined(LIBC_PICOLIBC) && DEFAULT_LIBC == LIBC_PICOLIBC +#undef LIB_SPEC +#define LIB_SPEC "--start-group %(libgcc) -lc %{-oslib=*:-l%*} --end-group" +#endif + diff --git a/gcc/config/nds32/elf.h b/gcc/config/nds32/elf.h index ebdc18cee2a..a956d531ef4 100644 --- a/gcc/config/nds32/elf.h +++ b/gcc/config/nds32/elf.h @@ -34,8 +34,12 @@ " %{shared:-shared}" \ NDS32_RELAX_SPEC +#if defined(DEFAULT_LIBC) && defined(LIBC_PICOLIBC) && DEFAULT_LIBC == LIBC_PICOLIBC +#define LIB_SPEC "--start-group %(libgcc) -lc %{-oslib=*:-l%*} --end-group" +#else #define LIB_SPEC \ " -lc -lgloss" +#endif #define LIBGCC_SPEC \ " -lgcc" 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. diff --git a/gcc/config/riscv/elf.h b/gcc/config/riscv/elf.h index f0e865d6ef4..ca906afcd52 100644 --- a/gcc/config/riscv/elf.h +++ b/gcc/config/riscv/elf.h @@ -27,7 +27,11 @@ along with GCC; see the file COPYING3. If not see /* Link against Newlib libraries, because the ELF backend assumes Newlib. Handle the circular dependence between libc and libgloss. */ #undef LIB_SPEC +#if defined(DEFAULT_LIBC) && defined(LIBC_PICOLIBC) && DEFAULT_LIBC == LIBC_PICOLIBC +#define LIB_SPEC "--start-group %(libgcc) -lc %{-oslib=*:-l%*} --end-group" +#else #define LIB_SPEC "--start-group -lc %{!specs=nosys.specs:-lgloss} --end-group" +#endif #undef STARTFILE_SPEC #define STARTFILE_SPEC "crt0%O%s crtbegin%O%s" diff --git a/gcc/config/sh/embed-elf.h b/gcc/config/sh/embed-elf.h index 21e51dd0bb9..e8605849e07 100644 --- a/gcc/config/sh/embed-elf.h +++ b/gcc/config/sh/embed-elf.h @@ -34,3 +34,8 @@ along with GCC; see the file COPYING3. If not see %{Os: -lgcc-Os-4-200} \ -lgcc \ %{!Os: -lgcc-Os-4-200}" + +#if defined(DEFAULT_LIBC) && defined(LIBC_PICOLIBC) && DEFAULT_LIBC == LIBC_PICOLIBC +#undef LIB_SPEC +#define LIB_SPEC "--start-group %(libgcc) -lc %{-oslib=*:-l%*} --end-group" +#endif -- 2.36.1