ladybird/Toolchain/Patches/gcc/0003-libgcc-Build-for-SerenityOS.patch
Daniel Bertalan 07918b79b7 Toolchain+Ports: Update GCC to 13.1.0
This is a mostly straight-forward rebase of our patches on top of
13.1.0. The spec files needed a change, as GCC no longer supports STABS
debug information, but we were building GCC with support for it.

Highlights of this release include static `operator()`, The Equality
Operator You Are Looking For and extended `constexpr` support.
2023-05-15 07:00:29 +02:00

79 lines
3 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Andreas Kling <awesomekling@gmail.com>
Date: Mon, 16 May 2022 15:01:06 +0200
Subject: [PATCH] libgcc: Build for SerenityOS
This patch enables building gcc's own C runtime files, and sets up
exception handling support.
Co-Authored-By: Gunnar Beutner <gbeutner@serenityos.org>
Co-Authored-By: Itamar <itamar8910@gmail.com>
Co-Authored-By: Nico Weber <thakis@chromium.org>
Co-Authored-By: Andrew Kaster <andrewdkaster@gmail.com>
Co-Authored-By: Daniel Bertalan <dani@danielbertalan.dev>
Co-Authored-By: Philip Herron <herron.philip@googlemail.com>
Co-Authored-By: Shannon Booth <shannon.ml.booth@gmail.com>
---
gcc/configure | 3 +++
libgcc/config.host | 16 ++++++++++++++++
libgcc/unwind-dw2-fde-dip.c | 6 ++++++
3 files changed, 25 insertions(+)
diff --git a/gcc/configure b/gcc/configure
index c7b26d1927de62d7b3a49ea9ac0a998979659cf2..5fcfaa3cfff30d2e8d1cdf3f62bf2125e2f99179 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -31377,6 +31377,9 @@ case "$target" in
*-linux-musl*)
gcc_cv_target_dl_iterate_phdr=yes
;;
+ *-serenity*)
+ gcc_cv_target_dl_iterate_phdr=yes
+ ;;
esac
if test x$gcc_cv_target_dl_iterate_phdr = xyes; then
diff --git a/libgcc/config.host b/libgcc/config.host
index b9975de902357576003cf391850fef2dc336aee1..7b1f6775b989410ccd6766f50740a288c6934794 100644
--- a/libgcc/config.host
+++ b/libgcc/config.host
@@ -1507,6 +1507,22 @@ nvptx-*)
tmake_file="$tmake_file nvptx/t-nvptx"
extra_parts="crt0.o"
;;
+i[34567]86-*-serenity*)
+ extra_parts="$extra_parts crti.o crtbegin.o crtbeginS.o crtend.o crtendS.o crtn.o"
+ tmake_file="$tmake_file i386/t-crtstuff t-crtstuff-pic t-libgcc-pic t-slibgcc t-eh-dw2-dip"
+ ;;
+x86_64-*-serenity*)
+ extra_parts="$extra_parts crti.o crtbegin.o crtbeginS.o crtend.o crtendS.o crtn.o"
+ tmake_file="$tmake_file i386/t-crtstuff t-crtstuff-pic t-libgcc-pic t-slibgcc t-eh-dw2-dip"
+ ;;
+aarch64-*-serenity*)
+ extra_parts="$extra_parts crti.o crtbegin.o crtbeginS.o crtend.o crtendS.o crtn.o"
+ extra_parts="$extra_parts crtfastmath.o"
+ tmake_file="$tmake_file ${cpu_type}/t-aarch64"
+ tmake_file="$tmake_file ${cpu_type}/t-lse t-slibgcc t-slibgcc-libgcc t-slibgcc-gld-nover"
+ tmake_file="$tmake_file ${cpu_type}/t-softfp t-softfp t-crtfm"
+ md_unwind_header=aarch64/aarch64-unwind.h
+ ;;
*)
echo "*** Configuration ${host} not supported" 1>&2
exit 1
diff --git a/libgcc/unwind-dw2-fde-dip.c b/libgcc/unwind-dw2-fde-dip.c
index 6223f5f18a23038c30654f191c63b9ae8baca26a..87813e9b249e7add5915ca310c86443a712caa05 100644
--- a/libgcc/unwind-dw2-fde-dip.c
+++ b/libgcc/unwind-dw2-fde-dip.c
@@ -57,6 +57,12 @@
# define USE_PT_GNU_EH_FRAME
#endif
+#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
+ && defined(TARGET_DL_ITERATE_PHDR) \
+ && defined(__serenity__)
+# define USE_PT_GNU_EH_FRAME
+#endif
+
#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
&& defined(TARGET_DL_ITERATE_PHDR) \
&& defined(__linux__)