commit: ca9d3aa51fbc100df68a3fb17b61bdf8d9f7c86e
parent 712175af4483cf4117c55c3e2dc5be43ba04d06d
Author: fosslinux <fosslinux@aussies.space>
Date: Fri, 27 Jan 2023 17:01:03 +1100
Patch GCC 4.7 for GCC 10
A couple of backports that ease the building of GCC 10.
Diffstat:
6 files changed, 360 insertions(+), 3 deletions(-)
diff --git a/parts.rst b/parts.rst
@@ -867,6 +867,10 @@ gcc 4.7.4
GCC 4.7.4 is the last version written in C. This time we build both C and C++ backends.
C++ backend has some dependency on ``gperf`` which is written in C++. Fortunately, it is
easy to patch it out and resulting ``g++`` compiler is capable of building ``gperf``.
+We also add in two patchsets to the compiler;
+
+* one to add support for musl shared library support
+* one providing a few compiler flags/features that are required later to build GCC 10
binutils 2.38
=============
diff --git a/sysa/SHA256SUMS.pkgs b/sysa/SHA256SUMS.pkgs
@@ -52,7 +52,7 @@ f55c11b091361536774b436abe86b17f759cd7a66522cd20c7a2190da92db67a findutils-4.2.
458b64a564ca1ef32ed1c682187caa59743a772210fc51a2bc7f11859bdc98f8 gc-8.0.4_0.tar.bz2
ebbc144e18ca908295845c707f10df82a3337732cc167fcc251b6e6c508d454e gcc-4.0.4_0.tar.bz2
5d3d9bae0069fd4388392b91a47bba4d7ce6733ca9075742ef0d4a4cab899803 gcc-4.0.4_1.tar.bz2
-8ab35eceef7dca2f532e254b2b3311f84ebea23f9bedee025806ed5b4513e523 gcc-4.7.4_0.tar.bz2
+ef44ca57e0b263bc4caae7c375af8930b4e3cf0c58fec98092678d622e37a4a6 gcc-4.7.4_0.tar.bz2
99891d9413e7d3923bd1466d1bb24fdad5c0b41735a4b614d4029ec9512df0c9 gettext-0.21_0.tar.bz2
8906ece680934b78ea0fb5f950595b6480b8fbd06481039547ec7a370cb6e6bf gmp-6.2.1_0.tar.bz2
3fd7b8e71183060864420479bd36a6853119c4eae5568672838cae23b7dc1050 gperf-3.1_0.tar.bz2
diff --git a/sysc/gcc-4.7.4/gcc-4.7.4.sh b/sysc/gcc-4.7.4/gcc-4.7.4.sh
@@ -1,6 +1,6 @@
# SPDX-FileCopyrightText: 2021 Andrius Štikonas <andrius@stikonas.eu>
# SPDX-FileCopyrightText: 2021 Paul Dersey <pdersey@gmail.com>
-# SPDX-FileCopyrightText: 2021-22 fosslinux <fosslinux@aussies.space>
+# SPDX-FileCopyrightText: 2021-23 fosslinux <fosslinux@aussies.space>
# SPDX-License-Identifier: GPL-3.0-or-later
@@ -104,7 +104,8 @@ src_configure() {
--disable-shared \
--program-transform-name= \
--enable-languages=c,c++ \
- --disable-sjlj-exceptions
+ --disable-sjlj-exceptions \
+ --with-system-zlib
cd ..
done
cd ..
diff --git a/sysc/gcc-4.7.4/patches/gcc-10-fself-test.patch b/sysc/gcc-4.7.4/patches/gcc-10-fself-test.patch
@@ -0,0 +1,21 @@
+SPDX-FileCopyrightText: 2023 fosslinux <fosslinux@aussies.space>
+
+SPDX-License-Identifier: GPL-3.0-or-later
+
+In GCC 10, fself-test is run on every GCC used in the
+build process to ensure correctness. However this is not
+yet introduced in GCC 4.7, so we no-op it.
+
+--- gcc/common.opt 2023-01-23 21:22:23.630919284 +1100
++++ gcc/common.opt 2023-01-23 21:23:33.030143958 +1100
+@@ -1701,6 +1701,10 @@
+ Common Report Var(flag_selective_scheduling2) Optimization
+ Run selective scheduling after reload
+
++fself-test=
++Common Undocumented Joined Var(flag_self_test)
++Run no-op self-tests.
++
+ fsel-sched-pipelining
+ Common Report Var(flag_sel_sched_pipelining) Init(0) Optimization
+ Perform software pipelining of inner loops during selective scheduling
diff --git a/sysc/gcc-4.7.4/patches/gcc-10-libgcc-builtin-macros.patch b/sysc/gcc-4.7.4/patches/gcc-10-libgcc-builtin-macros.patch
@@ -0,0 +1,45 @@
+SPDX-FileCopyrightText: 2023 fosslinux <fosslinux@aussies.space>
+SPDX-FileCopyrightText: 2014 Joseph Myers <joseph@codesourcery.com>
+
+SPDX-License-Identifier: GPL-3.0-or-later
+
+GCC 10 uses a variety of compiler builtin macros in libgcc.
+These macros do not exist in GCC 4.7, so we add them in.
+(Taken straight from GCC 10).
+
+(We could -D them in GCC 10, but this is a simpler unobtrusive
+solution, and is arguably more correct).
+
+--- gcc/c-family/c-cppbuiltin.c 2023-01-25 16:56:44.122222376 +1100
++++ gcc/c-family/c-cppbuiltin.c 2023-01-25 17:01:52.500855016 +1100
+@@ -850,6 +850,30 @@
+ builtin_define_with_int_value ("__LIBGCC_TRAMPOLINE_SIZE__",
+ TRAMPOLINE_SIZE);
+
++ /* For libgcc unwinder code. */
++#ifdef DONT_USE_BUILTIN_SETJMP
++ cpp_define (pfile, "__LIBGCC_DONT_USE_BUILTIN_SETJMP__");
++#endif
++#ifdef DWARF_ALT_FRAME_RETURN_COLUMN
++ builtin_define_with_int_value ("__LIBGCC_DWARF_ALT_FRAME_RETURN_COLUMN__",
++ DWARF_ALT_FRAME_RETURN_COLUMN);
++#endif
++ builtin_define_with_int_value ("__LIBGCC_DWARF_FRAME_REGISTERS__",
++ DWARF_FRAME_REGISTERS);
++#ifdef EH_RETURN_STACKADJ_RTX
++ cpp_define (pfile, "__LIBGCC_EH_RETURN_STACKADJ_RTX__");
++#endif
++#ifdef JMP_BUF_SIZE
++ builtin_define_with_int_value ("__LIBGCC_JMP_BUF_SIZE__",
++ JMP_BUF_SIZE);
++#endif
++ builtin_define_with_int_value ("__LIBGCC_STACK_POINTER_REGNUM__",
++ STACK_POINTER_REGNUM);
++
++ /* For libgcov. */
++ builtin_define_with_int_value ("__LIBGCC_VTABLE_USES_DESCRIPTORS__",
++ TARGET_VTABLE_USES_DESCRIPTORS);
++
+ /* For use in assembly language. */
+ builtin_define_with_value ("__REGISTER_PREFIX__", REGISTER_PREFIX, 0);
+ builtin_define_with_value ("__USER_LABEL_PREFIX__", user_label_prefix, 0);
diff --git a/sysc/gcc-4.7.4/patches/gcc-10-mlong-double.patch b/sysc/gcc-4.7.4/patches/gcc-10-mlong-double.patch
@@ -0,0 +1,286 @@
+SPDX-FileCopyrightText: 2023 fosslinux <fosslinux@aussies.space>
+SPDX-FileCopyrightText: 2012 H.J. Lu <hongjiu.lu@intel.com>
+
+SPDX-License-Identifier: GPL-3.0-or-later
+
+Backport of the commit:
+[PATCH] Add -mlong-double-64/-mlong-double-80 to i386
+to GCC 4.7.
+
+GCC 10 uses this argument to ensure some files are compiled with long
+double length = 80. This is almost universally true for i386, so it
+could be patched out; but the use of this flag is rather extensive,
+and if removed will break future added architectures anyway, so it
+makes more sense to simply add in support to GCC 4.7.
+
+diff --git gcc/config/i386/i386-c.c gcc/config/i386/i386-c.c
+index d00e0ba54b939..edd64ff7ae388 100644
+--- gcc/config/i386/i386-c.c
++++ gcc/config/i386/i386-c.c
+@@ -418,6 +418,9 @@
+ builtin_define_std ("i386");
+ }
+
++ if (TARGET_LONG_DOUBLE_64)
++ cpp_define (parse_in, "__LONG_DOUBLE_64__");
++
+ ix86_target_macros_internal (ix86_isa_flags,
+ ix86_arch,
+ ix86_tune,
+diff --git gcc/config/i386/i386.c gcc/config/i386/i386.c
+index a6fc45b047a94..da931ee153745 100644
+--- gcc/config/i386/i386.c
++++ gcc/config/i386/i386.c
+@@ -2786,6 +2786,7 @@ ix86_target_string (HOST_WIDE_INT isa, int flags, const char *arch,
+ static struct ix86_target_opts flag_opts[] =
+ {
+ { "-m128bit-long-double", MASK_128BIT_LONG_DOUBLE },
++ { "-mlong-double-64", MASK_LONG_DOUBLE_64 },
+ { "-m80387", MASK_80387 },
+ { "-maccumulate-outgoing-args", MASK_ACCUMULATE_OUTGOING_ARGS },
+ { "-malign-double", MASK_ALIGN_DOUBLE },
+@@ -4084,6 +4085,11 @@ ix86_option_override_internal (bool main_args_p)
+ else if (target_flags_explicit & MASK_RECIP)
+ recip_mask &= ~(RECIP_MASK_ALL & ~recip_mask_explicit);
+
++ /* Default long double to 64-bit for Bionic. */
++ if (TARGET_HAS_BIONIC
++ && !(target_flags_explicit & MASK_LONG_DOUBLE_64))
++ target_flags |= MASK_LONG_DOUBLE_64;
++
+ /* Save the initial options in case the user does function specific
+ options. */
+ if (main_args_p)
+diff --git gcc/config/i386/i386.h gcc/config/i386/i386.h
+index 11f79e3f670af..3a41a43e308bf 100644
+--- gcc/config/i386/i386.h
++++ gcc/config/i386/i386.h
+@@ -671,9 +671,17 @@ enum target_cpu_default
+ #define LONG_LONG_TYPE_SIZE 64
+ #define FLOAT_TYPE_SIZE 32
+ #define DOUBLE_TYPE_SIZE 64
+-#define LONG_DOUBLE_TYPE_SIZE 80
++#define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_64 ? 64 : 80)
+
+-#define WIDEST_HARDWARE_FP_SIZE LONG_DOUBLE_TYPE_SIZE
++/* Define this to set long double type size to use in libgcc2.c, which can
++ not depend on target_flags. */
++#ifdef __LONG_DOUBLE_64__
++#define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
++#else
++#define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 80
++#endif
++
++#define WIDEST_HARDWARE_FP_SIZE 80
+
+ #if defined (TARGET_BI_ARCH) || TARGET_64BIT_DEFAULT
+ #define MAX_BITS_PER_WORD 64
+diff --git gcc/config/i386/i386.opt gcc/config/i386/i386.opt
+index e4f78f3ce50f3..6a389947d904e 100644
+--- gcc/config/i386/i386.opt
++++ gcc/config/i386/i386.opt
+@@ -86,6 +86,14 @@ m96bit-long-double
+ Target RejectNegative Report InverseMask(128BIT_LONG_DOUBLE) Save
+ sizeof(long double) is 12
+
++mlong-double-80
++Target Report RejectNegative InverseMask(LONG_DOUBLE_64) Save
++Use 80-bit long double
++
++mlong-double-64
++Target Report RejectNegative Mask(LONG_DOUBLE_64) Save
++Use 64-bit long double
++
+ maccumulate-outgoing-args
+ Target Report Mask(ACCUMULATE_OUTGOING_ARGS) Save
+ Reserve space for outgoing arguments in the function prologue
+diff --git gcc/testsuite/gcc.target/i386/long-double-64-1.c gcc/testsuite/gcc.target/i386/long-double-64-1.c
+new file mode 100644
+index 0000000000000..cf933796f8aea
+--- /dev/null
++++ gcc/testsuite/gcc.target/i386/long-double-64-1.c
+@@ -0,0 +1,10 @@
++/* { dg-do compile } */
++/* { dg-options "-O2 -mlong-double-64" } */
++
++long double
++foo (long double x)
++{
++ return x * x;
++}
++
++/* { dg-final { scan-assembler-not "fldt" } } */
+diff --git gcc/testsuite/gcc.target/i386/long-double-64-2.c gcc/testsuite/gcc.target/i386/long-double-64-2.c
+new file mode 100644
+index 0000000000000..ddf4fe656d099
+--- /dev/null
++++ gcc/testsuite/gcc.target/i386/long-double-64-2.c
+@@ -0,0 +1,10 @@
++/* { dg-do compile { target *-*-linux* } } */
++/* { dg-options "-O2 -mbionic" } */
++
++long double
++foo (long double x)
++{
++ return x * x;
++}
++
++/* { dg-final { scan-assembler-not "fldt" } } */
+diff --git gcc/testsuite/gcc.target/i386/long-double-64-3.c gcc/testsuite/gcc.target/i386/long-double-64-3.c
+new file mode 100644
+index 0000000000000..e748fab2edd3c
+--- /dev/null
++++ gcc/testsuite/gcc.target/i386/long-double-64-3.c
+@@ -0,0 +1,10 @@
++/* { dg-do compile { target *-*-linux* } } */
++/* { dg-options "-O2 -mandroid" } */
++
++long double
++foo (long double x)
++{
++ return x * x;
++}
++
++/* { dg-final { scan-assembler-not "fldt" } } */
+diff --git gcc/testsuite/gcc.target/i386/long-double-64-4.c gcc/testsuite/gcc.target/i386/long-double-64-4.c
+new file mode 100644
+index 0000000000000..d9c25aaec080c
+--- /dev/null
++++ gcc/testsuite/gcc.target/i386/long-double-64-4.c
+@@ -0,0 +1,10 @@
++/* { dg-do compile } */
++/* { dg-options "-O2 -mlong-double-80 -mlong-double-64" } */
++
++long double
++foo (long double x)
++{
++ return x * x;
++}
++
++/* { dg-final { scan-assembler-not "fldt" } } */
+diff --git gcc/testsuite/gcc.target/i386/long-double-80-1.c gcc/testsuite/gcc.target/i386/long-double-80-1.c
+new file mode 100644
+index 0000000000000..d3b75a0be21de
+--- /dev/null
++++ gcc/testsuite/gcc.target/i386/long-double-80-1.c
+@@ -0,0 +1,10 @@
++/* { dg-do compile } */
++/* { dg-options "-O2 -mlong-double-80" } */
++
++long double
++foo (long double x)
++{
++ return x * x;
++}
++
++/* { dg-final { scan-assembler "fldt" } } */
+diff --git gcc/testsuite/gcc.target/i386/long-double-80-2.c gcc/testsuite/gcc.target/i386/long-double-80-2.c
+new file mode 100644
+index 0000000000000..954dfd15d4271
+--- /dev/null
++++ gcc/testsuite/gcc.target/i386/long-double-80-2.c
+@@ -0,0 +1,10 @@
++/* { dg-do compile { target *-*-linux* } } */
++/* { dg-options "-O2 -mlong-double-80 -mbionic" } */
++
++long double
++foo (long double x)
++{
++ return x * x;
++}
++
++/* { dg-final { scan-assembler "fldt" } } */
+diff --git gcc/testsuite/gcc.target/i386/long-double-80-3.c gcc/testsuite/gcc.target/i386/long-double-80-3.c
+new file mode 100644
+index 0000000000000..e0e8365e32c4a
+--- /dev/null
++++ gcc/testsuite/gcc.target/i386/long-double-80-3.c
+@@ -0,0 +1,10 @@
++/* { dg-do compile { target *-*-linux* } } */
++/* { dg-options "-O2 -mlong-double-80 -mandroid" } */
++
++long double
++foo (long double x)
++{
++ return x * x;
++}
++
++/* { dg-final { scan-assembler "fldt" } } */
+diff --git gcc/testsuite/gcc.target/i386/long-double-80-4.c gcc/testsuite/gcc.target/i386/long-double-80-4.c
+new file mode 100644
+index 0000000000000..cac2d55bc166c
+--- /dev/null
++++ gcc/testsuite/gcc.target/i386/long-double-80-4.c
+@@ -0,0 +1,10 @@
++/* { dg-do compile } */
++/* { dg-options "-O2 -mlong-double-64 -mlong-double-80" } */
++
++long double
++foo (long double x)
++{
++ return x * x;
++}
++
++/* { dg-final { scan-assembler "fldt" } } */
+diff --git gcc/testsuite/gcc.target/i386/long-double-80-5.c gcc/testsuite/gcc.target/i386/long-double-80-5.c
+new file mode 100644
+index 0000000000000..4aa606fd1ba05
+--- /dev/null
++++ gcc/testsuite/gcc.target/i386/long-double-80-5.c
+@@ -0,0 +1,10 @@
++/* { dg-do compile } */
++/* { dg-options "-O2 -mlong-double-64" } */
++
++__float80
++foo (__float80 x)
++{
++ return x * x;
++}
++
++/* { dg-final { scan-assembler "fldt" } } */
+diff --git gcc/testsuite/gcc.target/i386/long-double-80-6.c gcc/testsuite/gcc.target/i386/long-double-80-6.c
+new file mode 100644
+index 0000000000000..a395a265942c1
+--- /dev/null
++++ gcc/testsuite/gcc.target/i386/long-double-80-6.c
+@@ -0,0 +1,11 @@
++/* { dg-do run } */
++/* { dg-options "-O0 -mlong-double-64 -mfpmath=387" } */
++
++int
++main ()
++{
++ __float80 a = -0.23456789;
++ if ((double) a >= 0)
++ __builtin_abort ();
++ return 0;
++}
+diff --git gcc/testsuite/gcc.target/i386/long-double-80-7.c gcc/testsuite/gcc.target/i386/long-double-80-7.c
+new file mode 100644
+index 0000000000000..9b30fe8856786
+--- /dev/null
++++ gcc/testsuite/gcc.target/i386/long-double-80-7.c
+@@ -0,0 +1,13 @@
++/* { dg-do run } */
++/* { dg-options "-O0 -mlong-double-64 -mfpmath=sse" } */
++/* { dg-require-effective-target sse2 } */
++
++#include "sse2-check.h"
++
++static void
++sse2_test (void)
++{
++ __float80 a = -0.23456789;
++ if ((double) a >= 0)
++ __builtin_abort ();
++}
+diff --git libgcc/config/i386/t-linux libgcc/config/i386/t-linux
+index 29b4c22398346..4f47f7bfa59cf 100644
+--- libgcc/config/i386/t-linux
++++ libgcc/config/i386/t-linux
+@@ -2,3 +2,5 @@
+ # Need to support TImode for x86. Override the settings from
+ # t-slibgcc-elf-ver and t-linux
+ SHLIB_MAPFILES = libgcc-std.ver $(srcdir)/config/i386/libgcc-glibc.ver
++
++HOST_LIBGCC2_CFLAGS += -mlong-double-80