aboutsummaryrefslogtreecommitdiff
path: root/packages/gcc/12.4.0
diff options
context:
space:
mode:
Diffstat (limited to 'packages/gcc/12.4.0')
-rw-r--r--packages/gcc/12.4.0/0000-libtool-leave-framework-alone.patch18
-rw-r--r--packages/gcc/12.4.0/0001-gcc-plugin-POSIX-include-sys-select-h.patch14
-rw-r--r--packages/gcc/12.4.0/0002-arm-softfloat-libgcc.patch31
-rw-r--r--packages/gcc/12.4.0/0003-libgcc-disable-split-stack-nothreads.patch17
-rw-r--r--packages/gcc/12.4.0/0004-Remove-use-of-include_next-from-c-headers.patch262
-rw-r--r--packages/gcc/12.4.0/0005-Allow-default-libc-to-be-specified-to-configure.patch134
-rw-r--r--packages/gcc/12.4.0/0006-driver-Extend-getenv-function-to-allow-default-value.patch95
-rw-r--r--packages/gcc/12.4.0/0007-Add-newlib-and-picolibc-as-default-C-library-choices.patch37
-rw-r--r--packages/gcc/12.4.0/0008-Support-picolibc-targets.patch33
-rw-r--r--packages/gcc/12.4.0/0009-gcc-Allow-g-to-work-differently-from-gcc.patch60
-rw-r--r--packages/gcc/12.4.0/0010-Remove-crypt-and-crypt_r-interceptors.patch124
-rw-r--r--packages/gcc/12.4.0/0011-always-define-win32-lean-and-mean-before-windows-h.patch379
-rw-r--r--packages/gcc/12.4.0/chksum8
-rw-r--r--packages/gcc/12.4.0/experimental/0001-picolibc-Add-custom-spec-file-fragments-for-using-pi.patch138
-rw-r--r--packages/gcc/12.4.0/version.desc0
15 files changed, 1350 insertions, 0 deletions
diff --git a/packages/gcc/12.4.0/0000-libtool-leave-framework-alone.patch b/packages/gcc/12.4.0/0000-libtool-leave-framework-alone.patch
new file mode 100644
index 00000000..1a86e415
--- /dev/null
+++ b/packages/gcc/12.4.0/0000-libtool-leave-framework-alone.patch
@@ -0,0 +1,18 @@
+---
+ libtool-ldflags | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+--- a/libtool-ldflags
++++ b/libtool-ldflags
+@@ -36,6 +36,11 @@
+ for arg
+ do
+ case $arg in
++ -framework)
++ # libtool handles this option. It should not be prefixed with
++ # -Xcompiler, as that would split it from the argument that
++ # follows.
++ ;;
+ -f*|--*|-static-lib*|-shared-lib*|-B*)
+ # Libtool does not ascribe any special meaning options
+ # that begin with -f or with a double-dash. So, it will
diff --git a/packages/gcc/12.4.0/0001-gcc-plugin-POSIX-include-sys-select-h.patch b/packages/gcc/12.4.0/0001-gcc-plugin-POSIX-include-sys-select-h.patch
new file mode 100644
index 00000000..5f9a07a2
--- /dev/null
+++ b/packages/gcc/12.4.0/0001-gcc-plugin-POSIX-include-sys-select-h.patch
@@ -0,0 +1,14 @@
+---
+ libcc1/connection.cc | 1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/libcc1/connection.cc
++++ b/libcc1/connection.cc
+@@ -21,6 +21,7 @@
+ #include <string>
+ #include <unistd.h>
+ #include <sys/types.h>
++#include <sys/select.h>
+ #include <string.h>
+ #include <errno.h>
+ #include "marshall.hh"
diff --git a/packages/gcc/12.4.0/0002-arm-softfloat-libgcc.patch b/packages/gcc/12.4.0/0002-arm-softfloat-libgcc.patch
new file mode 100644
index 00000000..d9800365
--- /dev/null
+++ b/packages/gcc/12.4.0/0002-arm-softfloat-libgcc.patch
@@ -0,0 +1,31 @@
+---
+ gcc/config/arm/linux-elf.h | 2 +-
+ libgcc/config/arm/t-linux | 7 ++++++-
+ 2 files changed, 7 insertions(+), 2 deletions(-)
+
+--- a/gcc/config/arm/linux-elf.h
++++ b/gcc/config/arm/linux-elf.h
+@@ -58,7 +58,7 @@
+ %{shared:-lc} \
+ %{!shared:%{profile:-lc_p}%{!profile:-lc}}"
+
+-#define LIBGCC_SPEC "%{mfloat-abi=soft*:-lfloat} -lgcc"
++#define LIBGCC_SPEC "-lgcc"
+
+ #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
+
+--- a/libgcc/config/arm/t-linux
++++ b/libgcc/config/arm/t-linux
+@@ -1,6 +1,11 @@
+ LIB1ASMSRC = arm/lib1funcs.S
+ LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_lnx _clzsi2 _clzdi2 \
+- _ctzsi2 _arm_addsubdf3 _arm_addsubsf3
++ _ctzsi2 _arm_addsubdf3 _arm_addsubsf3 \
++ _arm_addsubdf3 _arm_addsubsf3 \
++ _arm_negdf2 _arm_muldivdf3 _arm_cmpdf2 _arm_unorddf2 \
++ _arm_fixdfsi _arm_fixunsdfsi _arm_truncdfsf2 \
++ _arm_negsf2 _arm_muldivsf3 _arm_cmpsf2 _arm_unordsf2 \
++ _arm_fixsfsi _arm_fixunssfsi
+
+ # Just for these, we omit the frame pointer since it makes such a big
+ # difference.
diff --git a/packages/gcc/12.4.0/0003-libgcc-disable-split-stack-nothreads.patch b/packages/gcc/12.4.0/0003-libgcc-disable-split-stack-nothreads.patch
new file mode 100644
index 00000000..df91a9ff
--- /dev/null
+++ b/packages/gcc/12.4.0/0003-libgcc-disable-split-stack-nothreads.patch
@@ -0,0 +1,17 @@
+disable split-stack for non-thread builds
+
+Signed-off-by: Waldemar Brodkorb <wbx@openadk.org>
+
+---
+ libgcc/config/t-stack | 2 ++
+ 1 file changed, 2 insertions(+)
+
+--- a/libgcc/config/t-stack
++++ b/libgcc/config/t-stack
+@@ -1,4 +1,6 @@
+ # Makefile fragment to provide generic support for -fsplit-stack.
+ # This should be used in config.host for any host which supports
+ # -fsplit-stack.
++ifeq ($(enable_threads),yes)
+ LIB2ADD_ST += $(srcdir)/generic-morestack.c $(srcdir)/generic-morestack-thread.c
++endif
diff --git a/packages/gcc/12.4.0/0004-Remove-use-of-include_next-from-c-headers.patch b/packages/gcc/12.4.0/0004-Remove-use-of-include_next-from-c-headers.patch
new file mode 100644
index 00000000..c0e35ffc
--- /dev/null
+++ b/packages/gcc/12.4.0/0004-Remove-use-of-include_next-from-c-headers.patch
@@ -0,0 +1,262 @@
+From ed1daa2cc9130e7807f32d515d16597fd2df8c25 Mon Sep 17 00:00:00 2001
+From: Keith Packard <keithp@keithp.com>
+Date: Sun, 24 Jan 2021 14:20:33 -0800
+Subject: [PATCH] Remove use of include_next from c++ headers
+
+Using include_next bypasses the default header search path and lets
+files later in the include path take priority over earlier files.
+
+This makes replacing libc impossible as the default libc headers will
+occur after the libstdc++ headers, and so be picked up in place of
+headers inserted at the begining of the search path or appended to the
+end of the search path.
+
+Using include_next is a hack to work-around broken combinations of
+libraries, and is not necessary in a well constructed toolchain.
+
+Signed-off-by: Keith Packard <keithp@keithp.com>
+---
+ libstdc++-v3/include/bits/std_abs.h | 4 ++--
+ libstdc++-v3/include/c/cassert | 2 +-
+ libstdc++-v3/include/c/cctype | 2 +-
+ libstdc++-v3/include/c/cerrno | 2 +-
+ libstdc++-v3/include/c/cfloat | 2 +-
+ libstdc++-v3/include/c/climits | 2 +-
+ libstdc++-v3/include/c/clocale | 2 +-
+ libstdc++-v3/include/c/cmath | 2 +-
+ libstdc++-v3/include/c/csetjmp | 2 +-
+ libstdc++-v3/include/c/csignal | 2 +-
+ libstdc++-v3/include/c/cstdarg | 2 +-
+ libstdc++-v3/include/c/cstddef | 2 +-
+ libstdc++-v3/include/c/cstdio | 2 +-
+ libstdc++-v3/include/c/cstdlib | 2 +-
+ libstdc++-v3/include/c/cstring | 2 +-
+ libstdc++-v3/include/c/ctime | 2 +-
+ libstdc++-v3/include/c/cuchar | 2 +-
+ libstdc++-v3/include/c/cwchar | 2 +-
+ libstdc++-v3/include/c/cwctype | 2 +-
+ libstdc++-v3/include/c_global/cmath | 2 +-
+ libstdc++-v3/include/c_global/cstdlib | 2 +-
+ 21 files changed, 22 insertions(+), 22 deletions(-)
+
+--- a/libstdc++-v3/include/bits/std_abs.h
++++ b/libstdc++-v3/include/bits/std_abs.h
+@@ -35,9 +35,9 @@
+ #include <bits/c++config.h>
+
+ #define _GLIBCXX_INCLUDE_NEXT_C_HEADERS
+-#include_next <stdlib.h>
++#include <stdlib.h>
+ #ifdef __CORRECT_ISO_CPP_MATH_H_PROTO
+-# include_next <math.h>
++# include <math.h>
+ #endif
+ #undef _GLIBCXX_INCLUDE_NEXT_C_HEADERS
+
+--- a/libstdc++-v3/include/c/cassert
++++ b/libstdc++-v3/include/c/cassert
+@@ -31,4 +31,4 @@
+ #pragma GCC system_header
+
+ #include <bits/c++config.h>
+-#include_next <assert.h>
++#include <assert.h>
+--- a/libstdc++-v3/include/c/cctype
++++ b/libstdc++-v3/include/c/cctype
+@@ -31,6 +31,6 @@
+
+ #pragma GCC system_header
+
+-#include_next <ctype.h>
++#include <ctype.h>
+
+ #endif
+--- a/libstdc++-v3/include/c/cerrno
++++ b/libstdc++-v3/include/c/cerrno
+@@ -41,7 +41,7 @@
+ #pragma GCC system_header
+
+ #include <bits/c++config.h>
+-#include_next <errno.h>
++#include <errno.h>
+
+ // Adhere to section 17.4.1.2 clause 5 of ISO 14882:1998
+ #ifndef errno
+--- a/libstdc++-v3/include/c/cfloat
++++ b/libstdc++-v3/include/c/cfloat
+@@ -32,6 +32,6 @@
+ #pragma GCC system_header
+
+ #include <bits/c++config.h>
+-#include_next <float.h>
++#include <float.h>
+
+ #endif
+--- a/libstdc++-v3/include/c/climits
++++ b/libstdc++-v3/include/c/climits
+@@ -32,6 +32,6 @@
+ #pragma GCC system_header
+
+ #include <bits/c++config.h>
+-#include_next <limits.h>
++#include <limits.h>
+
+ #endif
+--- a/libstdc++-v3/include/c/clocale
++++ b/libstdc++-v3/include/c/clocale
+@@ -31,6 +31,6 @@
+
+ #pragma GCC system_header
+
+-#include_next <locale.h>
++#include <locale.h>
+
+ #endif
+--- a/libstdc++-v3/include/c/cmath
++++ b/libstdc++-v3/include/c/cmath
+@@ -33,7 +33,7 @@
+
+ #include <bits/c++config.h>
+
+-#include_next <math.h>
++#include <math.h>
+
+ // Get rid of those macros defined in <math.h> in lieu of real functions.
+ #undef abs
+--- a/libstdc++-v3/include/c/csetjmp
++++ b/libstdc++-v3/include/c/csetjmp
+@@ -31,7 +31,7 @@
+
+ #pragma GCC system_header
+
+-#include_next <setjmp.h>
++#include <setjmp.h>
+
+ // Get rid of those macros defined in <setjmp.h> in lieu of real functions.
+ #undef longjmp
+--- a/libstdc++-v3/include/c/csignal
++++ b/libstdc++-v3/include/c/csignal
+@@ -31,6 +31,6 @@
+
+ #pragma GCC system_header
+
+-#include_next <signal.h>
++#include <signal.h>
+
+ #endif
+--- a/libstdc++-v3/include/c/cstdarg
++++ b/libstdc++-v3/include/c/cstdarg
+@@ -32,6 +32,6 @@
+ #pragma GCC system_header
+
+ #undef __need___va_list
+-#include_next <stdarg.h>
++#include <stdarg.h>
+
+ #endif
+--- a/libstdc++-v3/include/c/cstddef
++++ b/libstdc++-v3/include/c/cstddef
+@@ -35,6 +35,6 @@
+ #define __need_ptrdiff_t
+ #define __need_NULL
+ #define __need_offsetof
+-#include_next <stddef.h>
++#include <stddef.h>
+
+ #endif
+--- a/libstdc++-v3/include/c/cstdio
++++ b/libstdc++-v3/include/c/cstdio
+@@ -31,7 +31,7 @@
+
+ #pragma GCC system_header
+
+-#include_next <stdio.h>
++#include <stdio.h>
+
+ // Get rid of those macros defined in <stdio.h> in lieu of real functions.
+ #undef clearerr
+--- a/libstdc++-v3/include/c/cstdlib
++++ b/libstdc++-v3/include/c/cstdlib
+@@ -31,6 +31,6 @@
+
+ #pragma GCC system_header
+
+-#include_next <stdlib.h>
++#include <stdlib.h>
+
+ #endif
+--- a/libstdc++-v3/include/c/cstring
++++ b/libstdc++-v3/include/c/cstring
+@@ -31,6 +31,6 @@
+
+ #pragma GCC system_header
+
+-#include_next <string.h>
++#include <string.h>
+
+ #endif
+--- a/libstdc++-v3/include/c/ctime
++++ b/libstdc++-v3/include/c/ctime
+@@ -31,6 +31,6 @@
+
+ #pragma GCC system_header
+
+-#include_next <time.h>
++#include <time.h>
+
+ #endif
+--- a/libstdc++-v3/include/c/cuchar
++++ b/libstdc++-v3/include/c/cuchar
+@@ -39,7 +39,7 @@
+ #include <cwchar>
+
+ #if _GLIBCXX_USE_C11_UCHAR_CXX11
+-# include_next <uchar.h>
++# include <uchar.h>
+ #endif
+
+ #endif // C++11
+--- a/libstdc++-v3/include/c/cwchar
++++ b/libstdc++-v3/include/c/cwchar
+@@ -36,7 +36,7 @@
+ #include <ctime>
+
+ #if _GLIBCXX_HAVE_WCHAR_H
+-#include_next <wchar.h>
++#include <wchar.h>
+ #endif
+
+ // Need to do a bit of trickery here with mbstate_t as char_traits
+--- a/libstdc++-v3/include/c/cwctype
++++ b/libstdc++-v3/include/c/cwctype
+@@ -34,7 +34,7 @@
+ #include <bits/c++config.h>
+
+ #if _GLIBCXX_HAVE_WCTYPE_H
+-#include_next <wctype.h>
++#include <wctype.h>
+ #endif
+
+ #endif
+--- a/libstdc++-v3/include/c_global/cmath
++++ b/libstdc++-v3/include/c_global/cmath
+@@ -42,7 +42,7 @@
+ #include <bits/cpp_type_traits.h>
+ #include <ext/type_traits.h>
+ #define _GLIBCXX_INCLUDE_NEXT_C_HEADERS
+-#include_next <math.h>
++#include <math.h>
+ #undef _GLIBCXX_INCLUDE_NEXT_C_HEADERS
+ #include <bits/std_abs.h>
+
+--- a/libstdc++-v3/include/c_global/cstdlib
++++ b/libstdc++-v3/include/c_global/cstdlib
+@@ -72,7 +72,7 @@
+ // Need to ensure this finds the C library's <stdlib.h> not a libstdc++
+ // wrapper that might already be installed later in the include search path.
+ #define _GLIBCXX_INCLUDE_NEXT_C_HEADERS
+-#include_next <stdlib.h>
++#include <stdlib.h>
+ #undef _GLIBCXX_INCLUDE_NEXT_C_HEADERS
+ #include <bits/std_abs.h>
+
diff --git a/packages/gcc/12.4.0/0005-Allow-default-libc-to-be-specified-to-configure.patch b/packages/gcc/12.4.0/0005-Allow-default-libc-to-be-specified-to-configure.patch
new file mode 100644
index 00000000..924260f2
--- /dev/null
+++ b/packages/gcc/12.4.0/0005-Allow-default-libc-to-be-specified-to-configure.patch
@@ -0,0 +1,134 @@
+From 62bed0c557c6f5836ba06c9b4e4ffa32c6c3c122 Mon Sep 17 00:00:00 2001
+From: Keith Packard <keithp@keithp.com>
+Date: Fri, 2 Sep 2022 23:07:05 -0700
+Subject: [PATCH] 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(-)
+
+--- a/gcc/config.gcc
++++ b/gcc/config.gcc
+@@ -652,6 +652,8 @@
+ # 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 \
+@@ -857,16 +859,16 @@
+ 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
+@@ -959,7 +961,8 @@
+ 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
+@@ -1609,13 +1612,13 @@
+
+ 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
+ ;;
+ *)
+@@ -3068,7 +3071,7 @@
+ 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*)
+@@ -5925,3 +5928,32 @@
+ 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
+--- a/gcc/configure.ac
++++ b/gcc/configure.ac
+@@ -2498,6 +2498,10 @@
+ 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.
diff --git a/packages/gcc/12.4.0/0006-driver-Extend-getenv-function-to-allow-default-value.patch b/packages/gcc/12.4.0/0006-driver-Extend-getenv-function-to-allow-default-value.patch
new file mode 100644
index 00000000..f5429510
--- /dev/null
+++ b/packages/gcc/12.4.0/0006-driver-Extend-getenv-function-to-allow-default-value.patch
@@ -0,0 +1,95 @@
+From e18ce0c5f968167b5337a06fe61c4377c4349f1a Mon Sep 17 00:00:00 2001
+From: Keith Packard <keithp@keithp.com>
+Date: Fri, 26 Aug 2022 14:30:03 -0700
+Subject: [PATCH] driver: Extend 'getenv' function to allow default value
+
+Right now, a missing environment variable provided to the 'getenv'
+function in a .specs file causes a fatal error. That makes writing a
+spec file that uses the GCC_EXEC_PREFIX value difficult as that
+variable is only set when the driver has been relocated, but not when
+run from the defined location. This makes building a relocatable
+toolchain difficult to extend to other ancilary pieces which use specs
+files to locate header and library files adjacent to the toolchain.
+
+This patch adds an optional third argument to the getenv function that
+can be used to fall back to the standard installation path when the
+driver hasn't set GCC_EXEC_PREFIX in the environment.
+
+For example, if an alternate C library is installed in
+${prefix}/extra, then this change allows the specs file to locate that
+relative to the gcc directory, if gcc is located in the original
+installation directory (which would leave GCC_EXEC_PREFIX unset), or
+if the gcc tree has been moved to a different location (where gcc
+would set GCC_EXEC_PREFIX itself):
+
+*cpp:
+-isystem %:getenv(GCC_EXEC_PREFIX ../../extra/include ${prefix}/extra/include)
+
+I considered changing the behavior of either the %R sequence so that
+it had a defined behavior when there was no sysroot defined, or making
+the driver always set the GCC_EXEC_PREFIX environment variable and
+decided that the approach of adding functionality to getenv where it
+was previously invalid would cause the least potential for affecting
+existing usage.
+
+Signed-off-by: Keith Packard <keithp@keithp.com>
+---
+ gcc/doc/invoke.texi | 18 +++++++++++-------
+ gcc/gcc.cc | 10 +++++++++-
+ 2 files changed, 20 insertions(+), 8 deletions(-)
+
+--- a/gcc/doc/invoke.texi
++++ b/gcc/doc/invoke.texi
+@@ -33837,17 +33837,21 @@
+
+ @table @code
+ @item @code{getenv}
+-The @code{getenv} spec function takes two arguments: an environment
+-variable name and a string. If the environment variable is not
+-defined, a fatal error is issued. Otherwise, the return value is the
+-value of the environment variable concatenated with the string. For
+-example, if @env{TOPDIR} is defined as @file{/path/to/top}, then:
++
++The @code{getenv} spec function takes two or three arguments: an
++environment variable name, a string and an optional default value. If
++the environment variable is not defined and a default value is
++provided, that is used as the return value; otherwise a fatal error is
++issued. Otherwise, the return value is the value of the environment
++variable concatenated with the string. For example, if @env{TOPDIR}
++is defined as @file{/path/to/top}, then:
+
+ @smallexample
+-%:getenv(TOPDIR /include)
++%:getenv(TOPDIR /include /path/to/default/include)
+ @end smallexample
+
+-expands to @file{/path/to/top/include}.
++expands to @file{/path/to/top/include}. If @env{TOPDIR} is not
++defined, then this expands to @file{/path/to/default/include}.
+
+ @item @code{if-exists}
+ The @code{if-exists} spec function takes one argument, an absolute
+--- a/gcc/gcc.cc
++++ b/gcc/gcc.cc
+@@ -10167,12 +10167,20 @@
+ char *ptr;
+ size_t len;
+
+- if (argc != 2)
++ if (argc != 2 && argc != 3)
+ return NULL;
+
+ varname = argv[0];
+ value = env.get (varname);
+
++ if (!value && argc == 3)
++ {
++ value = argv[2];
++ result = XNEWVAR(char, strlen(value) + 1);
++ strcpy(result, value);
++ return result;
++ }
++
+ /* If the variable isn't defined and this is allowed, craft our expected
+ return value. Assume variable names used in specs strings don't contain
+ any active spec character so don't need escaping. */
diff --git a/packages/gcc/12.4.0/0007-Add-newlib-and-picolibc-as-default-C-library-choices.patch b/packages/gcc/12.4.0/0007-Add-newlib-and-picolibc-as-default-C-library-choices.patch
new file mode 100644
index 00000000..d1cf760c
--- /dev/null
+++ b/packages/gcc/12.4.0/0007-Add-newlib-and-picolibc-as-default-C-library-choices.patch
@@ -0,0 +1,37 @@
+From abbd605ce30a1ff8bea37ee955340b2247b8966b Mon Sep 17 00:00:00 2001
+From: Keith Packard <keithp@keithp.com>
+Date: Tue, 23 Aug 2022 22:12:06 -0700
+Subject: [PATCH] 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(-)
+
+--- a/gcc/config.gcc
++++ b/gcc/config.gcc
+@@ -650,7 +650,7 @@
+ 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=""
+
+@@ -5942,6 +5942,15 @@
+ 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
++ ;;
+ "")
+ ;;
+ *)
diff --git a/packages/gcc/12.4.0/0008-Support-picolibc-targets.patch b/packages/gcc/12.4.0/0008-Support-picolibc-targets.patch
new file mode 100644
index 00000000..cccc4ffb
--- /dev/null
+++ b/packages/gcc/12.4.0/0008-Support-picolibc-targets.patch
@@ -0,0 +1,33 @@
+From 3d83dcc5d2936ab76caecbf6cc35c3ee846ce01b Mon Sep 17 00:00:00 2001
+From: Keith Packard <keithp@keithp.com>
+Date: Sun, 12 Feb 2023 14:23:32 -0800
+Subject: [PATCH] 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(+)
+
+--- a/gcc/config.gcc
++++ b/gcc/config.gcc
+@@ -1085,6 +1085,17 @@
+ ;;
+ 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
diff --git a/packages/gcc/12.4.0/0009-gcc-Allow-g-to-work-differently-from-gcc.patch b/packages/gcc/12.4.0/0009-gcc-Allow-g-to-work-differently-from-gcc.patch
new file mode 100644
index 00000000..7b2a9bc2
--- /dev/null
+++ b/packages/gcc/12.4.0/0009-gcc-Allow-g-to-work-differently-from-gcc.patch
@@ -0,0 +1,60 @@
+From 69e8976de231174e10316452de791d63fa5b9ee8 Mon Sep 17 00:00:00 2001
+From: Keith Packard <keithp@keithp.com>
+Date: Sat, 11 Feb 2023 23:07:08 -0800
+Subject: [PATCH] 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
+
+--- a/gcc/cp/Make-lang.in
++++ b/gcc/cp/Make-lang.in
+@@ -77,7 +77,12 @@
+ 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 \
+--- /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"
diff --git a/packages/gcc/12.4.0/0010-Remove-crypt-and-crypt_r-interceptors.patch b/packages/gcc/12.4.0/0010-Remove-crypt-and-crypt_r-interceptors.patch
new file mode 100644
index 00000000..f22c8d73
--- /dev/null
+++ b/packages/gcc/12.4.0/0010-Remove-crypt-and-crypt_r-interceptors.patch
@@ -0,0 +1,124 @@
+From 95f0b5a33ef2f774e7fc0f3f85c0472b0b670996 Mon Sep 17 00:00:00 2001
+From: Fangrui Song <i@maskray.me>
+Date: Fri, 28 Apr 2023 09:59:17 -0700
+Subject: [PATCH] Remove crypt and crypt_r interceptors
+
+From Florian Weimer's D144073
+
+> On GNU/Linux (glibc), the crypt and crypt_r functions are not part of the main shared object (libc.so.6), but libcrypt (with multiple possible sonames). The sanitizer libraries do not depend on libcrypt, so it can happen that during sanitizer library initialization, no real implementation will be found because the crypt, crypt_r functions are not present in the process image (yet). If its interceptors are called nevertheless, this results in a call through a null pointer when the sanitizer library attempts to forward the call to the real implementation.
+>
+> Many distributions have already switched to libxcrypt, a library that is separate from glibc and that can be build with sanitizers directly (avoiding the need for interceptors). This patch disables building the interceptor for glibc targets.
+
+Let's remove crypt and crypt_r interceptors (D68431) to fix issues with
+newer glibc.
+
+For older glibc, msan will not know that an uninstrumented crypt_r call
+initializes `data`, so there is a risk for false positives. However, with some
+codebase survey, I think crypt_r uses are very few and the call sites typically
+have a `memset(&data, 0, sizeof(data));` anyway.
+
+Fix https://github.com/google/sanitizers/issues/1365
+Related: https://bugzilla.redhat.com/show_bug.cgi?id=2169432
+
+Reviewed By: #sanitizers, fweimer, thesamesam, vitalybuka
+
+Differential Revision: https://reviews.llvm.org/D149403
+---
+ libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc | 37 ----------
+ libsanitizer/sanitizer_common/sanitizer_platform_interceptors.h | 2
+ libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp | 2
+ libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h | 1
+ 4 files changed, 42 deletions(-)
+
+--- a/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc
++++ b/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc
+@@ -9977,41 +9977,6 @@
+ #define INIT_GETRANDOM
+ #endif
+
+-#if SANITIZER_INTERCEPT_CRYPT
+-INTERCEPTOR(char *, crypt, char *key, char *salt) {
+- void *ctx;
+- COMMON_INTERCEPTOR_ENTER(ctx, crypt, key, salt);
+- COMMON_INTERCEPTOR_READ_RANGE(ctx, key, internal_strlen(key) + 1);
+- COMMON_INTERCEPTOR_READ_RANGE(ctx, salt, internal_strlen(salt) + 1);
+- char *res = REAL(crypt)(key, salt);
+- if (res != nullptr)
+- COMMON_INTERCEPTOR_INITIALIZE_RANGE(res, internal_strlen(res) + 1);
+- return res;
+-}
+-#define INIT_CRYPT COMMON_INTERCEPT_FUNCTION(crypt);
+-#else
+-#define INIT_CRYPT
+-#endif
+-
+-#if SANITIZER_INTERCEPT_CRYPT_R
+-INTERCEPTOR(char *, crypt_r, char *key, char *salt, void *data) {
+- void *ctx;
+- COMMON_INTERCEPTOR_ENTER(ctx, crypt_r, key, salt, data);
+- COMMON_INTERCEPTOR_READ_RANGE(ctx, key, internal_strlen(key) + 1);
+- COMMON_INTERCEPTOR_READ_RANGE(ctx, salt, internal_strlen(salt) + 1);
+- char *res = REAL(crypt_r)(key, salt, data);
+- if (res != nullptr) {
+- COMMON_INTERCEPTOR_WRITE_RANGE(ctx, data,
+- __sanitizer::struct_crypt_data_sz);
+- COMMON_INTERCEPTOR_INITIALIZE_RANGE(res, internal_strlen(res) + 1);
+- }
+- return res;
+-}
+-#define INIT_CRYPT_R COMMON_INTERCEPT_FUNCTION(crypt_r);
+-#else
+-#define INIT_CRYPT_R
+-#endif
+-
+ #if SANITIZER_INTERCEPT_GETENTROPY
+ INTERCEPTOR(int, getentropy, void *buf, SIZE_T buflen) {
+ void *ctx;
+@@ -10521,8 +10486,6 @@
+ INIT_GETUSERSHELL;
+ INIT_SL_INIT;
+ INIT_GETRANDOM;
+- INIT_CRYPT;
+- INIT_CRYPT_R;
+ INIT_GETENTROPY;
+ INIT_QSORT;
+ INIT_QSORT_R;
+--- a/libsanitizer/sanitizer_common/sanitizer_platform_interceptors.h
++++ b/libsanitizer/sanitizer_common/sanitizer_platform_interceptors.h
+@@ -568,8 +568,6 @@
+ #define SANITIZER_INTERCEPT_FDEVNAME SI_FREEBSD
+ #define SANITIZER_INTERCEPT_GETUSERSHELL (SI_POSIX && !SI_ANDROID)
+ #define SANITIZER_INTERCEPT_SL_INIT (SI_FREEBSD || SI_NETBSD)
+-#define SANITIZER_INTERCEPT_CRYPT (SI_POSIX && !SI_ANDROID)
+-#define SANITIZER_INTERCEPT_CRYPT_R (SI_LINUX && !SI_ANDROID)
+
+ #define SANITIZER_INTERCEPT_GETRANDOM \
+ ((SI_LINUX && __GLIBC_PREREQ(2, 25)) || SI_FREEBSD)
+--- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp
++++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp
+@@ -154,7 +154,6 @@
+ #include <linux/serial.h>
+ #include <sys/msg.h>
+ #include <sys/ipc.h>
+-#include <crypt.h>
+ #endif // SANITIZER_ANDROID
+
+ #include <link.h>
+@@ -254,7 +253,6 @@
+ unsigned struct_ustat_sz = SIZEOF_STRUCT_USTAT;
+ unsigned struct_rlimit64_sz = sizeof(struct rlimit64);
+ unsigned struct_statvfs64_sz = sizeof(struct statvfs64);
+- unsigned struct_crypt_data_sz = sizeof(struct crypt_data);
+ #endif // SANITIZER_LINUX && !SANITIZER_ANDROID
+
+ #if SANITIZER_LINUX && !SANITIZER_ANDROID
+--- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h
++++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h
+@@ -298,7 +298,6 @@
+ extern unsigned struct_mq_attr_sz;
+ extern unsigned struct_timex_sz;
+ extern unsigned struct_statvfs_sz;
+-extern unsigned struct_crypt_data_sz;
+ #endif // SANITIZER_LINUX && !SANITIZER_ANDROID
+
+ struct __sanitizer_iovec {
diff --git a/packages/gcc/12.4.0/0011-always-define-win32-lean-and-mean-before-windows-h.patch b/packages/gcc/12.4.0/0011-always-define-win32-lean-and-mean-before-windows-h.patch
new file mode 100644
index 00000000..688ad8fe
--- /dev/null
+++ b/packages/gcc/12.4.0/0011-always-define-win32-lean-and-mean-before-windows-h.patch
@@ -0,0 +1,379 @@
+Original patch for GCC 13 by LIU Hao <lh_mouse@126.com>
+
+Recently, mingw-w64 has got updated <msxml.h> from Wine which is included
+indirectly by <windows.h> if `WIN32_LEAN_AND_MEAN` is not defined. The
+`IXMLDOMDocument` class has a member function named `abort()`, which gets
+affected by our `abort()` macro in "system.h".
+
+`WIN32_LEAN_AND_MEAN` should, nevertheless, always be defined. This
+can exclude 'APIs such as Cryptography, DDE, RPC, Shell, and Windows
+Sockets' [1], and speed up compilation of these files a bit.
+
+[1] https://learn.microsoft.com/en-us/windows/win32/winprog/using-the-windows-headers
+
+--- a/gcc/ada/adaint.c
++++ b/gcc/ada/adaint.c
+@@ -227,6 +227,7 @@ UINT __gnat_current_ccs_encoding;
+
+ #elif defined (_WIN32)
+
++#define WIN32_LEAN_AND_MEAN
+ #include <windows.h>
+ #include <accctrl.h>
+ #include <aclapi.h>
+--- a/gcc/ada/cio.c
++++ b/gcc/ada/cio.c
+@@ -67,6 +67,7 @@ extern "C" {
+ #endif
+
+ #ifdef RTX
++#define WIN32_LEAN_AND_MEAN
+ #include <windows.h>
+ #include <Rtapi.h>
+ #endif
+--- a/gcc/ada/ctrl_c.c
++++ b/gcc/ada/ctrl_c.c
+@@ -126,6 +126,7 @@ __gnat_uninstall_int_handler (void)
+
+ #elif defined (__MINGW32__)
+
++#define WIN32_LEAN_AND_MEAN
+ #include "mingw32.h"
+ #include <windows.h>
+
+--- a/gcc/ada/expect.c
++++ b/gcc/ada/expect.c
+@@ -71,6 +71,7 @@
+
+ #ifdef _WIN32
+
++#define WIN32_LEAN_AND_MEAN
+ #include <windows.h>
+ #include <process.h>
+ #include <signal.h>
+--- a/gcc/ada/gsocket.h
++++ b/gcc/ada/gsocket.h
+@@ -167,6 +167,7 @@
+
+ #endif
+
++#define WIN32_LEAN_AND_MEAN
+ #include <windows.h>
+
+ #elif defined(VMS)
+--- a/gcc/ada/mingw32.h
++++ b/gcc/ada/mingw32.h
+@@ -53,6 +53,7 @@
+ #define _X86INTRIN_H_INCLUDED
+ #define _EMMINTRIN_H_INCLUDED
+ #endif
++#define WIN32_LEAN_AND_MEAN
+ #include <windows.h>
+
+ /* After including this file it is possible to use the character t as prefix
+--- a/gcc/ada/mkdir.c
++++ b/gcc/ada/mkdir.c
+@@ -43,6 +43,7 @@
+ #endif
+
+ #ifdef __MINGW32__
++#define WIN32_LEAN_AND_MEAN
+ #include "mingw32.h"
+ #include <windows.h>
+ #ifdef MAXPATHLEN
+--- a/gcc/ada/rtfinal.c
++++ b/gcc/ada/rtfinal.c
+@@ -46,6 +46,7 @@ extern int __gnat_rt_init_count;
+ /* see initialize.c */
+
+ #if defined (__MINGW32__)
++#define WIN32_LEAN_AND_MEAN
+ #include "mingw32.h"
+ #include <windows.h>
+
+--- a/gcc/ada/rtinit.c
++++ b/gcc/ada/rtinit.c
+@@ -70,6 +70,7 @@ int __gnat_rt_init_count = 0;
+ and finalize properly the run-time. */
+
+ #if defined (__MINGW32__)
++#define WIN32_LEAN_AND_MEAN
+ #include "mingw32.h"
+ #include <windows.h>
+
+--- a/gcc/ada/seh_init.c
++++ b/gcc/ada/seh_init.c
+@@ -34,6 +34,7 @@
+
+ #if defined (_WIN32) || (defined (__CYGWIN__) && defined (__SEH__))
+ /* Include system headers, before system.h poisons malloc. */
++#define WIN32_LEAN_AND_MEAN
+ #include <windows.h>
+ #include <excpt.h>
+ #endif
+--- a/gcc/ada/sysdep.c
++++ b/gcc/ada/sysdep.c
+@@ -217,6 +217,7 @@ __gnat_ttyname (int filedes)
+ #endif /* __CYGWIN__ */
+
+ #if defined (__CYGWIN__) || defined (__MINGW32__)
++#define WIN32_LEAN_AND_MEAN
+ #include <windows.h>
+
+ int __gnat_is_windows_xp (void);
+@@ -589,6 +590,7 @@ getc_immediate_common (FILE *stream,
+ Ada programs. */
+
+ #ifdef WINNT
++#define WIN32_LEAN_AND_MEAN
+ #include <windows.h>
+
+ /* Provide functions to echo the values passed to WinMain (windows bindings
+--- a/gcc/ada/terminals.c
++++ b/gcc/ada/terminals.c
+@@ -151,6 +151,7 @@ __gnat_setup_winsize (void *desc ATTRIBUTE_UNUSED,
+ #include <stdio.h>
+ #include <stdlib.h>
+
++#define WIN32_LEAN_AND_MEAN
+ #include <windows.h>
+ #include <winternl.h>
+ #include <io.h>
+--- a/gcc/ada/tracebak.c
++++ b/gcc/ada/tracebak.c
+@@ -93,6 +93,7 @@ extern void (*Unlock_Task) (void);
+
+ #if defined (_WIN64) && defined (__SEH__)
+
++#define WIN32_LEAN_AND_MEAN
+ #include <windows.h>
+
+ #define IS_BAD_PTR(ptr) (IsBadCodePtr((FARPROC)ptr))
+@@ -455,6 +456,7 @@ struct layout
+ #elif defined (__i386__) || defined (__x86_64__)
+
+ #if defined (__WIN32)
++#define WIN32_LEAN_AND_MEAN
+ #include <windows.h>
+ #define IS_BAD_PTR(ptr) (IsBadCodePtr((FARPROC)ptr))
+ #elif defined (__sun__)
+--- a/gcc/diagnostic-color.cc
++++ b/gcc/diagnostic-color.cc
+@@ -22,6 +22,7 @@
+ #include "diagnostic-url.h"
+
+ #ifdef __MINGW32__
++# define WIN32_LEAN_AND_MEAN
+ # include <windows.h>
+ #endif
+
+--- a/gcc/jit/jit-w32.h
++++ b/gcc/jit/jit-w32.h
+@@ -20,6 +20,7 @@ along with GCC; see the file COPYING3. If not see
+
+ #include "config.h"
+
++#define WIN32_LEAN_AND_MEAN
+ #include <windows.h>
+
+ namespace gcc {
+--- a/gcc/plugin.cc
++++ b/gcc/plugin.cc
+@@ -41,6 +41,7 @@ along with GCC; see the file COPYING3. If not see
+ #ifndef NOMINMAX
+ #define NOMINMAX
+ #endif
++#define WIN32_LEAN_AND_MEAN
+ #include <windows.h>
+ #endif
+
+--- a/gcc/prefix.cc
++++ b/gcc/prefix.cc
+@@ -67,6 +67,7 @@ License along with GCC; see the file COPYING3. If not see
+ #include "system.h"
+ #include "coretypes.h"
+ #if defined(_WIN32) && defined(ENABLE_WIN32_REGISTRY)
++#define WIN32_LEAN_AND_MEAN
+ #include <windows.h>
+ #endif
+ #include "prefix.h"
+--- a/libatomic/config/mingw/lock.c
++++ b/libatomic/config/mingw/lock.c
+@@ -23,6 +23,7 @@
+ <http://www.gnu.org/licenses/>. */
+
+ #define UWORD __shadow_UWORD
++#define WIN32_LEAN_AND_MEAN
+ #include <windows.h>
+ #undef UWORD
+ #include "libatomic_i.h"
+--- a/libffi/src/aarch64/ffi.c
++++ b/libffi/src/aarch64/ffi.c
+@@ -28,6 +28,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+ #include <ffi_common.h>
+ #include "internal.h"
+ #ifdef _WIN32
++#define WIN32_LEAN_AND_MEAN
+ #include <windows.h> /* FlushInstructionCache */
+ #endif
+ #include <tramp.h>
+--- a/libgcc/config/i386/enable-execute-stack-mingw32.c
++++ b/libgcc/config/i386/enable-execute-stack-mingw32.c
+@@ -22,6 +22,7 @@
+ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ <http://www.gnu.org/licenses/>. */
+
++#define WIN32_LEAN_AND_MEAN
+ #include <windows.h>
+
+ extern void __enable_execute_stack (void *);
+--- a/libgcc/libgcc2.c
++++ b/libgcc/libgcc2.c
+@@ -2273,6 +2273,7 @@ __clear_cache (void *beg __attribute__((__unused__)),
+ /* Jump to a trampoline, loading the static chain address. */
+
+ #if defined(WINNT) && ! defined(__CYGWIN__)
++#define WIN32_LEAN_AND_MEAN
+ #include <windows.h>
+ int getpagesize (void);
+ int mprotect (char *,int, int);
+--- a/libgcc/unwind-generic.h
++++ b/libgcc/unwind-generic.h
+@@ -30,6 +30,7 @@
+
+ #if defined (__SEH__) && !defined (__USING_SJLJ_EXCEPTIONS__)
+ /* Only for _GCC_specific_handler. */
++#define WIN32_LEAN_AND_MEAN
+ #include <windows.h>
+ #endif
+
+--- a/libgfortran/intrinsics/sleep.c
++++ b/libgfortran/intrinsics/sleep.c
+@@ -30,6 +30,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ #endif
+
+ #ifdef __MINGW32__
++# define WIN32_LEAN_AND_MEAN
+ # include <windows.h>
+ # undef sleep
+ # define sleep(x) Sleep(1000*(x))
+--- a/libgo/misc/cgo/test/callback_c.c
++++ b/libgo/misc/cgo/test/callback_c.c
+@@ -32,6 +32,7 @@ IntoC(void)
+ }
+
+ #ifdef WIN32
++#define WIN32_LEAN_AND_MEAN
+ #include <windows.h>
+ long long
+ mysleep(int seconds) {
+--- a/libgomp/config/mingw32/proc.c
++++ b/libgomp/config/mingw32/proc.c
+@@ -30,6 +30,7 @@
+ The following implementation uses win32 API routines. */
+
+ #include "libgomp.h"
++#define WIN32_LEAN_AND_MEAN
+ #include <windows.h>
+
+ /* Count the CPU's currently available to this process. */
+--- a/libiberty/make-temp-file.c
++++ b/libiberty/make-temp-file.c
+@@ -37,6 +37,7 @@ Boston, MA 02110-1301, USA. */
+ #include <sys/file.h> /* May get R_OK, etc. on some systems. */
+ #endif
+ #if defined(_WIN32) && !defined(__CYGWIN__)
++#define WIN32_LEAN_AND_MEAN
+ #include <windows.h>
+ #endif
+ #if HAVE_SYS_STAT_H
+--- a/libiberty/pex-win32.c
++++ b/libiberty/pex-win32.c
+@@ -20,6 +20,7 @@ Boston, MA 02110-1301, USA. */
+
+ #include "pex-common.h"
+
++#define WIN32_LEAN_AND_MEAN
+ #include <windows.h>
+
+ #ifdef HAVE_STDLIB_H
+--- a/libssp/ssp.c
++++ b/libssp/ssp.c
+@@ -55,6 +55,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ /* Native win32 apps don't know about /dev/tty but can print directly
+ to the console using "CONOUT$" */
+ #if defined (_WIN32) && !defined (__CYGWIN__)
++#define WIN32_LEAN_AND_MEAN
+ #include <windows.h>
+ #include <wincrypt.h>
+ # define _PATH_TTY "CONOUT$"
+--- a/libstdc++-v3/src/c++11/system_error.cc
++++ b/libstdc++-v3/src/c++11/system_error.cc
+@@ -33,6 +33,7 @@
+ #undef __sso_string
+
+ #if defined(_WIN32) && !defined(__CYGWIN__)
++#define WIN32_LEAN_AND_MEAN
+ #include <memory>
+ #include <windows.h>
+ #endif
+--- a/libstdc++-v3/src/c++11/thread.cc
++++ b/libstdc++-v3/src/c++11/thread.cc
+@@ -34,6 +34,7 @@
+ # ifdef _GLIBCXX_HAVE_SLEEP
+ # include <unistd.h>
+ # elif defined(_GLIBCXX_HAVE_WIN32_SLEEP)
++# define WIN32_LEAN_AND_MEAN
+ # include <windows.h>
+ # elif defined _GLIBCXX_NO_SLEEP && defined _GLIBCXX_HAS_GTHREADS
+ // We expect to be able to sleep for targets that support multiple threads:
+--- a/libstdc++-v3/src/c++17/fs_ops.cc
++++ b/libstdc++-v3/src/c++17/fs_ops.cc
+@@ -54,6 +54,7 @@
+ # include <utime.h> // utime
+ #endif
+ #ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
++# define WIN32_LEAN_AND_MEAN
+ # include <windows.h>
+ #endif
+
+--- a/libstdc++-v3/src/filesystem/ops.cc
++++ b/libstdc++-v3/src/filesystem/ops.cc
+@@ -55,6 +55,7 @@
+ # include <utime.h> // utime
+ #endif
+ #ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
++# define WIN32_LEAN_AND_MEAN
+ # include <windows.h>
+ #endif
+
+--- a/libvtv/vtv_malloc.cc
++++ b/libvtv/vtv_malloc.cc
+@@ -33,6 +33,7 @@
+ #include <stdlib.h>
+ #include <unistd.h>
+ #if defined (__CYGWIN__) || defined (__MINGW32__)
++#define WIN32_LEAN_AND_MEAN
+ #include <windows.h>
+ #else
+ #include <sys/mman.h>
+--- a/libvtv/vtv_rts.cc
++++ b/libvtv/vtv_rts.cc
+@@ -121,6 +121,7 @@
+ #include <stdio.h>
+ #include <string.h>
+ #if defined (__CYGWIN__) || defined (__MINGW32__)
++#define WIN32_LEAN_AND_MEAN
+ #include <windows.h>
+ #include <winternl.h>
+ #include <psapi.h>
+--- a/libvtv/vtv_utils.cc
++++ b/libvtv/vtv_utils.cc
+@@ -33,6 +33,7 @@
+ #include <stdlib.h>
+ #include <string.h>
+ #if defined (__CYGWIN__) || defined (__MINGW32__)
++#define WIN32_LEAN_AND_MEAN
+ #include <windows.h>
+ #else
+ #include <execinfo.h>
diff --git a/packages/gcc/12.4.0/chksum b/packages/gcc/12.4.0/chksum
new file mode 100644
index 00000000..228b42d4
--- /dev/null
+++ b/packages/gcc/12.4.0/chksum
@@ -0,0 +1,8 @@
+md5 gcc-12.4.0.tar.xz fd7779aee878db67456575922281fa71
+sha1 gcc-12.4.0.tar.xz b373d4ac29bb06ca64d288621906cbf63ab5a1f5
+sha256 gcc-12.4.0.tar.xz 704f652604ccbccb14bdabf3478c9511c89788b12cb3bbffded37341916a9175
+sha512 gcc-12.4.0.tar.xz 5bd29402cad2deb5d9388d0236c7146414d77e5b8d5f1c6c941c7a1f47691c3389f08656d5f6e8e2d6717bf2c81f018d326f632fb468f42925b40bd217fc4853
+md5 gcc-12.4.0.tar.gz 2c34e2879ee25358417dc53ed8896d9a
+sha1 gcc-12.4.0.tar.gz 02f5483b3114a1704943e832dff95a512f3e6ae7
+sha256 gcc-12.4.0.tar.gz 5a30de2be740062bb3ddd3fd13c9b1bb4584d8f85616d33f23a713439d714148
+sha512 gcc-12.4.0.tar.gz 13b2054a761b96d1d9b448999ea9978027deb54c5ea21af5344997efc74ca7da2df6fea462e4513c8307c672a35a74a1354de46e23d4005c60b9d50c8e5a89c8
diff --git a/packages/gcc/12.4.0/experimental/0001-picolibc-Add-custom-spec-file-fragments-for-using-pi.patch b/packages/gcc/12.4.0/experimental/0001-picolibc-Add-custom-spec-file-fragments-for-using-pi.patch
new file mode 100644
index 00000000..0c4b90b5
--- /dev/null
+++ b/packages/gcc/12.4.0/experimental/0001-picolibc-Add-custom-spec-file-fragments-for-using-pi.patch
@@ -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
+
diff --git a/packages/gcc/12.4.0/version.desc b/packages/gcc/12.4.0/version.desc
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/packages/gcc/12.4.0/version.desc