diff options
author | Oliver Reiche <oliver.reiche@huawei.com> | 2023-10-20 16:07:58 +0200 |
---|---|---|
committer | Oliver Reiche <oliver.reiche@huawei.com> | 2023-10-20 16:07:58 +0200 |
commit | 060a0cf338d6024eee37cc344c224fe3bcb78e81 (patch) | |
tree | 3fea7c654b69ecf3490fe9c6cbc542aba0d5bd8f /etc/patches/gcc-4.7.4/various-fixes | |
download | bootstrappable-toolchain-060a0cf338d6024eee37cc344c224fe3bcb78e81.tar.gz |
Initial commit
Diffstat (limited to 'etc/patches/gcc-4.7.4/various-fixes')
5 files changed, 381 insertions, 0 deletions
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 |