summaryrefslogtreecommitdiff
path: root/etc/patches/gcc-4.7.4
diff options
context:
space:
mode:
authorOliver Reiche <oliver.reiche@huawei.com>2023-10-20 16:07:58 +0200
committerOliver Reiche <oliver.reiche@huawei.com>2023-10-20 16:07:58 +0200
commit060a0cf338d6024eee37cc344c224fe3bcb78e81 (patch)
tree3fea7c654b69ecf3490fe9c6cbc542aba0d5bd8f /etc/patches/gcc-4.7.4
downloadbootstrappable-toolchain-060a0cf338d6024eee37cc344c224fe3bcb78e81.tar.gz
Initial commit
Diffstat (limited to 'etc/patches/gcc-4.7.4')
-rw-r--r--etc/patches/gcc-4.7.4/musl-support/0001-config.sub-add-musl-support-for-gmp-mpc-mpfr.patch80
-rw-r--r--etc/patches/gcc-4.7.4/musl-support/0002-config.sub-add-musl-support-for-gcc.patch39
-rw-r--r--etc/patches/gcc-4.7.4/musl-support/0003-musl-libc-config.patch330
-rw-r--r--etc/patches/gcc-4.7.4/musl-support/0004-x86-musl-support.patch50
-rw-r--r--etc/patches/gcc-4.7.4/musl-support/0005-libstdc-workaround-for-musl.patch50
-rw-r--r--etc/patches/gcc-4.7.4/musl-support/0006-config.guess-add-musl-support.patch196
-rw-r--r--etc/patches/gcc-4.7.4/musl-support/0007-config.guess-detect-glibc-via-__GLIBC__.patch70
-rw-r--r--etc/patches/gcc-4.7.4/musl-support/series7
-rw-r--r--etc/patches/gcc-4.7.4/reproducibility/0001-strip-build-directory-from-fixinclues.patch29
-rw-r--r--etc/patches/gcc-4.7.4/reproducibility/0002-compute-reproducible-checksums.patch58
-rw-r--r--etc/patches/gcc-4.7.4/reproducibility/series2
-rw-r--r--etc/patches/gcc-4.7.4/use-ucontext_t.patch153
-rw-r--r--etc/patches/gcc-4.7.4/various-fixes/0001-non-behavioral-changing-fix-in-gcc-cp-rtti.c.patch46
-rw-r--r--etc/patches/gcc-4.7.4/various-fixes/0002-comment-out-M4-m4-not-needed-in-gmp-configure.patch35
-rw-r--r--etc/patches/gcc-4.7.4/various-fixes/0003-cfns-fix-mismatch-in-gnu_inline-attributes.patch62
-rw-r--r--etc/patches/gcc-4.7.4/various-fixes/0004-fix-gmp-configure-to-comply-with-newer-c-standards.patch234
-rw-r--r--etc/patches/gcc-4.7.4/various-fixes/series4
17 files changed, 1445 insertions, 0 deletions
diff --git a/etc/patches/gcc-4.7.4/musl-support/0001-config.sub-add-musl-support-for-gmp-mpc-mpfr.patch b/etc/patches/gcc-4.7.4/musl-support/0001-config.sub-add-musl-support-for-gmp-mpc-mpfr.patch
new file mode 100644
index 0000000..0dd1b0d
--- /dev/null
+++ b/etc/patches/gcc-4.7.4/musl-support/0001-config.sub-add-musl-support-for-gmp-mpc-mpfr.patch
@@ -0,0 +1,80 @@
+From 491a585201160692ac8683aeb16e884e2537a685 Mon Sep 17 00:00:00 2001
+From: Oliver Reiche <oliver.reiche@huawei.com>
+Date: Thu, 29 Jun 2023 18:20:38 +0200
+Subject: [PATCH 1/7] config.sub: Add musl support for gmp/mpc/mpfr
+
+---
+ gmp/configfsf.sub | 4 ++--
+ mpc/config.sub | 4 ++--
+ mpfr/config.sub | 4 ++--
+ 3 files changed, 6 insertions(+), 6 deletions(-)
+
+diff --git a/gmp/configfsf.sub b/gmp/configfsf.sub
+index a649350a6..b08476d3f 100755
+--- a/gmp/configfsf.sub
++++ b/gmp/configfsf.sub
+@@ -120,7 +120,7 @@ esac
+ # Here we must recognize all the valid KERNEL-OS combinations.
+ maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
+ case $maybe_os in
+- nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
++ nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-musl* | linux-uclibc* | \
+ uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
+ storm-chaos* | os2-emx* | rtmk-nova*)
+ os=-$maybe_os
+@@ -1262,7 +1262,7 @@ case $os in
+ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+ | -chorusos* | -chorusrdb* | -cegcc* \
+ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+- | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
++ | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-musl* | -linux-uclibc* \
+ | -uxpv* | -beos* | -mpeix* | -udk* \
+ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
+ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
+diff --git a/mpc/config.sub b/mpc/config.sub
+index 6759825a5..0057add97 100755
+--- a/mpc/config.sub
++++ b/mpc/config.sub
+@@ -120,7 +120,7 @@ esac
+ # Here we must recognize all the valid KERNEL-OS combinations.
+ maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
+ case $maybe_os in
+- nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
++ nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-musl* | linux-uclibc* | \
+ uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
+ storm-chaos* | os2-emx* | rtmk-nova*)
+ os=-$maybe_os
+@@ -1250,7 +1250,7 @@ case $os in
+ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+ | -chorusos* | -chorusrdb* \
+ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+- | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
++ | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-musl* | -linux-uclibc* \
+ | -uxpv* | -beos* | -mpeix* | -udk* \
+ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
+ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
+diff --git a/mpfr/config.sub b/mpfr/config.sub
+index 1761d8bdf..aeb4ba340 100755
+--- a/mpfr/config.sub
++++ b/mpfr/config.sub
+@@ -120,7 +120,7 @@ esac
+ # Here we must recognize all the valid KERNEL-OS combinations.
+ maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
+ case $maybe_os in
+- nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
++ nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-musl* | linux-uclibc* | \
+ uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
+ storm-chaos* | os2-emx* | rtmk-nova*)
+ os=-$maybe_os
+@@ -1218,7 +1218,7 @@ case $os in
+ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+ | -chorusos* | -chorusrdb* \
+ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+- | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
++ | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-musl* | -linux-uclibc* \
+ | -uxpv* | -beos* | -mpeix* | -udk* \
+ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
+ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
+--
+2.30.2
+
diff --git a/etc/patches/gcc-4.7.4/musl-support/0002-config.sub-add-musl-support-for-gcc.patch b/etc/patches/gcc-4.7.4/musl-support/0002-config.sub-add-musl-support-for-gcc.patch
new file mode 100644
index 0000000..0c1682c
--- /dev/null
+++ b/etc/patches/gcc-4.7.4/musl-support/0002-config.sub-add-musl-support-for-gcc.patch
@@ -0,0 +1,39 @@
+From c3922f0d82ab03e4702eba4c3359d25fd2139bcf Mon Sep 17 00:00:00 2001
+From: Oliver Reiche <oliver.reiche@huawei.com>
+Date: Thu, 29 Jun 2023 18:04:32 +0200
+Subject: [PATCH 2/7] config.sub: Add musl support for gcc
+
+Backport from GCC 4.8.0
+ Git commit: f08bdd699385e0c8cc3c841da3f4f72d9141f68c
+ Subversion revision: r194449
+
+Co-authored-by: Jan-Benedict Glaw <jbglaw@lug-owl.de>
+---
+ config.sub | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/config.sub b/config.sub
+index 78176a440..deebfcee7 100755
+--- a/config.sub
++++ b/config.sub
+@@ -125,7 +125,7 @@ esac
+ maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
+ case $maybe_os in
+ nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
+- linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
++ linux-musl | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
+ knetbsd*-gnu* | netbsd*-gnu* | \
+ kopensolaris*-gnu* | \
+ storm-chaos* | os2-emx* | rtmk-nova*)
+@@ -1345,7 +1345,7 @@ case $os in
+ | -chorusos* | -chorusrdb* | -cegcc* \
+ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+ | -mingw32* | -linux-gnu* | -linux-android* \
+- | -linux-newlib* | -linux-uclibc* \
++ | -linux-newlib* | -linux-musl* | -linux-uclibc* \
+ | -uxpv* | -beos* | -mpeix* | -udk* \
+ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
+ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
+--
+2.30.2
+
diff --git a/etc/patches/gcc-4.7.4/musl-support/0003-musl-libc-config.patch b/etc/patches/gcc-4.7.4/musl-support/0003-musl-libc-config.patch
new file mode 100644
index 0000000..fc3d5b0
--- /dev/null
+++ b/etc/patches/gcc-4.7.4/musl-support/0003-musl-libc-config.patch
@@ -0,0 +1,330 @@
+From 2568562d330c29bf2b487a85677cd319d78630bf Mon Sep 17 00:00:00 2001
+From: Oliver Reiche <oliver.reiche@huawei.com>
+Date: Thu, 29 Jun 2023 16:52:26 +0200
+Subject: [PATCH 3/7] musl libc config
+
+Backport from GCC 6.1.0
+ Git commit: 755658a56b57beca14b5fb70afdf1e588a058f7f
+ Subversion revision: r222904
+
+Original description:
+ * config.gcc (LIBC_MUSL): New tm_defines macro.
+ * config/linux.h (OPTION_MUSL): Define.
+ (MUSL_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER32,)
+ (MUSL_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKERX32,)
+ (INCLUDE_DEFAULTS_MUSL_GPP, INCLUDE_DEFAULTS_MUSL_LOCAL,)
+ (INCLUDE_DEFAULTS_MUSL_PREFIX, INCLUDE_DEFAULTS_MUSL_CROSS,)
+ (INCLUDE_DEFAULTS_MUSL_TOOL, INCLUDE_DEFAULTS_MUSL_NATIVE): Define.
+ * config/linux.opt (mmusl): New option.
+ * doc/invoke.texi (GNU/Linux Options): Document -mmusl.
+ * configure.ac (gcc_cv_libc_provides_ssp): Add *-*-musl*.
+ (gcc_cv_target_dl_iterate_phdr): Add *-linux-musl*.
+ * configure: Regenerate.
+
+Co-authored-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
+Co-authored-by: Gregor Richards <gregor.richards@uwaterloo.ca>
+---
+ gcc/config.gcc | 5 +-
+ gcc/config/linux.h | 110 +++++++++++++++++++++++++++++++++++++------
+ gcc/config/linux.opt | 6 ++-
+ gcc/configure | 7 +++
+ gcc/configure.ac | 7 +++
+ gcc/doc/invoke.texi | 10 +++-
+ 6 files changed, 127 insertions(+), 18 deletions(-)
+
+diff --git a/gcc/config.gcc b/gcc/config.gcc
+index 9503b96cf..96ddb1a92 100644
+--- a/gcc/config.gcc
++++ b/gcc/config.gcc
+@@ -522,7 +522,7 @@ case ${target} in
+ esac
+
+ # Common C libraries.
+-tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3"
++tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3 LIBC_MUSL=4"
+
+ # Common parts for widely ported systems.
+ case ${target} in
+@@ -625,6 +625,9 @@ case ${target} in
+ *-*-*uclibc*)
+ tm_defines="$tm_defines DEFAULT_LIBC=LIBC_UCLIBC"
+ ;;
++ *-*-*musl*)
++ tm_defines="$tm_defines DEFAULT_LIBC=LIBC_MUSL"
++ ;;
+ *)
+ tm_defines="$tm_defines DEFAULT_LIBC=LIBC_GLIBC"
+ ;;
+diff --git a/gcc/config/linux.h b/gcc/config/linux.h
+index fb459e680..064c6067d 100644
+--- a/gcc/config/linux.h
++++ b/gcc/config/linux.h
+@@ -33,10 +33,12 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ #define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC)
+ #define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
+ #define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
++#define OPTION_MUSL (DEFAULT_LIBC == LIBC_MUSL)
+ #else
+ #define OPTION_GLIBC (linux_libc == LIBC_GLIBC)
+ #define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC)
+ #define OPTION_BIONIC (linux_libc == LIBC_BIONIC)
++#define OPTION_MUSL (linux_libc == LIBC_MUSL)
+ #endif
+
+ #define GNU_USER_TARGET_OS_CPP_BUILTINS() \
+@@ -51,21 +53,25 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ } while (0)
+
+ /* Determine which dynamic linker to use depending on whether GLIBC or
+- uClibc or Bionic is the default C library and whether
+- -muclibc or -mglibc or -mbionic has been passed to change the default. */
++ uClibc or Bionic or musl is the default C library and whether
++ -muclibc or -mglibc or -mbionic or -mmusl has been passed to change
++ the default. */
+
+-#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LD1, LD2, LD3) \
+- "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:" LD1 "}}"
++#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LIBC4, LD1, LD2, LD3, LD4) \
++ "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:%{" LIBC4 ":" LD4 ";:" LD1 "}}}"
+
+ #if DEFAULT_LIBC == LIBC_GLIBC
+-#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
+- CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", G, U, B)
++#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
++ CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", "mmusl", G, U, B, M)
+ #elif DEFAULT_LIBC == LIBC_UCLIBC
+-#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
+- CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", U, G, B)
++#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
++ CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", "mmusl", U, G, B, M)
+ #elif DEFAULT_LIBC == LIBC_BIONIC
+-#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
+- CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", B, G, U)
++#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
++ CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", "mmusl", B, G, U, M)
++#elif DEFAULT_LIBC == LIBC_MUSL
++#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
++ CHOOSE_DYNAMIC_LINKER1 ("mmusl", "mglibc", "muclibc", "mbionic", M, G, U, B)
+ #else
+ #error "Unsupported DEFAULT_LIBC"
+ #endif /* DEFAULT_LIBC */
+@@ -82,19 +88,24 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ #define BIONIC_DYNAMIC_LINKER32 "/system/bin/linker"
+ #define BIONIC_DYNAMIC_LINKER64 "/system/bin/linker64"
+ #define BIONIC_DYNAMIC_LINKERX32 "/system/bin/linkerx32"
++/* Should be redefined for each target that supports musl. */
++#define MUSL_DYNAMIC_LINKER "/dev/null"
++#define MUSL_DYNAMIC_LINKER32 "/dev/null"
++#define MUSL_DYNAMIC_LINKER64 "/dev/null"
++#define MUSL_DYNAMIC_LINKERX32 "/dev/null"
+
+ #define GNU_USER_DYNAMIC_LINKER \
+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, \
+- BIONIC_DYNAMIC_LINKER)
++ BIONIC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER)
+ #define GNU_USER_DYNAMIC_LINKER32 \
+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, \
+- BIONIC_DYNAMIC_LINKER32)
++ BIONIC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32)
+ #define GNU_USER_DYNAMIC_LINKER64 \
+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, \
+- BIONIC_DYNAMIC_LINKER64)
++ BIONIC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64)
+ #define GNU_USER_DYNAMIC_LINKERX32 \
+ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERX32, UCLIBC_DYNAMIC_LINKERX32, \
+- BIONIC_DYNAMIC_LINKERX32)
++ BIONIC_DYNAMIC_LINKERX32, MUSL_DYNAMIC_LINKERX32)
+
+ /* Determine whether the entire c99 runtime
+ is present in the runtime library. */
+@@ -108,3 +119,74 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ /* Whether we have Bionic libc runtime */
+ #undef TARGET_HAS_BIONIC
+ #define TARGET_HAS_BIONIC (OPTION_BIONIC)
++
++/* musl avoids problematic includes by rearranging the include directories.
++ * Unfortunately, this is mostly duplicated from cppdefault.c */
++#if DEFAULT_LIBC == LIBC_MUSL
++#define INCLUDE_DEFAULTS_MUSL_GPP \
++ { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, \
++ GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 }, \
++ { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1, \
++ GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 1 }, \
++ { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, \
++ GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 },
++
++#ifdef LOCAL_INCLUDE_DIR
++#define INCLUDE_DEFAULTS_MUSL_LOCAL \
++ { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 2 }, \
++ { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 0 },
++#else
++#define INCLUDE_DEFAULTS_MUSL_LOCAL
++#endif
++
++#ifdef PREFIX_INCLUDE_DIR
++#define INCLUDE_DEFAULTS_MUSL_PREFIX \
++ { PREFIX_INCLUDE_DIR, 0, 0, 1, 0, 0},
++#else
++#define INCLUDE_DEFAULTS_MUSL_PREFIX
++#endif
++
++#ifdef CROSS_INCLUDE_DIR
++#define INCLUDE_DEFAULTS_MUSL_CROSS \
++ { CROSS_INCLUDE_DIR, "GCC", 0, 0, 0, 0},
++#else
++#define INCLUDE_DEFAULTS_MUSL_CROSS
++#endif
++
++#ifdef TOOL_INCLUDE_DIR
++#define INCLUDE_DEFAULTS_MUSL_TOOL \
++ { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1, 0, 0},
++#else
++#define INCLUDE_DEFAULTS_MUSL_TOOL
++#endif
++
++#ifdef NATIVE_SYSTEM_HEADER_DIR
++#define INCLUDE_DEFAULTS_MUSL_NATIVE \
++ { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 2 }, \
++ { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 0 },
++#else
++#define INCLUDE_DEFAULTS_MUSL_NATIVE
++#endif
++
++#if defined (CROSS_DIRECTORY_STRUCTURE) && !defined (TARGET_SYSTEM_ROOT)
++# undef INCLUDE_DEFAULTS_MUSL_LOCAL
++# define INCLUDE_DEFAULTS_MUSL_LOCAL
++# undef INCLUDE_DEFAULTS_MUSL_NATIVE
++# define INCLUDE_DEFAULTS_MUSL_NATIVE
++#else
++# undef INCLUDE_DEFAULTS_MUSL_CROSS
++# define INCLUDE_DEFAULTS_MUSL_CROSS
++#endif
++
++#undef INCLUDE_DEFAULTS
++#define INCLUDE_DEFAULTS \
++ { \
++ INCLUDE_DEFAULTS_MUSL_GPP \
++ INCLUDE_DEFAULTS_MUSL_PREFIX \
++ INCLUDE_DEFAULTS_MUSL_CROSS \
++ INCLUDE_DEFAULTS_MUSL_TOOL \
++ INCLUDE_DEFAULTS_MUSL_NATIVE \
++ { GCC_INCLUDE_DIR, "GCC", 0, 1, 0, 0 }, \
++ { 0, 0, 0, 0, 0, 0 } \
++ }
++#endif
+diff --git a/gcc/config/linux.opt b/gcc/config/linux.opt
+index ba6b9f83e..f5e94a9b1 100644
+--- a/gcc/config/linux.opt
++++ b/gcc/config/linux.opt
+@@ -28,5 +28,9 @@ Target Report RejectNegative Var(linux_libc,LIBC_GLIBC) Negative(muclibc)
+ Use GNU C library
+
+ muclibc
+-Target Report RejectNegative Var(linux_libc,LIBC_UCLIBC) Negative(mbionic)
++Target Report RejectNegative Var(linux_libc,LIBC_UCLIBC) Negative(mmusl)
+ Use uClibc C library
++
++mmusl
++Target Report RejectNegative Var(linux_libc,LIBC_MUSL) Negative(mbionic)
++Use musl C library
+diff --git a/gcc/configure b/gcc/configure
+index 0d8c5e71d..695e7c415 100755
+--- a/gcc/configure
++++ b/gcc/configure
+@@ -26791,6 +26791,9 @@ if test "${gcc_cv_libc_provides_ssp+set}" = set; then :
+ else
+ gcc_cv_libc_provides_ssp=no
+ case "$target" in
++ *-*-musl*)
++ # All versions of musl provide stack protector
++ gcc_cv_libc_provides_ssp=yes;;
+ *-*-linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu)
+ # glibc 2.4 and later provides __stack_chk_fail and
+ # either __stack_chk_guard, or TLS access to stack guard canary.
+@@ -26824,6 +26827,7 @@ else
+ # <http://gcc.gnu.org/ml/gcc/2008-10/msg00130.html>) and for now
+ # simply assert that glibc does provide this, which is true for all
+ # realistically usable GNU/Hurd configurations.
++ # All supported versions of musl provide it as well
+ gcc_cv_libc_provides_ssp=yes;;
+ *-*-darwin* | *-*-freebsd*)
+ ac_fn_c_check_func "$LINENO" "__stack_chk_fail" "ac_cv_func___stack_chk_fail"
+@@ -26906,6 +26910,9 @@ case "$target" in
+ gcc_cv_target_dl_iterate_phdr=no
+ fi
+ ;;
++ *-linux-musl*)
++ gcc_cv_target_dl_iterate_phdr=yes
++ ;;
+ esac
+
+ if test x$gcc_cv_target_dl_iterate_phdr = xyes; then
+diff --git a/gcc/configure.ac b/gcc/configure.ac
+index a78a1d76d..b6425efb4 100644
+--- a/gcc/configure.ac
++++ b/gcc/configure.ac
+@@ -4669,6 +4669,9 @@ AC_CACHE_CHECK(__stack_chk_fail in target C library,
+ gcc_cv_libc_provides_ssp,
+ [gcc_cv_libc_provides_ssp=no
+ case "$target" in
++ *-*-musl*)
++ # All versions of musl provide stack protector
++ gcc_cv_libc_provides_ssp=yes;;
+ *-*-linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu)
+ [# glibc 2.4 and later provides __stack_chk_fail and
+ # either __stack_chk_guard, or TLS access to stack guard canary.
+@@ -4702,6 +4705,7 @@ AC_CACHE_CHECK(__stack_chk_fail in target C library,
+ # <http://gcc.gnu.org/ml/gcc/2008-10/msg00130.html>) and for now
+ # simply assert that glibc does provide this, which is true for all
+ # realistically usable GNU/Hurd configurations.
++ # All supported versions of musl provide it as well
+ gcc_cv_libc_provides_ssp=yes;;
+ *-*-darwin* | *-*-freebsd*)
+ AC_CHECK_FUNC(__stack_chk_fail,[gcc_cv_libc_provides_ssp=yes],
+@@ -4767,6 +4771,9 @@ case "$target" in
+ gcc_cv_target_dl_iterate_phdr=no
+ fi
+ ;;
++ *-linux-musl*)
++ gcc_cv_target_dl_iterate_phdr=yes
++ ;;
+ esac
+ GCC_TARGET_TEMPLATE([TARGET_DL_ITERATE_PHDR])
+ if test x$gcc_cv_target_dl_iterate_phdr = xyes; then
+diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
+index 625fef25a..159615fe4 100644
+--- a/gcc/doc/invoke.texi
++++ b/gcc/doc/invoke.texi
+@@ -595,7 +595,7 @@ Objective-C and Objective-C++ Dialects}.
+ -mcpu=@var{cpu}}
+
+ @emph{GNU/Linux Options}
+-@gccoptlist{-mglibc -muclibc -mbionic -mandroid @gol
++@gccoptlist{-mglibc -muclibc -mmusl -mbionic -mandroid @gol
+ -tno-android-cc -tno-android-ld}
+
+ @emph{H8/300 Options}
+@@ -12879,13 +12879,19 @@ These @samp{-m} options are defined for GNU/Linux targets:
+ @item -mglibc
+ @opindex mglibc
+ Use the GNU C library. This is the default except
+-on @samp{*-*-linux-*uclibc*} and @samp{*-*-linux-*android*} targets.
++on @samp{*-*-linux-*uclibc*}, @samp{*-*-linux-*musl*} and
++@samp{*-*-linux-*android*} targets.
+
+ @item -muclibc
+ @opindex muclibc
+ Use uClibc C library. This is the default on
+ @samp{*-*-linux-*uclibc*} targets.
+
++@item -mmusl
++@opindex mmusl
++Use the musl C library. This is the default on
++@samp{*-*-linux-*musl*} targets.
++
+ @item -mbionic
+ @opindex mbionic
+ Use Bionic C library. This is the default on
+--
+2.30.2
+
diff --git a/etc/patches/gcc-4.7.4/musl-support/0004-x86-musl-support.patch b/etc/patches/gcc-4.7.4/musl-support/0004-x86-musl-support.patch
new file mode 100644
index 0000000..012abea
--- /dev/null
+++ b/etc/patches/gcc-4.7.4/musl-support/0004-x86-musl-support.patch
@@ -0,0 +1,50 @@
+From dd5e082250ca7b45ed22f713e10f0ba78b10b798 Mon Sep 17 00:00:00 2001
+From: Oliver Reiche <oliver.reiche@huawei.com>
+Date: Thu, 29 Jun 2023 16:53:50 +0200
+Subject: [PATCH 4/7] x86 musl support
+
+Backport from GCC 6.1.0
+ Git commit: cf57e99350d0b44876979c71986d8ca29c361f83
+ Subversion revision: r223218
+
+Original description:
+ * config/i386/linux.h (MUSL_DYNAMIC_LINKER): Define.
+ * config/i386/linux64.h (MUSL_DYNAMIC_LINKER32): Define.
+ (MUSL_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKERX32): Define.
+
+Co-authored-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
+Co-authored-by: Gregor Richards <gregor.richards@uwaterloo.ca>
+---
+ gcc/config/i386/linux.h | 3 +++
+ gcc/config/i386/linux64.h | 7 +++++++
+ 2 files changed, 10 insertions(+)
+
+diff --git a/gcc/config/i386/linux.h b/gcc/config/i386/linux.h
+index 73681fe82..f907adfb1 100644
+--- a/gcc/config/i386/linux.h
++++ b/gcc/config/i386/linux.h
+@@ -22,3 +22,6 @@ along with GCC; see the file COPYING3. If not see
+
+ #define GNU_USER_LINK_EMULATION "elf_i386"
+ #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
++
++#undef MUSL_DYNAMIC_LINKER
++#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-i386.so.1"
+diff --git a/gcc/config/i386/linux64.h b/gcc/config/i386/linux64.h
+index 5b0a212ce..cf361b264 100644
+--- a/gcc/config/i386/linux64.h
++++ b/gcc/config/i386/linux64.h
+@@ -31,3 +31,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ #define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2"
+ #define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux-x86-64.so.2"
+ #define GLIBC_DYNAMIC_LINKERX32 "/libx32/ld-linux-x32.so.2"
++
++#undef MUSL_DYNAMIC_LINKER32
++#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-i386.so.1"
++#undef MUSL_DYNAMIC_LINKER64
++#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-x86_64.so.1"
++#undef MUSL_DYNAMIC_LINKERX32
++#define MUSL_DYNAMIC_LINKERX32 "/lib/ld-musl-x32.so.1"
+--
+2.30.2
+
diff --git a/etc/patches/gcc-4.7.4/musl-support/0005-libstdc-workaround-for-musl.patch b/etc/patches/gcc-4.7.4/musl-support/0005-libstdc-workaround-for-musl.patch
new file mode 100644
index 0000000..0b862e0
--- /dev/null
+++ b/etc/patches/gcc-4.7.4/musl-support/0005-libstdc-workaround-for-musl.patch
@@ -0,0 +1,50 @@
+From 6f30aa9b58c145331da46adad18dc38926252547 Mon Sep 17 00:00:00 2001
+From: Oliver Reiche <oliver.reiche@huawei.com>
+Date: Thu, 29 Jun 2023 17:02:18 +0200
+Subject: [PATCH 5/7] libstdc++ workaround for musl
+
+Backport from GCC 6.1.0
+ Git commit: 85da5c3024f731e719c4093314da8edcd1056527
+ Subversion revision: r222329
+
+Original description:
+ * config/os/generic/os_defines.h (_GLIBCXX_GTHREAD_USE_WEAK): Define.
+ * configure.host (os_include_dir): Set to "os/generic" for linux-musl*.
+
+Co-authored-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
+---
+ libstdc++-v3/config/os/generic/os_defines.h | 5 +++++
+ libstdc++-v3/configure.host | 3 +++
+ 2 files changed, 8 insertions(+)
+
+diff --git a/libstdc++-v3/config/os/generic/os_defines.h b/libstdc++-v3/config/os/generic/os_defines.h
+index 3199bf30b..b8d7c1636 100644
+--- a/libstdc++-v3/config/os/generic/os_defines.h
++++ b/libstdc++-v3/config/os/generic/os_defines.h
+@@ -33,4 +33,9 @@
+ // System-specific #define, typedefs, corrections, etc, go here. This
+ // file will come before all others.
+
++// Disable the weak reference logic in gthr.h for os/generic because it
++// is broken on every platform unless there is implementation specific
++// workaround in gthr-posix.h and at link-time for static linking.
++#define _GLIBCXX_GTHREAD_USE_WEAK 0
++
+ #endif
+diff --git a/libstdc++-v3/configure.host b/libstdc++-v3/configure.host
+index b0e2cd9ea..df7977151 100644
+--- a/libstdc++-v3/configure.host
++++ b/libstdc++-v3/configure.host
+@@ -242,6 +242,9 @@ case "${host_os}" in
+ freebsd*)
+ os_include_dir="os/bsd/freebsd"
+ ;;
++ linux-musl*)
++ os_include_dir="os/generic"
++ ;;
+ gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu)
+ if [ "$uclibc" = "yes" ]; then
+ os_include_dir="os/uclibc"
+--
+2.30.2
+
diff --git a/etc/patches/gcc-4.7.4/musl-support/0006-config.guess-add-musl-support.patch b/etc/patches/gcc-4.7.4/musl-support/0006-config.guess-add-musl-support.patch
new file mode 100644
index 0000000..675ec49
--- /dev/null
+++ b/etc/patches/gcc-4.7.4/musl-support/0006-config.guess-add-musl-support.patch
@@ -0,0 +1,196 @@
+From 3c7b2147778b44abe947fb645074fed0545905ac Mon Sep 17 00:00:00 2001
+From: Oliver Reiche <oliver.reiche@huawei.com>
+Date: Thu, 29 Jun 2023 16:43:25 +0200
+Subject: [PATCH 6/7] config.guess: Add musl support
+
+Backport from GCC 9.1.0
+ Git commit: 29305f6018483963fa79b072cf8e95128f3e2cd8
+ Subversion revision: r261675
+
+Co-authored-by: Ben Elliston <bje@gnu.org>
+---
+ config.guess | 92 ++++++++++++++++++++++++++++++++--------------------
+ 1 file changed, 56 insertions(+), 36 deletions(-)
+
+diff --git a/config.guess b/config.guess
+index b02565c7b..081f4c8b7 100755
+--- a/config.guess
++++ b/config.guess
+@@ -142,6 +142,34 @@ UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
+
+ # Note: order is significant - the case branches are not exclusive.
+
++case "$UNAME_SYSTEM" in
++Linux|GNU|GNU/*)
++ # If the system lacks a compiler, then just pick glibc.
++ # We could probably try harder.
++ LIBC=gnu
++
++ eval $set_cc_for_build
++ cat <<-EOF > "$dummy.c"
++ #include <features.h>
++ #if defined(__UCLIBC__)
++ LIBC=uclibc
++ #elif defined(__dietlibc__)
++ LIBC=dietlibc
++ #else
++ LIBC=gnu
++ #endif
++ EOF
++ eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`"
++
++ # If ldd exists, use it to detect musl libc.
++ if command -v ldd >/dev/null && \
++ ldd --version 2>&1 | grep -q ^musl
++ then
++ LIBC=musl
++ fi
++ ;;
++esac
++
+ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+ *:NetBSD:*:*)
+ # NetBSD (nbsd) targets should (where applicable) match one or
+@@ -872,56 +900,48 @@ EOF
+ EV68*) UNAME_MACHINE=alphaev68 ;;
+ esac
+ objdump --private-headers /bin/sh | grep -q ld.so.1
+- if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
+- echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
++ if test "$?" = 0 ; then LIBC="gnulibc1" ; fi
++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ arm*:Linux:*:*)
+ eval $set_cc_for_build
+ if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
+ | grep -q __ARM_EABI__
+ then
+- echo ${UNAME_MACHINE}-unknown-linux-gnu
++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ else
+ if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
+ | grep -q __ARM_PCS_VFP
+ then
+- echo ${UNAME_MACHINE}-unknown-linux-gnueabi
++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi
+ else
+- echo ${UNAME_MACHINE}-unknown-linux-gnueabihf
++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf
+ fi
+ fi
+ exit ;;
+ avr32*:Linux:*:*)
+- echo ${UNAME_MACHINE}-unknown-linux-gnu
++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ cris:Linux:*:*)
+- echo cris-axis-linux-gnu
++ echo cris-axis-linux-${LIBC}
+ exit ;;
+ crisv32:Linux:*:*)
+- echo crisv32-axis-linux-gnu
++ echo crisv32-axis-linux-${LIBC}
+ exit ;;
+ frv:Linux:*:*)
+- echo frv-unknown-linux-gnu
++ echo frv-unknown-linux-${LIBC}
+ exit ;;
+ i*86:Linux:*:*)
+- LIBC=gnu
+- eval $set_cc_for_build
+- sed 's/^ //' << EOF >$dummy.c
+- #ifdef __dietlibc__
+- LIBC=dietlibc
+- #endif
+-EOF
+- eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'`
+ echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
+ exit ;;
+ ia64:Linux:*:*)
+- echo ${UNAME_MACHINE}-unknown-linux-gnu
++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ m32r*:Linux:*:*)
+- echo ${UNAME_MACHINE}-unknown-linux-gnu
++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ m68*:Linux:*:*)
+- echo ${UNAME_MACHINE}-unknown-linux-gnu
++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ mips:Linux:*:* | mips64:Linux:*:*)
+ eval $set_cc_for_build
+@@ -940,54 +960,54 @@ EOF
+ #endif
+ EOF
+ eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
+- test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
++ test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; }
+ ;;
+ or32:Linux:*:*)
+- echo or32-unknown-linux-gnu
++ echo or32-unknown-linux-${LIBC}
+ exit ;;
+ padre:Linux:*:*)
+- echo sparc-unknown-linux-gnu
++ echo sparc-unknown-linux-${LIBC}
+ exit ;;
+ parisc64:Linux:*:* | hppa64:Linux:*:*)
+- echo hppa64-unknown-linux-gnu
++ echo hppa64-unknown-linux-${LIBC}
+ exit ;;
+ parisc:Linux:*:* | hppa:Linux:*:*)
+ # Look for CPU level
+ case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
+- PA7*) echo hppa1.1-unknown-linux-gnu ;;
+- PA8*) echo hppa2.0-unknown-linux-gnu ;;
+- *) echo hppa-unknown-linux-gnu ;;
++ PA7*) echo hppa1.1-unknown-linux-${LIBC} ;;
++ PA8*) echo hppa2.0-unknown-linux-${LIBC} ;;
++ *) echo hppa-unknown-linux-${LIBC} ;;
+ esac
+ exit ;;
+ ppc64:Linux:*:*)
+- echo powerpc64-unknown-linux-gnu
++ echo powerpc64-unknown-linux-${LIBC}
+ exit ;;
+ ppc:Linux:*:*)
+- echo powerpc-unknown-linux-gnu
++ echo powerpc-unknown-linux-${LIBC}
+ exit ;;
+ s390:Linux:*:* | s390x:Linux:*:*)
+ echo ${UNAME_MACHINE}-ibm-linux
+ exit ;;
+ sh64*:Linux:*:*)
+- echo ${UNAME_MACHINE}-unknown-linux-gnu
++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ sh*:Linux:*:*)
+- echo ${UNAME_MACHINE}-unknown-linux-gnu
++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ sparc:Linux:*:* | sparc64:Linux:*:*)
+- echo ${UNAME_MACHINE}-unknown-linux-gnu
++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ tile*:Linux:*:*)
+- echo ${UNAME_MACHINE}-unknown-linux-gnu
++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ vax:Linux:*:*)
+- echo ${UNAME_MACHINE}-dec-linux-gnu
++ echo ${UNAME_MACHINE}-dec-linux-${LIBC}
+ exit ;;
+ x86_64:Linux:*:*)
+- echo x86_64-unknown-linux-gnu
++ echo x86_64-unknown-linux-${LIBC}
+ exit ;;
+ xtensa*:Linux:*:*)
+- echo ${UNAME_MACHINE}-unknown-linux-gnu
++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ i*86:DYNIX/ptx:4*:*)
+ # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
+--
+2.30.2
+
diff --git a/etc/patches/gcc-4.7.4/musl-support/0007-config.guess-detect-glibc-via-__GLIBC__.patch b/etc/patches/gcc-4.7.4/musl-support/0007-config.guess-detect-glibc-via-__GLIBC__.patch
new file mode 100644
index 0000000..ea62d6b
--- /dev/null
+++ b/etc/patches/gcc-4.7.4/musl-support/0007-config.guess-detect-glibc-via-__GLIBC__.patch
@@ -0,0 +1,70 @@
+From 32088af3619e49aecec44260d594fdcf590bfe00 Mon Sep 17 00:00:00 2001
+From: Oliver Reiche <oliver.reiche@huawei.com>
+Date: Wed, 19 Jul 2023 11:55:37 +0200
+Subject: [PATCH] config.guess: Detect glibc via __GLIBC__
+
+Backport from GCC 11.1.0
+ Git commit: 53a90650663e59948f86505660604b5769cf808c and
+ 74af13c174714dd3b9f1ded4b39955f003c16361
+
+Co-authored-by: Iain Sandoe <iain@sandoe.co.uk>
+Co-authored-by: Kito Cheng <kito.cheng@sifive.com>
+---
+ config.guess | 30 ++++++++++++++++++++----------
+ 1 file changed, 20 insertions(+), 10 deletions(-)
+
+diff --git a/config.guess b/config.guess
+index 081f4c8b7..3d378a144 100755
+--- a/config.guess
++++ b/config.guess
+@@ -144,9 +144,7 @@ UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
+
+ case "$UNAME_SYSTEM" in
+ Linux|GNU|GNU/*)
+- # If the system lacks a compiler, then just pick glibc.
+- # We could probably try harder.
+- LIBC=gnu
++ LIBC=unknown
+
+ eval $set_cc_for_build
+ cat <<-EOF > "$dummy.c"
+@@ -155,17 +153,29 @@ Linux|GNU|GNU/*)
+ LIBC=uclibc
+ #elif defined(__dietlibc__)
+ LIBC=dietlibc
+- #else
++ #elif defined(__GLIBC__)
+ LIBC=gnu
++ #else
++ #include <stdarg.h>
++ /* First heuristic to detect musl libc. */
++ #ifdef __DEFINED_va_list
++ LIBC=musl
++ #endif
+ #endif
+ EOF
+- eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`"
++ eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`"
+
+- # If ldd exists, use it to detect musl libc.
+- if command -v ldd >/dev/null && \
+- ldd --version 2>&1 | grep -q ^musl
+- then
+- LIBC=musl
++ # Second heuristic to detect musl libc.
++ if [ "$LIBC" = unknown ] &&
++ command -v ldd >/dev/null &&
++ ldd --version 2>&1 | grep -q ^musl; then
++ LIBC=musl
++ fi
++
++ # If the system lacks a compiler, then just pick glibc.
++ # We could probably try harder.
++ if [ "$LIBC" = unknown ]; then
++ LIBC=gnu
+ fi
+ ;;
+ esac
+--
+2.30.2
+
diff --git a/etc/patches/gcc-4.7.4/musl-support/series b/etc/patches/gcc-4.7.4/musl-support/series
new file mode 100644
index 0000000..00daf30
--- /dev/null
+++ b/etc/patches/gcc-4.7.4/musl-support/series
@@ -0,0 +1,7 @@
+0001-config.sub-add-musl-support-for-gmp-mpc-mpfr.patch
+0002-config.sub-add-musl-support-for-gcc.patch
+0003-musl-libc-config.patch
+0004-x86-musl-support.patch
+0005-libstdc-workaround-for-musl.patch
+0006-config.guess-add-musl-support.patch
+0007-config.guess-detect-glibc-via-__GLIBC__.patch
diff --git a/etc/patches/gcc-4.7.4/reproducibility/0001-strip-build-directory-from-fixinclues.patch b/etc/patches/gcc-4.7.4/reproducibility/0001-strip-build-directory-from-fixinclues.patch
new file mode 100644
index 0000000..885c7d0
--- /dev/null
+++ b/etc/patches/gcc-4.7.4/reproducibility/0001-strip-build-directory-from-fixinclues.patch
@@ -0,0 +1,29 @@
+From 95563f6ef2366acb57557c11b8301d468a87e04f Mon Sep 17 00:00:00 2001
+From: Oliver Reiche <oliver.reiche@huawei.com>
+Date: Fri, 18 Aug 2023 14:36:57 +0200
+Subject: [PATCH 1/2] Strip build directory from fixinclues
+
+... to achieve a reproducible binary, which contains the
+configure string. For this to work, the user needs to set
+"BUILD_ROOT_DIR" before building.
+---
+ fixincludes/configure | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/fixincludes/configure b/fixincludes/configure
+index 4a28cd1f3..45fdab2be 100755
+--- a/fixincludes/configure
++++ b/fixincludes/configure
+@@ -6236,6 +6236,9 @@ cat >"$tmp/defines.awk" <<\_ACAWK ||
+ BEGIN {
+ _ACEOF
+
++# Remove host machine's build path from confdefs.h
++sed -i 's|'${BUILD_ROOT_DIR:-/nonexistent}'|/build|g' confdefs.h
++
+ # Transform confdefs.h into an awk script `defines.awk', embedded as
+ # here-document in config.status, that substitutes the proper values into
+ # config.h.in to produce config.h.
+--
+2.30.2
+
diff --git a/etc/patches/gcc-4.7.4/reproducibility/0002-compute-reproducible-checksums.patch b/etc/patches/gcc-4.7.4/reproducibility/0002-compute-reproducible-checksums.patch
new file mode 100644
index 0000000..7db6c92
--- /dev/null
+++ b/etc/patches/gcc-4.7.4/reproducibility/0002-compute-reproducible-checksums.patch
@@ -0,0 +1,58 @@
+From 617a9fc8ad3711fedea305881286bdc00b80a6e1 Mon Sep 17 00:00:00 2001
+From: Oliver Reiche <oliver.reiche@huawei.com>
+Date: Mon, 21 Aug 2023 18:03:56 +0200
+Subject: [PATCH 2/2] Compute reproducible checksums
+
+... for variable toolchain paths:
+* remove linker path from gcc's checksum-options
+* strip debug info before computing checksums
+For removing the linker path, the user needs to set
+"BUILD_ROOT_DIR" before building.
+---
+ gcc/Makefile.in | 7 ++++++-
+ gcc/cp/Make-lang.in | 6 +++++-
+ 2 files changed, 11 insertions(+), 2 deletions(-)
+
+diff --git a/gcc/Makefile.in b/gcc/Makefile.in
+index f3cc49fdb..7fb30a13f 100644
+--- a/gcc/Makefile.in
++++ b/gcc/Makefile.in
+@@ -1804,12 +1804,17 @@ gcc-cross$(exeext): xgcc$(exeext)
+
+ checksum-options:
+ echo "$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS)" > checksum-options.tmp \
++ && sed -i 's|'$${BUILD_ROOT_DIR:-/nonexistent}'|/build|g' checksum-options.tmp \
+ && $(srcdir)/../move-if-change checksum-options.tmp checksum-options
+
+ # compute checksum over all object files and the options
+ cc1-checksum.c : build/genchecksum$(build_exeext) checksum-options \
+ $(C_OBJS) $(BACKEND) $(LIBDEPS)
+- build/genchecksum$(build_exeext) $(C_OBJS) $(BACKEND) $(LIBDEPS) \
++ rm -rf stripped_c_checksum_inputs; \
++ mkdir stripped_c_checksum_inputs; \
++ cp $(C_OBJS) $(BACKEND) $(LIBDEPS) stripped_c_checksum_inputs/; \
++ strip -g stripped_c_checksum_inputs/*; \
++ build/genchecksum$(build_exeext) $$(ls stripped_c_checksum_inputs/* | LC_ALL=C sort) \
+ checksum-options > cc1-checksum.c.tmp && \
+ $(srcdir)/../move-if-change cc1-checksum.c.tmp cc1-checksum.c
+
+diff --git a/gcc/cp/Make-lang.in b/gcc/cp/Make-lang.in
+index 0ce01ac49..0fc43d305 100644
+--- a/gcc/cp/Make-lang.in
++++ b/gcc/cp/Make-lang.in
+@@ -95,7 +95,11 @@ cp-warn = $(STRICT_WARN)
+ # compute checksum over all object files and the options
+ cc1plus-checksum.c : build/genchecksum$(build_exeext) checksum-options \
+ $(CXX_OBJS) $(BACKEND) $(LIBDEPS)
+- build/genchecksum$(build_exeext) $(CXX_OBJS) $(BACKEND) $(LIBDEPS) \
++ rm -rf stripped_cp_checksum_inputs; \
++ mkdir stripped_cp_checksum_inputs; \
++ cp $(CXX_OBJS) $(BACKEND) $(CODYLIB) $(LIBDEPS) stripped_cp_checksum_inputs; \
++ strip -g stripped_cp_checksum_inputs/*; \
++ build/genchecksum$(build_exeext) $$(ls stripped_cp_checksum_inputs/* | LC_ALL=C sort) \
+ checksum-options > cc1plus-checksum.c.tmp && \
+ $(srcdir)/../move-if-change cc1plus-checksum.c.tmp cc1plus-checksum.c
+
+--
+2.30.2
+
diff --git a/etc/patches/gcc-4.7.4/reproducibility/series b/etc/patches/gcc-4.7.4/reproducibility/series
new file mode 100644
index 0000000..1ec9fe3
--- /dev/null
+++ b/etc/patches/gcc-4.7.4/reproducibility/series
@@ -0,0 +1,2 @@
+0001-strip-build-directory-from-fixinclues.patch
+0002-compute-reproducible-checksums.patch
diff --git a/etc/patches/gcc-4.7.4/use-ucontext_t.patch b/etc/patches/gcc-4.7.4/use-ucontext_t.patch
new file mode 100644
index 0000000..51efb60
--- /dev/null
+++ b/etc/patches/gcc-4.7.4/use-ucontext_t.patch
@@ -0,0 +1,153 @@
+From 321844cd2cd0676936c309669df058069c1a1db1 Mon Sep 17 00:00:00 2001
+From: Oliver Reiche <oliver.reiche@huawei.com>
+Date: Thu, 29 Jun 2023 15:53:01 +0200
+Subject: [PATCH] Use ucontext_t not struct ucontext in linux-unwind.h files.
+
+Backport from GCC 8.1.0
+ Git commit: 883312dc79806f513275b72502231c751c14ff72
+ Subversion revision: r249731
+
+Original description:
+ Current glibc no longer gives the ucontext_t type the tag struct
+ ucontext, to conform with POSIX namespace rules. This requires
+ various linux-unwind.h files in libgcc, that were previously using
+ struct ucontext, to be fixed to use ucontext_t instead. This is
+ similar to the removal of the struct siginfo tag from siginfo_t some
+ years ago.
+
+ This patch changes those files to use ucontext_t instead. As the
+ standard name that should be unconditionally safe, so this is not
+ restricted to architectures supported by glibc, or conditioned on the
+ glibc version.
+
+ Tested compilation together with current glibc with glibc's
+ build-many-glibcs.py.
+
+Co-authored-by: Joseph Myers <joseph@codesourcery.com>
+---
+ libgcc/config/alpha/linux-unwind.h | 2 +-
+ libgcc/config/bfin/linux-unwind.h | 2 +-
+ libgcc/config/i386/linux-unwind.h | 4 ++--
+ libgcc/config/m68k/linux-unwind.h | 2 +-
+ libgcc/config/pa/linux-unwind.h | 2 +-
+ libgcc/config/sh/linux-unwind.h | 2 +-
+ libgcc/config/tilepro/linux-unwind.h | 2 +-
+ libgcc/config/xtensa/linux-unwind.h | 2 +-
+ 8 files changed, 9 insertions(+), 9 deletions(-)
+
+diff --git a/libgcc/config/alpha/linux-unwind.h b/libgcc/config/alpha/linux-unwind.h
+index 6c2f02891..c1fc84486 100644
+--- a/libgcc/config/alpha/linux-unwind.h
++++ b/libgcc/config/alpha/linux-unwind.h
+@@ -51,7 +51,7 @@ alpha_fallback_frame_state (struct _Unwind_Context *context,
+ {
+ struct rt_sigframe {
+ siginfo_t info;
+- struct ucontext uc;
++ ucontext_t uc;
+ } *rt_ = context->cfa;
+ sc = &rt_->uc.uc_mcontext;
+ }
+diff --git a/libgcc/config/bfin/linux-unwind.h b/libgcc/config/bfin/linux-unwind.h
+index 15bb2f12b..28d9f4207 100644
+--- a/libgcc/config/bfin/linux-unwind.h
++++ b/libgcc/config/bfin/linux-unwind.h
+@@ -52,7 +52,7 @@ bfin_fallback_frame_state (struct _Unwind_Context *context,
+ void *puc;
+ char retcode[8];
+ siginfo_t info;
+- struct ucontext uc;
++ ucontext_t uc;
+ } *rt_ = context->cfa;
+
+ /* The void * cast is necessary to avoid an aliasing warning.
+diff --git a/libgcc/config/i386/linux-unwind.h b/libgcc/config/i386/linux-unwind.h
+index cd9a9a1e2..4518c1ff9 100644
+--- a/libgcc/config/i386/linux-unwind.h
++++ b/libgcc/config/i386/linux-unwind.h
+@@ -53,7 +53,7 @@ x86_64_fallback_frame_state (struct _Unwind_Context *context,
+ if (*(unsigned char *)(pc+0) == 0x48
+ && *(unsigned long long *)(pc+1) == RT_SIGRETURN_SYSCALL)
+ {
+- struct ucontext *uc_ = context->cfa;
++ ucontext_t *uc_ = context->cfa;
+ /* The void * cast is necessary to avoid an aliasing warning.
+ The aliasing warning is correct, but should not be a problem
+ because it does not alias anything. */
+@@ -142,7 +142,7 @@ x86_fallback_frame_state (struct _Unwind_Context *context,
+ siginfo_t *pinfo;
+ void *puc;
+ siginfo_t info;
+- struct ucontext uc;
++ ucontext_t uc;
+ } *rt_ = context->cfa;
+ /* The void * cast is necessary to avoid an aliasing warning.
+ The aliasing warning is correct, but should not be a problem
+diff --git a/libgcc/config/m68k/linux-unwind.h b/libgcc/config/m68k/linux-unwind.h
+index 053c15558..d7bc1f2c0 100644
+--- a/libgcc/config/m68k/linux-unwind.h
++++ b/libgcc/config/m68k/linux-unwind.h
+@@ -33,7 +33,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ /* <sys/ucontext.h> is unfortunately broken right now. */
+ struct uw_ucontext {
+ unsigned long uc_flags;
+- struct ucontext *uc_link;
++ ucontext_t *uc_link;
+ stack_t uc_stack;
+ mcontext_t uc_mcontext;
+ unsigned long uc_filler[80];
+diff --git a/libgcc/config/pa/linux-unwind.h b/libgcc/config/pa/linux-unwind.h
+index 38b4eda7a..45ea66cf3 100644
+--- a/libgcc/config/pa/linux-unwind.h
++++ b/libgcc/config/pa/linux-unwind.h
+@@ -64,7 +64,7 @@ pa32_fallback_frame_state (struct _Unwind_Context *context,
+ struct sigcontext *sc;
+ struct rt_sigframe {
+ siginfo_t info;
+- struct ucontext uc;
++ ucontext_t uc;
+ } *frame;
+
+ /* rt_sigreturn trampoline:
+diff --git a/libgcc/config/sh/linux-unwind.h b/libgcc/config/sh/linux-unwind.h
+index 5a78e3172..eefad5175 100644
+--- a/libgcc/config/sh/linux-unwind.h
++++ b/libgcc/config/sh/linux-unwind.h
+@@ -181,7 +181,7 @@ sh_fallback_frame_state (struct _Unwind_Context *context,
+ {
+ struct rt_sigframe {
+ siginfo_t info;
+- struct ucontext uc;
++ ucontext_t uc;
+ } *rt_ = context->cfa;
+ /* The void * cast is necessary to avoid an aliasing warning.
+ The aliasing warning is correct, but should not be a problem
+diff --git a/libgcc/config/tilepro/linux-unwind.h b/libgcc/config/tilepro/linux-unwind.h
+index 27a6c4351..d2a15bb9f 100644
+--- a/libgcc/config/tilepro/linux-unwind.h
++++ b/libgcc/config/tilepro/linux-unwind.h
+@@ -62,7 +62,7 @@ tile_fallback_frame_state (struct _Unwind_Context *context,
+ struct rt_sigframe {
+ unsigned char save_area[C_ABI_SAVE_AREA_SIZE];
+ siginfo_t info;
+- struct ucontext uc;
++ ucontext_t uc;
+ } *rt_;
+
+ /* Return if this is not a signal handler. */
+diff --git a/libgcc/config/xtensa/linux-unwind.h b/libgcc/config/xtensa/linux-unwind.h
+index 245649728..b7b128cf0 100644
+--- a/libgcc/config/xtensa/linux-unwind.h
++++ b/libgcc/config/xtensa/linux-unwind.h
+@@ -63,7 +63,7 @@ xtensa_fallback_frame_state (struct _Unwind_Context *context,
+
+ struct rt_sigframe {
+ siginfo_t info;
+- struct ucontext uc;
++ ucontext_t uc;
+ } *rt_;
+
+ /* movi a2, __NR_rt_sigreturn; syscall */
+--
+2.30.2
+
diff --git a/etc/patches/gcc-4.7.4/various-fixes/0001-non-behavioral-changing-fix-in-gcc-cp-rtti.c.patch b/etc/patches/gcc-4.7.4/various-fixes/0001-non-behavioral-changing-fix-in-gcc-cp-rtti.c.patch
new file mode 100644
index 0000000..9d32ef4
--- /dev/null
+++ b/etc/patches/gcc-4.7.4/various-fixes/0001-non-behavioral-changing-fix-in-gcc-cp-rtti.c.patch
@@ -0,0 +1,46 @@
+From 8dfe03984e5c8060b5baabd19478db9f89bc43d0 Mon Sep 17 00:00:00 2001
+From: Oliver Reiche <oliver.reiche@huawei.com>
+Date: Thu, 29 Jun 2023 15:47:17 +0200
+Subject: [PATCH 1/4] Non-behavioral changing fix in gcc/cp/rtti.c
+
+... to fix an infinite loop that occurs in the "cc1plus"
+binary, if it was compiled with TinyCC version 0.9.27. Upon
+closer inspection, the loop was infinitely executing the
+lines 814, 820, and 823 of the following snippet:
+
+---
+812: function(...) {
+813: while (true) {
+814: if (...)
+...
+820: else if (...)
+...
+822: else
+823: return ...;
+824: }
+---
+
+Presumably, TinyCC somehow generates instructions that are
+not able to exit the function from the return-statement
+inside the while loop. The solution is a non-behavioral
+changing fix: insert a break-statement in line 823 and
+thereby move the return-statement outside the while loop.
+---
+ gcc/cp/rtti.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c
+index 30383ed18..faf639115 100644
+--- a/gcc/cp/rtti.c
++++ b/gcc/cp/rtti.c
+@@ -820,6 +820,7 @@ target_incomplete_p (tree type)
+ else if (TREE_CODE (type) == POINTER_TYPE)
+ type = TREE_TYPE (type);
+ else
++ break;
+ return !COMPLETE_OR_VOID_TYPE_P (type);
+ }
+
+--
+2.30.2
+
diff --git a/etc/patches/gcc-4.7.4/various-fixes/0002-comment-out-M4-m4-not-needed-in-gmp-configure.patch b/etc/patches/gcc-4.7.4/various-fixes/0002-comment-out-M4-m4-not-needed-in-gmp-configure.patch
new file mode 100644
index 0000000..eccb90a
--- /dev/null
+++ b/etc/patches/gcc-4.7.4/various-fixes/0002-comment-out-M4-m4-not-needed-in-gmp-configure.patch
@@ -0,0 +1,35 @@
+From 220a31382c25e511b30ef675711d9bcd057c1083 Mon Sep 17 00:00:00 2001
+From: Oliver Reiche <oliver.reiche@huawei.com>
+Date: Thu, 29 Jun 2023 15:47:27 +0200
+Subject: [PATCH 2/4] Comment out M4=m4-not-needed in gmp/configure
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Backport from GMP 5.0.2
+ Mercurial changeset IDs: d32fa7b198d3 and 2b1c397a9463
+
+Co-authored-by: Niels Möller <nisse@lysator.liu.se>
+Co-authored-by: Torbjorn Granlund <tege@gmplib.org>
+---
+ gmp/configure | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/gmp/configure b/gmp/configure
+index c72990c07..c5f247948 100755
+--- a/gmp/configure
++++ b/gmp/configure
+@@ -28982,8 +28982,8 @@ echo "${ECHO_T}$gmp_cv_m4_m4wrap_spurious" >&6
+ echo "define(<M4WRAP_SPURIOUS>,<$gmp_cv_m4_m4wrap_spurious>)" >> $gmp_tmpconfigm4
+
+
+-else
+- M4=m4-not-needed
++#else
++# M4=m4-not-needed
+ fi
+
+ # Only do the GMP_ASM checks if there's a .S or .asm wanting them.
+--
+2.30.2
+
diff --git a/etc/patches/gcc-4.7.4/various-fixes/0003-cfns-fix-mismatch-in-gnu_inline-attributes.patch b/etc/patches/gcc-4.7.4/various-fixes/0003-cfns-fix-mismatch-in-gnu_inline-attributes.patch
new file mode 100644
index 0000000..217ff88
--- /dev/null
+++ b/etc/patches/gcc-4.7.4/various-fixes/0003-cfns-fix-mismatch-in-gnu_inline-attributes.patch
@@ -0,0 +1,62 @@
+From 45decf6322dedb510df1886da5b8419aecef52c5 Mon Sep 17 00:00:00 2001
+From: Mike Frysinger <vapier at gentoo dot org>
+Date: Thu, 29 Jun 2023 16:02:23 +0200
+Subject: [PATCH 3/4] cfns: fix mismatch in gnu_inline attributes
+
+Since the 3.0.3 release of gperf (made in May 2007), the generated func
+has had the gnu_inline attribute applied to it. The gcc source however
+has not been updated to include that which has lead to a mismatch.
+
+In practice, this hasn't been an issue for two reasons:
+(1) Before gcc-5, the default standard was (gnu) C89, and gcc does not
+warn or throw an error in this mode.
+(2) Starting with gcc-4.8, the compiler driver used to build gcc was
+changed to C++, and g++ does not warn or throw an error in this mode.
+
+This error does show up though when using gcc-5 to build gcc-4.7 or
+older as then the default is (gnu) C11 and the C compiler driver is
+used. That failure looks like:
+In file included from .../gcc-4.7.4/gcc/cp/except.c:990:0:
+cfns.gperf: At top level:
+cfns.gperf:101:1: error: 'gnu_inline' attribute present on 'libc_name_p'
+cfns.gperf:26:14: error: but not here
+
+Whether the compiler should always emit this error regardless of the
+active standard or compiler driver is debatable (I think it should be
+consistent -- either always do it or never do it).
+---
+ gcc/cp/cfns.gperf | 3 +++
+ gcc/cp/cfns.h | 3 +++
+ 2 files changed, 6 insertions(+)
+
+diff --git a/gcc/cp/cfns.gperf b/gcc/cp/cfns.gperf
+index ef1ed083d..ba0c487a6 100644
+--- a/gcc/cp/cfns.gperf
++++ b/gcc/cp/cfns.gperf
+@@ -22,6 +22,9 @@ __inline
+ static unsigned int hash (const char *, unsigned int);
+ #ifdef __GNUC__
+ __inline
++#ifdef __GNUC_STDC_INLINE__
++__attribute__ ((__gnu_inline__))
++#endif
+ #endif
+ const char * libc_name_p (const char *, unsigned int);
+ %}
+diff --git a/gcc/cp/cfns.h b/gcc/cp/cfns.h
+index 62cdfab93..2fb9b4632 100644
+--- a/gcc/cp/cfns.h
++++ b/gcc/cp/cfns.h
+@@ -53,6 +53,9 @@ __inline
+ static unsigned int hash (const char *, unsigned int);
+ #ifdef __GNUC__
+ __inline
++#ifdef __GNUC_STDC_INLINE__
++__attribute__ ((__gnu_inline__))
++#endif
+ #endif
+ const char * libc_name_p (const char *, unsigned int);
+ /* maximum key range = 391, duplicates = 0 */
+--
+2.30.2
+
diff --git a/etc/patches/gcc-4.7.4/various-fixes/0004-fix-gmp-configure-to-comply-with-newer-c-standards.patch b/etc/patches/gcc-4.7.4/various-fixes/0004-fix-gmp-configure-to-comply-with-newer-c-standards.patch
new file mode 100644
index 0000000..1360b06
--- /dev/null
+++ b/etc/patches/gcc-4.7.4/various-fixes/0004-fix-gmp-configure-to-comply-with-newer-c-standards.patch
@@ -0,0 +1,234 @@
+From 7a642773c924589eeee2ca1be4615b35c12c6f5e Mon Sep 17 00:00:00 2001
+From: Oliver Reiche <oliver.reiche@huawei.com>
+Date: Tue, 17 Oct 2023 14:59:32 +0200
+Subject: [PATCH 4/4] Fix GMP configure to comply with newer C standards
+
+---
+ configure | 68 +++++++++++++++++++++++--------------------------------
+ 1 file changed, 28 insertions(+), 40 deletions(-)
+
+diff --git a/gmp/configure b/gmp/configure
+index c72990c..c13bea9 100755
+--- a/gmp/configure
++++ b/gmp/configure
+@@ -7752,7 +7752,7 @@ cat >conftest.c <<EOF
+ int
+ main ()
+ {
+- exit(0);
++ return 0;
+ }
+ EOF
+ gmp_compile="$CC_FOR_BUILD conftest.c"
+@@ -7786,7 +7786,7 @@ cat >conftest.c <<EOF
+ int
+ main ()
+ {
+- exit(0);
++ return 0;
+ }
+ EOF
+ gmp_compile="$HOST_CC conftest.c"
+@@ -7821,7 +7821,7 @@ cat >conftest.c <<EOF
+ int
+ main ()
+ {
+- exit(0);
++ return 0;
+ }
+ EOF
+ gmp_compile="$i conftest.c"
+@@ -7904,7 +7904,7 @@ else
+ int
+ main ()
+ {
+- exit (0);
++ return 0;
+ }
+ EOF
+ for i in .exe ,ff8 ""; do
+@@ -7941,9 +7941,9 @@ if test "${gmp_cv_c_for_build_ansi+set}" = set; then
+ else
+ cat >conftest.c <<EOF
+ int
+-main (int argc, char *argv)
++main (int argc, char **argv)
+ {
+- exit(0);
++ return 0;
+ }
+ EOF
+ gmp_compile="$CC_FOR_BUILD conftest.c"
+@@ -7978,7 +7978,7 @@ else
+ int
+ main ()
+ {
+- exit(0);
++ return 0;
+ }
+ double d;
+ double
+@@ -9243,7 +9243,7 @@ main ()
+ if (XOR (islower (i), ISLOWER (i))
+ || toupper (i) != TOUPPER (i))
+ exit(2);
+- exit (0);
++ return 0;
+ }
+ _ACEOF
+ rm -f conftest$ac_exeext
+@@ -24628,7 +24628,7 @@ main ()
+ if (XOR (islower (i), ISLOWER (i))
+ || toupper (i) != TOUPPER (i))
+ exit(2);
+- exit (0);
++ return 0;
+ }
+ _ACEOF
+ rm -f conftest$ac_exeext
+@@ -27932,11 +27932,11 @@ check (va_alist)
+ ret = vsnprintf (buf, 4, fmt, ap);
+
+ if (strcmp (buf, "hel") != 0)
+- exit (1);
++ return 1;
+
+ /* allowed return values */
+ if (ret != -1 && ret != 3 && ret != 11)
+- exit (2);
++ return 2;
+
+ return 0;
+ }
+@@ -27945,7 +27945,7 @@ int
+ main ()
+ {
+ $i
+- exit (0);
++ return 0;
+ }
+
+ _ACEOF
+@@ -30741,25 +30741,22 @@ main ()
+
+ FILE *f = fopen ("conftest.val", "w");
+ if (! f)
+- exit (1);
++ return 1;
+ if (((long) (sizeof (unsigned short))) < 0)
+ {
+ long i = longval ();
+ if (i != ((long) (sizeof (unsigned short))))
+- exit (1);
++ return 1;
+ fprintf (f, "%ld\n", i);
+ }
+ else
+ {
+ unsigned long i = ulongval ();
+ if (i != ((long) (sizeof (unsigned short))))
+- exit (1);
++ return 1;
+ fprintf (f, "%lu\n", i);
+ }
+- exit (ferror (f) || fclose (f) != 0);
+-
+- ;
+- return 0;
++ return (ferror (f) || fclose (f) != 0);
+ }
+ _ACEOF
+ rm -f conftest$ac_exeext
+@@ -31155,25 +31152,22 @@ main ()
+
+ FILE *f = fopen ("conftest.val", "w");
+ if (! f)
+- exit (1);
++ return 1;
+ if (((long) (sizeof (unsigned))) < 0)
+ {
+ long i = longval ();
+ if (i != ((long) (sizeof (unsigned))))
+- exit (1);
++ return 1;
+ fprintf (f, "%ld\n", i);
+ }
+ else
+ {
+ unsigned long i = ulongval ();
+ if (i != ((long) (sizeof (unsigned))))
+- exit (1);
++ return 1;
+ fprintf (f, "%lu\n", i);
+ }
+- exit (ferror (f) || fclose (f) != 0);
+-
+- ;
+- return 0;
++ return (ferror (f) || fclose (f) != 0);
+ }
+ _ACEOF
+ rm -f conftest$ac_exeext
+@@ -31569,25 +31563,22 @@ main ()
+
+ FILE *f = fopen ("conftest.val", "w");
+ if (! f)
+- exit (1);
++ return 1;
+ if (((long) (sizeof (unsigned long))) < 0)
+ {
+ long i = longval ();
+ if (i != ((long) (sizeof (unsigned long))))
+- exit (1);
++ return 1;
+ fprintf (f, "%ld\n", i);
+ }
+ else
+ {
+ unsigned long i = ulongval ();
+ if (i != ((long) (sizeof (unsigned long))))
+- exit (1);
++ return 1;
+ fprintf (f, "%lu\n", i);
+ }
+- exit (ferror (f) || fclose (f) != 0);
+-
+- ;
+- return 0;
++ return (ferror (f) || fclose (f) != 0);
+ }
+ _ACEOF
+ rm -f conftest$ac_exeext
+@@ -32032,25 +32023,22 @@ main ()
+
+ FILE *f = fopen ("conftest.val", "w");
+ if (! f)
+- exit (1);
++ return 1;
+ if (((long) (sizeof (mp_limb_t))) < 0)
+ {
+ long i = longval ();
+ if (i != ((long) (sizeof (mp_limb_t))))
+- exit (1);
++ return 1;
+ fprintf (f, "%ld\n", i);
+ }
+ else
+ {
+ unsigned long i = ulongval ();
+ if (i != ((long) (sizeof (mp_limb_t))))
+- exit (1);
++ return 1;
+ fprintf (f, "%lu\n", i);
+ }
+- exit (ferror (f) || fclose (f) != 0);
+-
+- ;
+- return 0;
++ return (ferror (f) || fclose (f) != 0);
+ }
+ _ACEOF
+ rm -f conftest$ac_exeext
+--
+2.30.2
+
diff --git a/etc/patches/gcc-4.7.4/various-fixes/series b/etc/patches/gcc-4.7.4/various-fixes/series
new file mode 100644
index 0000000..50e3f37
--- /dev/null
+++ b/etc/patches/gcc-4.7.4/various-fixes/series
@@ -0,0 +1,4 @@
+0001-non-behavioral-changing-fix-in-gcc-cp-rtti.c.patch
+0002-comment-out-M4-m4-not-needed-in-gmp-configure.patch
+0003-cfns-fix-mismatch-in-gnu_inline-attributes.patch
+0004-fix-gmp-configure-to-comply-with-newer-c-standards.patch