⛏️ index : buildtools.git

author Alexander von Gluck IV <kallisti5@unixzen.com> 2019-02-16 19:48:08.0 -06:00:00
committer Alex von Gluck IV <kallisti5@unixzen.com> 2019-02-21 1:32:48.0 +00:00:00
commit
abcbee7bbace3ae5b6df384e879a0d1d24808476 [patch]
tree
46dee1533cf4c70d17a0254cf8778834e217a0c0
parent
198e0fde5e533da0b2187c71abecb3e6cb1e1adf
download
abcbee7bbace3ae5b6df384e879a0d1d24808476.tar.gz

haiku: Add riscv arch support

Change-Id: Ifa5b93cb959798d74ed045f53f5050651f409314
Reviewed-on: https://review.haiku-os.org/c/1062
Reviewed-by: Alex von Gluck IV <kallisti5@unixzen.com>
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>

Diff

 gcc/gcc/config.gcc           |  4 ++++
 gcc/gcc/config/riscv/haiku.h | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 gcc/gcc/config/riscv/t-haiku |  3 +++
 3 files changed, 61 insertions(+)

diff --git a/gcc/gcc/config.gcc b/gcc/gcc/config.gcc
index 071b671..24df8ee 100644
--- a/gcc/gcc/config.gcc
+++ a/gcc/gcc/config.gcc
@@ -2068,6 +2068,10 @@
	cxx_target_objs="${cxx_target_objs} microblaze-c.o"
	tmake_file="${tmake_file} microblaze/t-microblaze"
        ;;
riscv*-*-haiku*)
	tm_file="elfos.h haiku.h ${tm_file} riscv/haiku.h"
	tmake_file="${tmake_file} t-haiku riscv/t-riscv riscv/t-haiku"
	;;
riscv*-*-linux*)
	tm_file="elfos.h gnu-user.h linux.h glibc-stdint.h ${tm_file} riscv/linux.h"
	case "x${enable_multilib}" in
diff --git a/gcc/gcc/config/riscv/haiku.h b/gcc/gcc/config/riscv/haiku.h
new file mode 100644
index 0000000..b3568e9 100644
--- /dev/null
+++ a/gcc/gcc/config/riscv/haiku.h
@@ -1,0 +1,54 @@
/* Definitions for RISC-V Haiku systems with ELF format.
   Copyright (C) 1998-2017 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/>.  */

#undef TARGET_OS_CPP_BUILTINS
#define TARGET_OS_CPP_BUILTINS()		\
  do									\
    {									\
      builtin_define ("__HAIKU__");					\
      if (POINTER_SIZE == 64)						\
        builtin_define ("__riscv64__");				\
      else											\
        builtin_define ("__riscv32__");				\
      builtin_define ("__RISCV__");					\
      builtin_define ("__riscv__");					\
      builtin_define ("__stdcall=__attribute__((__stdcall__))");	\
      builtin_define ("__cdecl=__attribute__((__cdecl__))");		\
      builtin_define ("__STDC_ISO_10646__=201103L"); \
      builtin_assert ("system=haiku");					\
    }									\
  while (0)

#define MUSL_ABI_SUFFIX \
  "%{mabi=ilp32:-sf}" \
  "%{mabi=ilp32f:-sp}" \
  "%{mabi=ilp32d:}" \
  "%{mabi=lp64:-sf}" \
  "%{mabi=lp64f:-sp}" \
  "%{mabi=lp64d:}" \

/* Because RISC-V only has word-sized atomics, it requries libatomic where
   others do not.  So link libatomic by default, as needed.  */
#undef LIB_SPEC
#define LIB_SPEC " -lroot -latomic "

#define ICACHE_FLUSH_FUNC "__riscv_flush_icache"

#undef	LINK_SPEC
#define LINK_SPEC "%{!o*:-o %b} -melf" XLEN_SPEC "lriscv %{!r:-shared} %{nostart:-e 0} %{shared:-e 0} %{!shared: %{!nostart: -no-undefined}} -X"
diff --git a/gcc/gcc/config/riscv/t-haiku b/gcc/gcc/config/riscv/t-haiku
new file mode 100644
index 0000000..216d277 100644
--- /dev/null
+++ a/gcc/gcc/config/riscv/t-haiku
@@ -1,0 +1,3 @@
# Only XLEN and ABI affect Linux multilib dir names, e.g. /lib32/ilp32d/
MULTILIB_DIRNAMES := $(patsubst rv32%,lib32,$(patsubst rv64%,lib64,$(MULTILIB_DIRNAMES)))
MULTILIB_OSDIRNAMES := $(patsubst lib%,../lib%,$(MULTILIB_DIRNAMES))