Toolchain: Enough to make rebuild-toolchain aarch64 work

The gcc patch might not be completely correct, but at least the
toolchain completes building.
This commit is contained in:
Nico Weber 2021-08-27 22:36:38 -04:00 committed by Linus Groh
parent 61b6f69947
commit 7052f403c8
4 changed files with 47 additions and 10 deletions

View file

@ -94,6 +94,10 @@ get_top_dir() {
}
is_valid_target() {
if [ "$TARGET" = "aarch64" ]; then
CMAKE_ARGS+=("-DSERENITY_ARCH=aarch64")
return 0
fi
if [ "$TARGET" = "lagom" ]; then
CMAKE_ARGS+=("-DBUILD_LAGOM=ON")
return 0

View file

@ -1,8 +1,8 @@
diff --git a/bfd/config.bfd b/bfd/config.bfd
index 30087e3b..7658cf30 100644
index 30087e3b..8b192b2e 100644
--- a/bfd/config.bfd
+++ b/bfd/config.bfd
@@ -223,7 +223,24 @@ esac
@@ -223,7 +223,29 @@ esac
case "${targ}" in
# START OF targmatch.h
@ -23,6 +23,11 @@ index 30087e3b..7658cf30 100644
+ targ_selvecs=
+ targ64_selvecs=
+ ;;
+ aarch64-*-serenity*)
+ targ_defvec=aarch64_elf64_le_vec
+ targ_selvecs=
+ want64=true
+ ;;
+
aarch64-*-darwin*)
targ_defvec=aarch64_mach_o_vec
@ -40,15 +45,16 @@ index 7384e919..aa02c3f6 100755
| hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \
| sym* | plan9* | psp* | sim* | xray* | os68k* | v88r* \
diff --git a/gas/configure.tgt b/gas/configure.tgt
index 338892ad..0cac7829 100644
index 338892ad..3c03ee8b 100644
--- a/gas/configure.tgt
+++ b/gas/configure.tgt
@@ -123,6 +123,8 @@ esac
@@ -123,6 +123,9 @@ esac
generic_target=${cpu_type}-$vendor-$os
# Note: This table is alpha-sorted, please try to keep it that way.
case ${generic_target} in
+ i386-*-serenity*) fmt=elf;;
+ arm-*-serenity*) fmt=elf;;
+ aarch64-*-serenity*) fmt=elf;;
aarch64*-*-elf*) fmt=elf;;
aarch64*-*-fuchsia*) fmt=elf;;
aarch64*-*-genode*) fmt=elf;;
@ -93,10 +99,10 @@ index ef2e99e0..657d24a2 100644
ei386pep.c \
emmo.c
diff --git a/ld/configure.tgt b/ld/configure.tgt
index 6205d7c9..390c10d7 100644
index 6205d7c9..00d97c37 100644
--- a/ld/configure.tgt
+++ b/ld/configure.tgt
@@ -43,6 +43,19 @@ targ64_extra_libpath=
@@ -43,6 +43,23 @@ targ64_extra_libpath=
# Please try to keep this table more or less in alphabetic order - it
# makes it much easier to lookup a specific archictecture.
case "${targ}" in
@ -112,6 +118,10 @@ index 6205d7c9..390c10d7 100644
+arm-*-serenity*)
+ targ_emul=armelf_serenity
+ targ_extra_emuls="armelf_serenity armelf"
+ ;;
+aarch64-*-serenity*)
+ targ_emul=aarch64elf
+ targ_extra_emuls=
+ ;;
aarch64_be-*-elf) targ_emul=aarch64elfb
targ_extra_emuls="aarch64elf aarch64elf32 aarch64elf32b armelfb armelf"
@ -129,6 +139,13 @@ index 00000000..517cd626
+
+unset STACK_ADDR
+unset EMBEDDED
diff --git a/ld/emulparams/elf_aarch64_serenity.sh b/ld/emulparams/elf_aarch64_serenity.sh
new file mode 100644
index 00000000..45a05bf4
--- /dev/null
+++ b/ld/emulparams/elf_aarch64_serenity.sh
@@ -0,0 +1 @@
+. ${srcdir}/emulparams/elf_aarch64.sh
diff --git a/ld/emulparams/elf_i386_serenity.sh b/ld/emulparams/elf_i386_serenity.sh
new file mode 100644
index 00000000..342d5298

View file

@ -46,7 +46,7 @@ index a75b44ee4..6fab7c3ca 100644
+
; This comment is to ensure we retain the blank line above.
diff --git a/gcc/config.gcc b/gcc/config.gcc
index 357b0bed0..c6c23044d 100644
index 357b0bed0..18d099584 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -686,6 +686,12 @@ x86_cpus="generic intel"
@ -62,7 +62,7 @@ index 357b0bed0..c6c23044d 100644
*-*-darwin*)
tmake_file="t-darwin "
tm_file="${tm_file} darwin.h"
@@ -1084,6 +1090,15 @@ case ${target} in
@@ -1084,6 +1090,18 @@ case ${target} in
esac
case ${target} in
@ -74,6 +74,9 @@ index 357b0bed0..c6c23044d 100644
+ ;;
+arm-*-serenity*)
+ tm_file="dbxelf.h elfos.h arm/elf.h arm/aout.h glibc-stdint.h arm/serenity-elf.h ${tm_file} serenity.h"
+ ;;
+aarch64-*-serenity*)
+ tm_file="${tm_file} dbxelf.h elfos.h aarch64/aarch64-elf.h glibc-stdint.h serenity.h"
+ ;;
aarch64*-*-elf | aarch64*-*-fuchsia* | aarch64*-*-rtems*)
tm_file="${tm_file} dbxelf.h elfos.h newlib-stdint.h"
@ -267,10 +270,10 @@ index 9b28369e3..6821ed4ba 100755
if test x$gcc_cv_target_dl_iterate_phdr = xyes; then
diff --git a/libgcc/config.host b/libgcc/config.host
index 50f000622..dc20e672a 100644
index 50f000622..fa30ef089 100644
--- a/libgcc/config.host
+++ b/libgcc/config.host
@@ -1504,6 +1504,22 @@ nvptx-*)
@@ -1504,6 +1504,30 @@ nvptx-*)
tmake_file="$tmake_file nvptx/t-nvptx"
extra_parts="crt0.o"
;;
@ -289,6 +292,14 @@ index 50f000622..dc20e672a 100644
+ tm_file="$tm_file arm/bpabi-lib.h"
+ unwind_header=config/arm/unwind-arm.h
+ extra_parts="$extra_parts crti.o crtn.o"
+ ;;
+aarch64-*-serenity*)
+ extra_parts="$extra_parts crti.o crtbegin.o crtend.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-libgcc"
+ tmake_file="$tmake_file ${cpu_type}/t-softfp t-softp t-crtfm"
+ md_unwind_header=aarch64/aarch64-unwind.h
+ ;;
*)
echo "*** Configuration ${host} not supported" 1>&2

View file

@ -35,6 +35,9 @@ struct __jmp_buf {
uint64_t rbp;
uint64_t rsp;
uint64_t rip;
#elif __aarch64__
// FIXME: This is likely incorrect.
uint64_t regs[22];
#else
# error
#endif
@ -49,6 +52,8 @@ typedef struct __jmp_buf sigjmp_buf[1];
static_assert(sizeof(struct __jmp_buf) == 32, "struct __jmp_buf unsynchronized with i386/setjmp.S");
#elif __x86_64__
static_assert(sizeof(struct __jmp_buf) == 72, "struct __jmp_buf unsynchronized with x86_64/setjmp.S");
#elif __aarch64__
static_assert(sizeof(struct __jmp_buf) == 184, "struct __jmp_buf unsynchronized with aarch64/setjmp.S");
#else
# error
#endif