From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Andreas Kling 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 Co-Authored-By: Itamar Co-Authored-By: Nico Weber Co-Authored-By: Andrew Kaster Co-Authored-By: Daniel Bertalan Co-Authored-By: Philip Herron Co-Authored-By: Shannon Booth --- 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 5ce0557719a9fe0acf9a0f0ffaf949e9eeba0eb1..2deaac5bc85815a7e3efc47a935fb81fca9b24da 100755 --- a/gcc/configure +++ b/gcc/configure @@ -31608,6 +31608,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 8c56fcae5d2fdfcc8d1f9b2614f0c41ad44f258f..f5855cfa66d7950c3d7565ad938b4e4727d7b46d 100644 --- a/libgcc/config.host +++ b/libgcc/config.host @@ -1534,6 +1534,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 7f9be5e6b021a539278570ad202f1f9c45311ca1..817c3fe219252ab3e1707913ebd53dfd97616b58 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__)