Skip to content

Commit

Permalink
toolchain: gcc: add support for GCC 14
Browse files Browse the repository at this point in the history
Deleted (upstreamed):
- 020-Include-safe-ctype.h-after-C-standard-headers-to-avo.patch [1]
- 021-libcc1-fix-vector-include.patch [2]

All other patches automatically rebased.

Note that selecting GCC 14, as of now, *will* result in build failures. The
packages that fail to build will be fixed as they're found. Thus, GCC 13.x is
the default, for the time being.

[1] https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=9970b576b7e4ae337af1268395ff221348c4b34a
[2] https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=5213047b1d50af63dfabb5e5649821a6cb157e33

Signed-off-by: Rui Salvaterra <[email protected]>
  • Loading branch information
rsalvaterra committed May 12, 2024
1 parent fbf6f9d commit c758d64
Show file tree
Hide file tree
Showing 21 changed files with 630 additions and 0 deletions.
3 changes: 3 additions & 0 deletions toolchain/gcc/Config.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ choice

config GCC_USE_VERSION_13
bool "gcc 13.x"

config GCC_USE_VERSION_14
bool "gcc 14.x"
endchoice

config GCC_USE_GRAPHITE
Expand Down
5 changes: 5 additions & 0 deletions toolchain/gcc/Config.version
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@ config GCC_VERSION_12
default y if GCC_USE_VERSION_12
bool

config GCC_VERSION_14
default y if GCC_USE_VERSION_14
bool

config GCC_VERSION
string
default EXTERNAL_GCC_VERSION if EXTERNAL_TOOLCHAIN && !NATIVE_TOOLCHAIN
default "11.3.0" if GCC_VERSION_11
default "12.3.0" if GCC_VERSION_12
default "14.1.0" if GCC_VERSION_14
default "13.2.0"

config GCC_USE_DEFAULT_VERSION
Expand Down
4 changes: 4 additions & 0 deletions toolchain/gcc/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ ifeq ($(PKG_VERSION),13.2.0)
PKG_HASH:=e275e76442a6067341a27f04c5c6b83d8613144004c0413528863dc6b5c743da
endif

ifeq ($(PKG_VERSION),14.1.0)
PKG_HASH:=e283c654987afe3de9d8080bc0bd79534b5ca0d681a73a11ff2b5d3767426840
endif

PATCH_DIR=../patches-$(GCC_MAJOR_VERSION).x

BUGURL=http://bugs.openwrt.org/
Expand Down
24 changes: 24 additions & 0 deletions toolchain/gcc/patches-14.x/002-case_insensitive.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
commit 81cc26c706b2bc8c8c1eb1a322e5c5157900836e
Author: Felix Fietkau <[email protected]>
Date: Sun Oct 19 21:45:51 2014 +0000

gcc: do not assume that the Mac OS X filesystem is case insensitive

Signed-off-by: Felix Fietkau <[email protected]>

SVN-Revision: 42973

--- a/include/filenames.h
+++ b/include/filenames.h
@@ -44,11 +44,6 @@ extern "C" {
# define IS_DIR_SEPARATOR(c) IS_DOS_DIR_SEPARATOR (c)
# define IS_ABSOLUTE_PATH(f) IS_DOS_ABSOLUTE_PATH (f)
#else /* not DOSish */
-# if defined(__APPLE__)
-# ifndef HAVE_CASE_INSENSITIVE_FILE_SYSTEM
-# define HAVE_CASE_INSENSITIVE_FILE_SYSTEM 1
-# endif
-# endif /* __APPLE__ */
# define HAS_DRIVE_SPEC(f) (0)
# define IS_DIR_SEPARATOR(c) IS_UNIX_DIR_SEPARATOR (c)
# define IS_ABSOLUTE_PATH(f) IS_UNIX_ABSOLUTE_PATH (f)
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--- a/gcc/real.h
+++ b/gcc/real.h
@@ -77,8 +77,10 @@ struct GTY(()) real_value {
+ (REAL_VALUE_TYPE_SIZE%HOST_BITS_PER_WIDE_INT ? 1 : 0)) /* round up */

/* Verify the guess. */
+#ifndef __LP64__
extern char test_real_width
[sizeof (REAL_VALUE_TYPE) <= REAL_WIDTH * sizeof (HOST_WIDE_INT) ? 1 : -1];
+#endif

/* Calculate the format for CONST_DOUBLE. We need as many slots as
are necessary to overlay a REAL_VALUE_TYPE on them. This could be
35 changes: 35 additions & 0 deletions toolchain/gcc/patches-14.x/010-documentation.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
commit 098bd91f5eae625c7d2ee621e10930fc4434e5e2
Author: Luka Perkov <[email protected]>
Date: Tue Feb 26 16:16:33 2013 +0000

gcc: don't build documentation

This closes #13039.

Signed-off-by: Luka Perkov <[email protected]>

SVN-Revision: 35807

--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -3549,18 +3549,10 @@ doc/gcc.info: $(TEXI_GCC_FILES)
doc/gccint.info: $(TEXI_GCCINT_FILES)
doc/cppinternals.info: $(TEXI_CPPINT_FILES)

-doc/%.info: %.texi
- if [ x$(BUILD_INFO) = xinfo ]; then \
- $(MAKEINFO) $(MAKEINFOFLAGS) -I . -I $(gcc_docdir) \
- -I $(gcc_docdir)/include -o $@ $<; \
- fi
+doc/%.info:

# Duplicate entry to handle renaming of gccinstall.info
-doc/gccinstall.info: $(TEXI_GCCINSTALL_FILES)
- if [ x$(BUILD_INFO) = xinfo ]; then \
- $(MAKEINFO) $(MAKEINFOFLAGS) -I $(gcc_docdir) \
- -I $(gcc_docdir)/include -o $@ $<; \
- fi
+doc/gccinstall.info:

doc/cpp.dvi: $(TEXI_CPP_FILES)
doc/gcc.dvi: $(TEXI_GCC_FILES)
20 changes: 20 additions & 0 deletions toolchain/gcc/patches-14.x/110-Fix-MIPS-PR-84790.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Fix https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84790.
MIPS16 functions have a static assembler prologue which clobbers
registers v0 and v1. Add these register clobbers to function call
instructions.

--- a/gcc/config/mips/mips.cc
+++ b/gcc/config/mips/mips.cc
@@ -3227,6 +3227,12 @@ mips_emit_call_insn (rtx pattern, rtx or
emit_insn (gen_update_got_version ());
}

+ if (TARGET_MIPS16 && TARGET_USE_GOT)
+ {
+ clobber_reg (&CALL_INSN_FUNCTION_USAGE (insn), MIPS16_PIC_TEMP);
+ clobber_reg (&CALL_INSN_FUNCTION_USAGE (insn), MIPS_PROLOGUE_TEMP (word_mode));
+ }
+
if (TARGET_MIPS16
&& TARGET_EXPLICIT_RELOCS
&& TARGET_CALL_CLOBBERED_GP)
13 changes: 13 additions & 0 deletions toolchain/gcc/patches-14.x/230-musl_libssp.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -985,7 +985,9 @@ proper position among the other output f
#endif

#ifndef LINK_SSP_SPEC
-#ifdef TARGET_LIBC_PROVIDES_SSP
+#if DEFAULT_LIBC == LIBC_MUSL
+#define LINK_SSP_SPEC "-lssp_nonshared"
+#elif defined(TARGET_LIBC_PROVIDES_SSP)
#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
"|fstack-protector-strong|fstack-protector-explicit:}"
#else
21 changes: 21 additions & 0 deletions toolchain/gcc/patches-14.x/300-mips_Os_cpu_rtx_cost_model.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
commit ecf7671b769fe96f7b5134be442089f8bdba55d2
Author: Felix Fietkau <[email protected]>
Date: Thu Aug 4 20:29:45 2016 +0200

gcc: add a patch to generate better code with Os on mips

Also happens to reduce compressed code size a bit

Signed-off-by: Felix Fietkau <[email protected]>

--- a/gcc/config/mips/mips.cc
+++ b/gcc/config/mips/mips.cc
@@ -20444,7 +20444,7 @@ mips_option_override (void)
flag_pcc_struct_return = 0;

/* Decide which rtx_costs structure to use. */
- if (optimize_size)
+ if (0 && optimize_size)
mips_cost = &mips_rtx_cost_optimize_size;
else
mips_cost = &mips_rtx_cost_data[mips_tune];
33 changes: 33 additions & 0 deletions toolchain/gcc/patches-14.x/810-arm-softfloat-libgcc.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
commit 8570c4be394cff7282f332f97da2ff569a927ddb
Author: Imre Kaloz <[email protected]>
Date: Wed Feb 2 20:06:12 2011 +0000

fixup arm soft-float symbols

SVN-Revision: 25325

--- a/libgcc/config/arm/t-linux
+++ b/libgcc/config/arm/t-linux
@@ -1,6 +1,10 @@
LIB1ASMSRC = arm/lib1funcs.S
LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_lnx _clzsi2 _clzdi2 \
- _ctzsi2 _arm_addsubdf3 _arm_addsubsf3
+ _ctzsi2 _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.
--- a/gcc/config/arm/linux-elf.h
+++ b/gcc/config/arm/linux-elf.h
@@ -58,8 +58,6 @@
%{shared:-lc} \
%{!shared:%{profile:-lc_p}%{!profile:-lc}}"

-#define LIBGCC_SPEC "%{mfloat-abi=soft*:-lfloat} -lgcc"
-
#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"

#define LINUX_TARGET_LINK_SPEC "%{h*} \
44 changes: 44 additions & 0 deletions toolchain/gcc/patches-14.x/820-libgcc_pic.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
commit c96312958c0621e72c9b32da5bc224ffe2161384
Author: Felix Fietkau <[email protected]>
Date: Mon Oct 19 23:26:09 2009 +0000

gcc: create a proper libgcc_pic.a static library for relinking (4.3.3+ for now, backport will follow)

SVN-Revision: 18086

--- a/libgcc/Makefile.in
+++ b/libgcc/Makefile.in
@@ -940,11 +940,12 @@ $(libgcov-driver-objects): %$(objext): $

# Static libraries.
libgcc.a: $(libgcc-objects)
+libgcc_pic.a: $(libgcc-s-objects)
libgcov.a: $(libgcov-objects)
libunwind.a: $(libunwind-objects)
libgcc_eh.a: $(libgcc-eh-objects)

-libgcc.a libgcov.a libunwind.a libgcc_eh.a:
+libgcc.a libgcov.a libunwind.a libgcc_eh.a libgcc_pic.a:
-rm -f $@

objects="$(objects)"; \
@@ -968,7 +969,7 @@ all: libunwind.a
endif

ifeq ($(enable_shared),yes)
-all: libgcc_eh.a libgcc_s$(SHLIB_EXT)
+all: libgcc_eh.a libgcc_pic.a libgcc_s$(SHLIB_EXT)
ifneq ($(LIBUNWIND),)
all: libunwind$(SHLIB_EXT)
libgcc_s$(SHLIB_EXT): libunwind$(SHLIB_EXT)
@@ -1174,6 +1175,10 @@ install-shared:
chmod 644 $(DESTDIR)$(inst_libdir)/libgcc_eh.a
$(RANLIB) $(DESTDIR)$(inst_libdir)/libgcc_eh.a

+ $(INSTALL_DATA) libgcc_pic.a $(mapfile) $(DESTDIR)$(inst_libdir)/
+ chmod 644 $(DESTDIR)$(inst_libdir)/libgcc_pic.a
+ $(RANLIB) $(DESTDIR)$(inst_libdir)/libgcc_pic.a
+
$(subst @multilib_dir@,$(MULTIDIR),$(subst \
@shlib_base_name@,libgcc_s,$(subst \
@shlib_slibdir_qual@,$(MULTIOSSUBDIR),$(SHLIB_INSTALL))))
28 changes: 28 additions & 0 deletions toolchain/gcc/patches-14.x/840-armv4_pass_fix-v4bx_to_ld.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
commit 7edc8ca5456d9743dd0075eb3cc5b04f4f24c8cc
Author: Imre Kaloz <[email protected]>
Date: Wed Feb 2 19:34:36 2011 +0000

add armv4 fixup patches

SVN-Revision: 25322


--- a/gcc/config/arm/linux-eabi.h
+++ b/gcc/config/arm/linux-eabi.h
@@ -88,10 +88,15 @@
#define MUSL_DYNAMIC_LINKER \
"/lib/ld-musl-arm" MUSL_DYNAMIC_LINKER_E "%{mfloat-abi=hard:hf}%{mfdpic:-fdpic}.so.1"

+/* For armv4 we pass --fix-v4bx to linker to support EABI */
+#undef TARGET_FIX_V4BX_SPEC
+#define TARGET_FIX_V4BX_SPEC " %{mcpu=arm8|mcpu=arm810|mcpu=strongarm*"\
+ "|march=armv4|mcpu=fa526|mcpu=fa626:--fix-v4bx}"
+
/* At this point, bpabi.h will have clobbered LINK_SPEC. We want to
use the GNU/Linux version, not the generic BPABI version. */
#undef LINK_SPEC
-#define LINK_SPEC EABI_LINK_SPEC \
+#define LINK_SPEC EABI_LINK_SPEC TARGET_FIX_V4BX_SPEC \
LINUX_OR_ANDROID_LD (LINUX_TARGET_LINK_SPEC, \
LINUX_TARGET_LINK_SPEC " " ANDROID_LINK_SPEC)

54 changes: 54 additions & 0 deletions toolchain/gcc/patches-14.x/850-use_shared_libgcc.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
commit dcfc40358b5a3cae7320c17f8d1cebd5ad5540cd
Author: Felix Fietkau <[email protected]>
Date: Sun Feb 12 20:25:47 2012 +0000

gcc 4.6: port over the missing patch 850-use_shared_libgcc.patch to prevent libgcc crap from leaking into every single binary

SVN-Revision: 30486
--- a/gcc/config/arm/linux-eabi.h
+++ b/gcc/config/arm/linux-eabi.h
@@ -129,10 +129,6 @@
"%{Ofast|ffast-math|funsafe-math-optimizations:%{!shared:crtfastmath.o%s}} " \
LINUX_OR_ANDROID_LD (GNU_USER_TARGET_ENDFILE_SPEC, ANDROID_ENDFILE_SPEC)

-/* Use the default LIBGCC_SPEC, not the version in linux-elf.h, as we
- do not use -lfloat. */
-#undef LIBGCC_SPEC
-
/* Clear the instruction cache from `beg' to `end'. This is
implemented in lib1funcs.S, so ensure an error if this definition
is used. */
--- a/gcc/config/linux.h
+++ b/gcc/config/linux.h
@@ -58,6 +58,10 @@ see the files COPYING3 and COPYING.RUNTI
builtin_assert ("system=posix"); \
} while (0)

+#ifndef LIBGCC_SPEC
+#define LIBGCC_SPEC "%{static|static-libgcc:-lgcc}%{!static:%{!static-libgcc:-lgcc_s}}"
+#endif
+
/* Determine which dynamic linker to use depending on whether GLIBC or
uClibc or Bionic or musl is the default C library and whether
-muclibc or -mglibc or -mbionic or -mmusl has been passed to change
--- a/libgcc/mkmap-symver.awk
+++ b/libgcc/mkmap-symver.awk
@@ -136,5 +136,5 @@ function output(lib) {
else if (inherit[lib])
printf("} %s;\n", inherit[lib]);
else
- printf ("\n local:\n\t*;\n};\n");
+ printf ("\n\t*;\n};\n");
}
--- a/gcc/config/rs6000/linux.h
+++ b/gcc/config/rs6000/linux.h
@@ -70,6 +70,9 @@
#undef CPP_OS_DEFAULT_SPEC
#define CPP_OS_DEFAULT_SPEC "%(cpp_os_linux)"

+#undef LIBGCC_SPEC
+#define LIBGCC_SPEC "%{!static:%{!static-libgcc:-lgcc_s}} -lgcc"
+
#undef LINK_SHLIB_SPEC
#define LINK_SHLIB_SPEC "%{shared:-shared} %{!shared: %{static:-static}} \
%{static-pie:-static -pie --no-dynamic-linker -z text}"
22 changes: 22 additions & 0 deletions toolchain/gcc/patches-14.x/851-libgcc_no_compat.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
commit 64661de100da1ec1061ef3e5e400285dce115e6b
Author: Felix Fietkau <[email protected]>
Date: Sun May 10 13:16:35 2015 +0000

gcc: add some size optimization patches

Signed-off-by: Felix Fietkau <[email protected]>

SVN-Revision: 45664

--- a/libgcc/config/t-libunwind
+++ b/libgcc/config/t-libunwind
@@ -2,8 +2,7 @@

HOST_LIBGCC2_CFLAGS += -DUSE_GAS_SYMVER

-LIB2ADDEH = $(srcdir)/unwind-sjlj.c $(srcdir)/unwind-c.c \
- $(srcdir)/unwind-compat.c $(srcdir)/unwind-dw2-fde-compat.c
+LIB2ADDEH = $(srcdir)/unwind-sjlj.c $(srcdir)/unwind-c.c
LIB2ADDEHSTATIC = $(srcdir)/unwind-sjlj.c $(srcdir)/unwind-c.c

# Override the default value from t-slibgcc-elf-ver and mention -lunwind
11 changes: 11 additions & 0 deletions toolchain/gcc/patches-14.x/870-ppc_no_crtsavres.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/gcc/config/rs6000/rs6000-logue.cc
+++ b/gcc/config/rs6000/rs6000-logue.cc
@@ -344,7 +344,7 @@ rs6000_savres_strategy (rs6000_stack_t *
/* Define cutoff for using out-of-line functions to save registers. */
if (DEFAULT_ABI == ABI_V4 || TARGET_ELF)
{
- if (!optimize_size)
+ if (1)
{
strategy |= SAVE_INLINE_FPRS | REST_INLINE_FPRS;
strategy |= SAVE_INLINE_GPRS | REST_INLINE_GPRS;
11 changes: 11 additions & 0 deletions toolchain/gcc/patches-14.x/881-no_tm_section.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/libgcc/crtstuff.c
+++ b/libgcc/crtstuff.c
@@ -152,7 +152,7 @@ call_ ## FUNC (void) \
#endif

#if !defined(USE_TM_CLONE_REGISTRY) && defined(OBJECT_FORMAT_ELF)
-# define USE_TM_CLONE_REGISTRY 1
+# define USE_TM_CLONE_REGISTRY 0
#elif !defined(USE_TM_CLONE_REGISTRY)
# define USE_TM_CLONE_REGISTRY 0
#endif
9 changes: 9 additions & 0 deletions toolchain/gcc/patches-14.x/900-bad-mips16-crt.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
--- a/libgcc/config/mips/t-mips16
+++ b/libgcc/config/mips/t-mips16
@@ -42,3 +42,6 @@ SYNC_CFLAGS = -mno-mips16

# Version these symbols if building libgcc.so.
SHLIB_MAPFILES += $(srcdir)/config/mips/libgcc-mips16.ver
+
+CRTSTUFF_T_CFLAGS += -mno-mips16
+CRTSTUFF_T_CFLAGS_S += -mno-mips16
Loading

0 comments on commit c758d64

Please sign in to comment.