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 | 21 +++++++++++++++++++++ libgcc/unwind-dw2-fde-dip.c | 6 ++++++ 3 files changed, 30 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 9d7212028d063648206b521705601ad2b50620c5..9f3c857a1e0cade7171b371c4e823487a5e3b2f2 100644 --- a/libgcc/config.host +++ b/libgcc/config.host @@ -1312,6 +1312,11 @@ riscv*-*-freebsd*) tmake_file="${tmake_file} riscv/t-softfp${host_address} t-softfp riscv/t-elf riscv/t-elf${host_address} t-slibgcc-libgcc" extra_parts="$extra_parts crtbegin.o crtend.o crti.o crtn.o crtendS.o crtbeginT.o" ;; +riscv64-*-serenity*) + extra_parts="$extra_parts crti.o crtbegin.o crtbeginS.o crtend.o crtendS.o crtn.o" + tmake_file="$tmake_file riscv/t-softfp64 t-softfp riscv/t-elf riscv/t-elf64 t-slibgcc-libgcc t-eh-dw2-dip" + tmake_file="$tmake_file riscv/t-crtstuff t-crtstuff-pic t-libgcc-pic t-slibgcc t-slibgcc-gld-nover" + ;; riscv*-*-*) tmake_file="${tmake_file} riscv/t-softfp${host_address} t-softfp riscv/t-elf riscv/t-elf${host_address}" extra_parts="$extra_parts crtbegin.o crtend.o crti.o crtn.o" @@ -1525,6 +1530,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 28ea0e64e0e8d8c1faf52194a78cfc98398eceb8..2b139330c045ee01651bececc4d882f09f380cce 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__)