public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Keith Packard <keithp@keithp.com>
To: gcc-patches@gcc.gnu.org
Cc: Keith Packard <keithp@keithp.com>,
	Andrew Pinski <pinskia@gmail.com>,
	Kito Cheng <kito.cheng@gmail.com>,
	Richard Sandiford <richard.sandiford@arm.com>,
	Sebastian Huber <sebastian.huber@embedded-brains.de>
Subject: [PATCH 3/3] Add '--oslib=' option when default C library is picolibc
Date: Sat,  4 Feb 2023 23:10:36 -0800	[thread overview]
Message-ID: <266bf8d1221b5472760ee51eb292ac67a94f91b2.1675579641.git.keithp@keithp.com> (raw)
In-Reply-To: <cover.1675579641.git.keithp@keithp.com>

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 <keithp@keithp.com>
---
 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
+   <http://www.gnu.org/licenses/>.  */
+
+#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
+; <http://www.gnu.org/licenses/>.
+
+-oslib
+Driver Separate Alias(-oslib=)
+
+-oslib=
+Driver Joined
+Specify an OS support library to load after libc.
-- 
2.39.0


      parent reply	other threads:[~2023-02-05  7:10 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-24 18:04 [PATCH 0/3] picolibc: Add picolibc linking help Keith Packard
2022-08-24 18:04 ` [PATCH 1/3] picolibc: Allow default libc to be specified to configure Keith Packard
2022-08-24 18:04   ` [PATCH 2/3] picolibc: Add newlib and picolibc as default C library choices Keith Packard
2022-08-24 18:04     ` [PATCH 3/3] picolibc: Add '--oslib=' option when default C library is picolibc Keith Packard
2022-08-24 18:24 ` [PATCH 0/3] picolibc: Add picolibc linking help Andrew Pinski
2022-08-24 19:32   ` Keith Packard
2022-08-25  7:16     ` Kito Cheng
2022-08-25 17:38       ` Keith Packard
2022-09-02 12:36 ` Richard Sandiford
2022-09-03  6:02   ` Keith Packard
2022-09-03  6:07 ` Keith Packard
2022-09-03  6:07   ` [PATCH 1/3] Allow default libc to be specified to configure Keith Packard
2022-09-03  6:07   ` [PATCH 2/3] Add newlib and picolibc as default C library choices Keith Packard
2022-09-03  6:07   ` [PATCH 3/3] Add '--oslib=' option when default C library is picolibc Keith Packard
2022-11-21  7:11     ` Sebastian Huber
2023-02-05  7:10   ` [PATCH 0/3] picolibc: Add picolibc linking help (v3) Keith Packard
2023-02-05  7:10     ` [PATCH 1/3] Allow default libc to be specified to configure Keith Packard
2023-02-05  7:10     ` [PATCH 2/3] Add newlib and picolibc as default C library choices Keith Packard
2023-02-05  7:10     ` Keith Packard [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=266bf8d1221b5472760ee51eb292ac67a94f91b2.1675579641.git.keithp@keithp.com \
    --to=keithp@keithp.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=kito.cheng@gmail.com \
    --cc=pinskia@gmail.com \
    --cc=richard.sandiford@arm.com \
    --cc=sebastian.huber@embedded-brains.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).