mirror of
https://github.com/crosstool-ng/crosstool-ng.git
synced 2025-01-18 02:39:46 +00:00
packages/gcc/12.2.0: Add picolibc patches
These patches allow picolibc to act as the system C library within gcc. Signed-off-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
parent
8a9d371d06
commit
90cbc880af
141
packages/gcc/12.2.0/0005-Allow-default-libc-to-be-specified-to-configure.patch
vendored
Normal file
141
packages/gcc/12.2.0/0005-Allow-default-libc-to-be-specified-to-configure.patch
vendored
Normal file
@ -0,0 +1,141 @@
|
||||
From e55524baedbf2dc94b5159373c2b71049bdde1a8 Mon Sep 17 00:00:00 2001
|
||||
From: Keith Packard <keithp@keithp.com>
|
||||
Date: Fri, 2 Sep 2022 23:07:05 -0700
|
||||
Subject: [PATCH 5/9] Allow default libc to be specified to configure
|
||||
|
||||
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 <keithp@keithp.com>
|
||||
---
|
||||
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 c5064dd3766..ddab68fbf8f 100644
|
||||
--- a/gcc/config.gcc
|
||||
+++ b/gcc/config.gcc
|
||||
@@ -648,6 +648,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 \
|
||||
@@ -854,16 +856,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
|
||||
@@ -956,7 +958,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
|
||||
@@ -1606,13 +1609,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
|
||||
;;
|
||||
*)
|
||||
@@ -3065,7 +3068,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*)
|
||||
@@ -5915,3 +5918,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 23bee7010a3..4fd41993b58 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.
|
||||
--
|
||||
2.39.0
|
||||
|
42
packages/gcc/12.2.0/0006-Add-newlib-and-picolibc-as-default-C-library-choices.patch
vendored
Normal file
42
packages/gcc/12.2.0/0006-Add-newlib-and-picolibc-as-default-C-library-choices.patch
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
From 2e3918a283c1c9fb3b4775fe96a56e430748579a Mon Sep 17 00:00:00 2001
|
||||
From: Keith Packard <keithp@keithp.com>
|
||||
Date: Tue, 23 Aug 2022 22:12:06 -0700
|
||||
Subject: [PATCH 6/9] Add newlib and picolibc as default C library choices
|
||||
|
||||
Signed-off-by: Keith Packard <keithp@keithp.com>
|
||||
---
|
||||
gcc/config.gcc | 11 ++++++++++-
|
||||
1 file changed, 10 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/gcc/config.gcc b/gcc/config.gcc
|
||||
index ddab68fbf8f..e294ff8fbc8 100644
|
||||
--- a/gcc/config.gcc
|
||||
+++ b/gcc/config.gcc
|
||||
@@ -646,7 +646,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=""
|
||||
|
||||
@@ -5932,6 +5932,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
|
||||
+ ;;
|
||||
"")
|
||||
;;
|
||||
*)
|
||||
--
|
||||
2.39.0
|
||||
|
38
packages/gcc/12.2.0/0007-Support-picolibc-targets.patch
vendored
Normal file
38
packages/gcc/12.2.0/0007-Support-picolibc-targets.patch
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
From 41b20e994970f0ae63fb3f49c6f89a0b2f06aecb Mon Sep 17 00:00:00 2001
|
||||
From: Keith Packard <keithp@keithp.com>
|
||||
Date: Sun, 12 Feb 2023 14:23:32 -0800
|
||||
Subject: [PATCH 7/9] Support picolibc targets
|
||||
|
||||
Match *-picolibc-* and select picolibc as the default C library, plus continuing to use
|
||||
the newlib-based logic for other configuration items.
|
||||
|
||||
Signed-off-by: Keith Packard <keithp@keithp.com>
|
||||
---
|
||||
gcc/config.gcc | 11 +++++++++++
|
||||
1 file changed, 11 insertions(+)
|
||||
|
||||
diff --git a/gcc/config.gcc b/gcc/config.gcc
|
||||
index e294ff8fbc8..06af4057079 100644
|
||||
--- a/gcc/config.gcc
|
||||
+++ b/gcc/config.gcc
|
||||
@@ -1082,6 +1082,17 @@ case ${target} in
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
+*-picolibc-*)
|
||||
+ # __cxa_atexit is provided.
|
||||
+ default_use_cxa_atexit=yes
|
||||
+ use_gcc_stdint=wrap
|
||||
+ default_libc=LIBC_PICOLIBC
|
||||
+ case "${with_newlib}-${with_headers}" in
|
||||
+ no-no) use_gcc_stdint=provide ;;
|
||||
+ *) ;;
|
||||
+ esac
|
||||
+ ;;
|
||||
+
|
||||
*-*-elf|arc*-*-elf*)
|
||||
# Assume that newlib is being used and so __cxa_atexit is provided.
|
||||
default_use_cxa_atexit=yes
|
||||
--
|
||||
2.39.0
|
||||
|
68
packages/gcc/12.2.0/0008-gcc-Allow-g-to-work-differently-from-gcc.patch
vendored
Normal file
68
packages/gcc/12.2.0/0008-gcc-Allow-g-to-work-differently-from-gcc.patch
vendored
Normal file
@ -0,0 +1,68 @@
|
||||
From e426a20988185695675a2c456e0c24dcea515baf Mon Sep 17 00:00:00 2001
|
||||
From: Keith Packard <keithp@keithp.com>
|
||||
Date: Sat, 11 Feb 2023 23:07:08 -0800
|
||||
Subject: [PATCH 8/9] gcc: Allow g++ to work differently from gcc
|
||||
|
||||
Compile gcc.cc with -DIN_GPP defined when building g++ so that the
|
||||
code can respond appropriately for the default target language. This
|
||||
allows the driver to customize the specs used, selecting different
|
||||
linker scripts, adjusting the use of crtbegin.o/crtend.o etc.
|
||||
|
||||
By default, this change has no effect; targets need to explicitly
|
||||
check for IN_GPP to have alternate behavior.
|
||||
|
||||
Signed-off-by: Keith Packard <keithp@keithp.com>
|
||||
---
|
||||
gcc/cp/Make-lang.in | 7 ++++++-
|
||||
gcc/gpp.cc | 21 +++++++++++++++++++++
|
||||
2 files changed, 27 insertions(+), 1 deletion(-)
|
||||
create mode 100644 gcc/gpp.cc
|
||||
|
||||
diff --git a/gcc/cp/Make-lang.in b/gcc/cp/Make-lang.in
|
||||
index 2de4e47c659..39c659b9537 100644
|
||||
--- a/gcc/cp/Make-lang.in
|
||||
+++ b/gcc/cp/Make-lang.in
|
||||
@@ -68,7 +68,12 @@ CFLAGS-cp/module.o += -DMODULE_VERSION='($(subst -,,$(MODULE_VERSION))U)'
|
||||
endif
|
||||
|
||||
# Create the compiler driver for g++.
|
||||
-GXX_OBJS = $(GCC_OBJS) cp/g++spec.o
|
||||
+GXX_OBJS = $(GCC_OBJS:gcc.o=gpp.o) cp/g++spec.o
|
||||
+
|
||||
+CFLAGS-gpp.o = $(CFLAGS-gcc.o)
|
||||
+gpp.o: $(BASEVER)
|
||||
+gpp.o: gcc.o
|
||||
+
|
||||
xg++$(exeext): $(GXX_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a $(LIBDEPS)
|
||||
+$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
|
||||
$(GXX_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a \
|
||||
diff --git a/gcc/gpp.cc b/gcc/gpp.cc
|
||||
new file mode 100644
|
||||
index 00000000000..3cd7b45e808
|
||||
--- /dev/null
|
||||
+++ b/gcc/gpp.cc
|
||||
@@ -0,0 +1,21 @@
|
||||
+/* Compiler driver program that can handle many languages.
|
||||
+ Copyright (C) 1987-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/>. */
|
||||
+
|
||||
+#define IN_GPP
|
||||
+#include "gcc.cc"
|
||||
--
|
||||
2.39.0
|
||||
|
138
packages/gcc/12.2.0/0009-picolibc-Add-custom-spec-file-fragments-for-using-pi.patch
vendored
Normal file
138
packages/gcc/12.2.0/0009-picolibc-Add-custom-spec-file-fragments-for-using-pi.patch
vendored
Normal file
@ -0,0 +1,138 @@
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user