From abcbee7bbace3ae5b6df384e879a0d1d24808476 Mon Sep 17 00:00:00 2001 From: Alexander von Gluck IV Date: Sat, 16 Feb 2019 19:48:08 -0600 Subject: [PATCH] haiku: Add riscv arch support Change-Id: Ifa5b93cb959798d74ed045f53f5050651f409314 Reviewed-on: https://review.haiku-os.org/c/1062 Reviewed-by: Alex von Gluck IV Reviewed-by: Adrien Destugues --- gcc/gcc/config.gcc | 4 +++ gcc/gcc/config/riscv/haiku.h | 54 ++++++++++++++++++++++++++++++++++++ gcc/gcc/config/riscv/t-haiku | 3 ++ 3 files changed, 61 insertions(+) create mode 100644 gcc/gcc/config/riscv/haiku.h create mode 100644 gcc/gcc/config/riscv/t-haiku diff --git a/gcc/gcc/config.gcc b/gcc/gcc/config.gcc index 071b671730..24df8eebd8 100644 --- a/gcc/gcc/config.gcc +++ b/gcc/gcc/config.gcc @@ -2068,6 +2068,10 @@ microblaze*-*-elf) 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 0000000000..b3568e98ff --- /dev/null +++ b/gcc/gcc/config/riscv/haiku.h @@ -0,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 +. */ + +#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 0000000000..216d2776a1 --- /dev/null +++ b/gcc/gcc/config/riscv/t-haiku @@ -0,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))