mirror of
https://github.com/crosstool-ng/crosstool-ng.git
synced 2024-12-24 06:56:40 +00:00
90cbc880af
These patches allow picolibc to act as the system C library within gcc. Signed-off-by: Keith Packard <keithp@keithp.com>
139 lines
4.6 KiB
Diff
139 lines
4.6 KiB
Diff
From ad485aba918ea651987c6d153c2202a3efb5a75f Mon Sep 17 00:00:00 2001
|
|
From: Keith Packard <keithp@keithp.com>
|
|
Date: Tue, 23 Aug 2022 22:13:08 -0700
|
|
Subject: [PATCH 9/9] picolibc: Add custom spec file fragments for using
|
|
picolibc
|
|
|
|
The '--oslib=' 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.
|
|
|
|
The '--crt0=' option allows targets to use an alternate crt0 in place
|
|
of the usual one as provided by Picolibc.
|
|
|
|
For example, picolibc provides 'libsemihost' and 'crt0-semihost.o' on
|
|
various targets which maps some POSIX APIs to semihosting capabilities
|
|
and signals the semihosting environment when 'main' returns. These
|
|
would be used by specifying --oslib=semihost --crt0=semihost.
|
|
|
|
This patch also takes advantage of the IN_GPP conditional when
|
|
building g++ to elide exception handling contents from the executable
|
|
when not linking with the g++ driver.
|
|
|
|
Signed-off-by: Keith Packard <keithp@keithp.com>
|
|
---
|
|
gcc/config.gcc | 7 +++++++
|
|
gcc/config/picolibc.h | 44 +++++++++++++++++++++++++++++++++++++++++
|
|
gcc/config/picolibc.opt | 33 +++++++++++++++++++++++++++++++
|
|
3 files changed, 84 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 06af4057079..94d53970ceb 100644
|
|
--- a/gcc/config.gcc
|
|
+++ b/gcc/config.gcc
|
|
@@ -5967,3 +5967,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..d1d3fc44477
|
|
--- /dev/null
|
|
+++ b/gcc/config/picolibc.h
|
|
@@ -0,0 +1,44 @@
|
|
+/* 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/>. */
|
|
+
|
|
+#ifdef IN_GPP
|
|
+#define PICOLIBC_LD "picolibcpp.ld"
|
|
+#define PICOLIBC_BEGIN " crtbegin%O%s"
|
|
+#define PICOLIBC_END "crtend%O%s"
|
|
+#else
|
|
+#define PICOLIBC_LD "picolibc.ld"
|
|
+#define PICOLIBC_BEGIN ""
|
|
+#define PICOLIBC_END ""
|
|
+#endif
|
|
+
|
|
+#undef LIB_SPEC
|
|
+#define LIB_SPEC "%{!T:-T" PICOLIBC_LD "} --start-group -lc %{-oslib=*:-l%*} %(libgcc) --end-group"
|
|
+
|
|
+#undef STARTFILE_SPEC
|
|
+#define STARTFILE_SPEC "%{-crt0=*:crt0-%*%O%s; :crt0%O%s}" PICOLIBC_BEGIN
|
|
+
|
|
+#undef ENDFILE_SPEC
|
|
+#define ENDFILE_SPEC PICOLIBC_END
|
|
+
|
|
+#define EH_TABLES_CAN_BE_READ_ONLY 1
|
|
diff --git a/gcc/config/picolibc.opt b/gcc/config/picolibc.opt
|
|
new file mode 100644
|
|
index 00000000000..39f81c446bb
|
|
--- /dev/null
|
|
+++ b/gcc/config/picolibc.opt
|
|
@@ -0,0 +1,33 @@
|
|
+; 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.
|
|
+
|
|
+-crt0
|
|
+Driver Separate Alias(-crt0=)
|
|
+
|
|
+-crt0=
|
|
+Driver Joined
|
|
+Specify an alternate startup file.
|
|
--
|
|
2.39.0
|
|
|