⛏️ index : buildtools.git

author Jaroslaw Pelczar <jarek@jpelczar.com> 2019-08-30 19:33:02.0 +02:00:00
committer waddlesplash <waddlesplash@gmail.com> 2019-09-01 3:06:22.0 +00:00:00
commit
e4426fc38a49e3b9f8ef350663717a8caef4d6c8 [patch]
tree
264e8631d4a82e4cae496185680dcef7fe8262d5
parent
e97614541b06f8d188c98c790435f42fd974999b
download
e4426fc38a49e3b9f8ef350663717a8caef4d6c8.tar.gz

gcc: Add initial support for AArch64 Haiku

Signed-off-by: Jaroslaw Pelczar <jarek@jpelczar.com>
Change-Id: I8bd362b61ded01ae1b15d0a999d0db947204aeb7
Reviewed-on: https://review.haiku-os.org/c/buildtools/+/1797
Reviewed-by: waddlesplash <waddlesplash@gmail.com>

Diff

 gcc/gcc/config.gcc                       |  5 +++++
 gcc/libgcc/config.host                   |  5 +++++
 gcc/gcc/config/aarch64/aarch64-haiku.h   | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 gcc/gcc/config/aarch64/t-aarch64-haiku   | 21 +++++++++++++++++++++
 gcc/libgcc/config/aarch64/haiku-unwind.h | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 176 insertions(+)

diff --git a/gcc/gcc/config.gcc b/gcc/gcc/config.gcc
index 80309f6..33f7bba 100644
--- a/gcc/gcc/config.gcc
+++ a/gcc/gcc/config.gcc
@@ -993,6 +993,11 @@
	tm_file="${tm_file} aarch64/aarch64-elf.h aarch64/aarch64-freebsd.h"
	tmake_file="${tmake_file} aarch64/t-aarch64 aarch64/t-aarch64-freebsd"
	;;
aarch64*-*-haiku*)
	tm_file="${tm_file} dbxelf.h elfos.h haiku.h haiku-stdint.h"
	tm_file="${tm_file} aarch64/aarch64-elf.h aarch64/aarch64-haiku.h"
	tmake_file="${tmake_file} t-haiku aarch64/t-aarch64 aarch64/t-aarch64-haiku"
	;;
aarch64*-*-linux*)
	tm_file="${tm_file} dbxelf.h elfos.h gnu-user.h linux.h glibc-stdint.h"
	tm_file="${tm_file} aarch64/aarch64-elf.h aarch64/aarch64-linux.h"
diff --git a/gcc/libgcc/config.host b/gcc/libgcc/config.host
index fe2c056..0c8d424 100644
--- a/gcc/libgcc/config.host
+++ a/gcc/libgcc/config.host
@@ -354,6 +354,11 @@
	tmake_file="${tmake_file} ${cpu_type}/t-aarch64"
	tmake_file="${tmake_file} ${cpu_type}/t-softfp t-softfp"
	;;
aarch64*-*-haiku*)
	tmake_file="${tmake_file} ${cpu_type}/t-aarch64"
	tmake_file="${tmake_file} ${cpu_type}/t-softfp t-softfp"
	md_unwind_header=aarch64/haiku-unwind.h
	;;
aarch64*-*-linux*)
	extra_parts="$extra_parts crtfastmath.o"
	md_unwind_header=aarch64/linux-unwind.h
diff --git a/gcc/gcc/config/aarch64/aarch64-haiku.h b/gcc/gcc/config/aarch64/aarch64-haiku.h
new file mode 100644
index 0000000..1d49930 100644
--- /dev/null
+++ a/gcc/gcc/config/aarch64/aarch64-haiku.h
@@ -1,0 +1,94 @@
/* Machine description for AArch64 architecture.
   Copyright (C) 2009-2018 Free Software Foundation, Inc.
   Contributed by ARM Ltd.
   Updated for Haiku by Jaroslaw Pelczar <jarek@jpelczar.com>

   This file is part of GCC.

   GCC is free software; you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3, or (at your option)
   any later version.

   GCC is distributed in the hope that it will be useful, but
   WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with GCC; see the file COPYING3.  If not see
   <http://www.gnu.org/licenses/>.  */

#ifndef GCC_AARCH64_HAIKU_H
#define GCC_AARCH64_HAIKU_H

#define HAIKU_DYNAMIC_LINKER		"/system/runtime_loader"

#define CPP_SPEC "%{pthread:-D_REENTRANT}"

#if TARGET_BIG_ENDIAN_DEFAULT

#define TARGET_LINKER_EMULATION  "aarch64haikub"
#else
#define TARGET_LINKER_EMULATION  "aarch64haiku"
#endif

#undef  SUBTARGET_EXTRA_LINK_SPEC
#define SUBTARGET_EXTRA_LINK_SPEC " -m" TARGET_LINKER_EMULATION

#undef  HAIKU_TARGET_LINK_SPEC
#define HAIKU_TARGET_LINK_SPEC "                                 \
    %{p:%nconsider using `-pg' instead of `-p' with gprof (1) } \
    %{v:-V}                                                     \
    %{assert*} %{R*} %{rpath*} %{defsym*}                       \
    %{shared:-Bshareable %{h*} %{soname*}}                      \
    %{symbolic:-Bsymbolic}                                      \
    %{static:-Bstatic}                                          \
    %{!static:                                                  \
      %{rdynamic:-export-dynamic}                               \
      %{!shared:-dynamic-linker " HAIKU_DYNAMIC_LINKER " }}     \
    -X" SUBTARGET_EXTRA_LINK_SPEC "                             \
    %{mbig-endian:-EB} %{mlittle-endian:-EL}"

#if TARGET_FIX_ERR_A53_835769_DEFAULT

#define CA53_ERR_835769_SPEC \
  " %{!mno-fix-cortex-a53-835769:--fix-cortex-a53-835769}"
#else
#define CA53_ERR_835769_SPEC \
  " %{mfix-cortex-a53-835769:--fix-cortex-a53-835769}"
#endif

#if TARGET_FIX_ERR_A53_843419_DEFAULT

#define CA53_ERR_843419_SPEC \
  " %{!mno-fix-cortex-a53-843419:--fix-cortex-a53-843419}"
#else
#define CA53_ERR_843419_SPEC \
  " %{mfix-cortex-a53-843419:--fix-cortex-a53-843419}"
#endif

#define LINK_SPEC HAIKU_TARGET_LINK_SPEC \
                  CA53_ERR_835769_SPEC \
                  CA53_ERR_843419_SPEC

#define TARGET_OS_CPP_BUILTINS()		\
  do									\
    {									\
	builtin_define ("__HAIKU__");					\
	builtin_define ("__stdcall=__attribute__((__stdcall__))");	\
	builtin_define ("__cdecl=__attribute__((__cdecl__))");		\
    builtin_define ("__STDC_ISO_10646__=201103L"); \
	builtin_assert ("system=haiku");					\
    }									\
  while (0)

#define TARGET_ASM_FILE_END file_end_indicate_exec_stack

/* Uninitialized common symbols in non-PIE executables, even with
   strong definitions in dependent shared libraries, will resolve
   to COPY relocated symbol in the executable.  See PR65780.  */
#undef TARGET_BINDS_LOCAL_P
#define TARGET_BINDS_LOCAL_P default_binds_local_p_2

/* Define this to be nonzero if static stack checking is supported.  */
#define STACK_CHECK_STATIC_BUILTIN 1

#endif  /* GCC_AARCH64_HAIKU_H */
diff --git a/gcc/gcc/config/aarch64/t-aarch64-haiku b/gcc/gcc/config/aarch64/t-aarch64-haiku
new file mode 100644
index 0000000..99d3dea 100644
--- /dev/null
+++ a/gcc/gcc/config/aarch64/t-aarch64-haiku
@@ -1,0 +1,21 @@
# Machine description for AArch64 architecture.
#  Copyright (C) 2016-2018 Free Software Foundation, Inc.
#
#  This file is part of GCC.
#
#  GCC is free software; you can redistribute it and/or modify it
#  under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 3, or (at your option)
#  any later version.
#
#  GCC is distributed in the hope that it will be useful, but
#  WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
#  General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with GCC; see the file COPYING3.  If not see
#  <http://www.gnu.org/licenses/>.

LIB1ASMSRC   = aarch64/lib1funcs.asm
LIB1ASMFUNCS = _aarch64_sync_cache_range
diff --git a/gcc/libgcc/config/aarch64/haiku-unwind.h b/gcc/libgcc/config/aarch64/haiku-unwind.h
new file mode 100644
index 0000000..3c8d33d 100644
--- /dev/null
+++ a/gcc/libgcc/config/aarch64/haiku-unwind.h
@@ -1,0 +1,51 @@
/* DWARF2 EH unwinding support for FreeBSD/ARM64 (aarch64).
   Copyright (C) 2017-2018 Free Software Foundation, Inc.
   Contributed by John Marino <gnugcc@marino.st>

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.

GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.

You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
<http://www.gnu.org/licenses/>.  */

/* Identify a signal frame, and set the frame state data appropriately.
   See unwind-dw2.c for the structs. */

/* Always include AArch64 unwinder header file.  */
#include "config/aarch64/aarch64-unwind.h"

#include <sys/types.h>
#include <signal.h>
#include <unistd.h>
#include <signal.h>

#define REG_NAME(reg)   mc_gpregs.gp_## reg
#define XREG(num)       mc_gpregs.gp_x[num]
#define DARC            __LIBGCC_DWARF_ALT_FRAME_RETURN_COLUMN__

#define MD_FALLBACK_FRAME_STATE_FOR aarch64_haiku_fallback_frame_state

static _Unwind_Reason_Code
aarch64_haiku_fallback_frame_state
(struct _Unwind_Context *context, _Unwind_FrameState *fs)
{
  // For now just signal end of stack. Once the Haiku implementation
  // for AArch64 is more mature we can consider writing something similar
  // to Linux or FreeBSD support.
  return _URC_END_OF_STACK;
}