public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH v2] RISC-V: Support for FreeBSD
@ 2018-02-18  3:08 Kito Cheng
  2018-02-20 21:26 ` Jim Wilson
  0 siblings, 1 reply; 6+ messages in thread
From: Kito Cheng @ 2018-02-18  3:08 UTC (permalink / raw)
  To: gcc-patches, Jim Wilson, Ruslan Bukin, Ruslan Bukin
  Cc: Li-Wen Hsu, Palmer Dabbelt, Andrew Waterman

[-- Attachment #1: Type: text/plain, Size: 1000 bytes --]

Hi all:

This patch is version 2 of FreeBSD supporting for RISC-V, Ruslan
(RISC-V FreeBSD maintainer) and me has been tested on FreeBSD 12
for building kernel and whole user space programs/libraries again :)


Hi Jim:

Ruslan and me just decide upstream GCC part only this time since
binutils need more work (mostly for ELF header info), but it's not
affect the correctness.

Changes since v1[1]:
- Remove dbxelf.h.
- Correct the copyright year info.
- Fix libgcc/config.host for riscv*-*-freebsd*.

Copyright part, Ruslan has sent to fsf-records@gnu.org but no echo,
I've forward that to assign@gnu.org again.


gcc/ChangeLog

2018-01-29  Ruslan Bukin  <br@bsdpad.com>
                    Kito Cheng  <kito.cheng@gmail.com>

        * config.gcc (riscv*-*-freebsd*): New.
        * config/riscv/freebsd.h: New.

libgcc/ChangeLog

2018-01-29  Ruslan Bukin  <br@bsdpad.com>

        * libgcc/config.host: Support RISC-V FreeBSD.

[1] V1 patch: https://gcc.gnu.org/ml/gcc-patches/2018-01/msg02235.html

[-- Attachment #2: 0001-RISC-V-Add-support-for-FreeBSD.patch --]
[-- Type: text/x-patch, Size: 4145 bytes --]

From 13781768c4f71eb83505f0d579de37d5f861ac7c Mon Sep 17 00:00:00 2001
From: Ruslan Bukin <br@bsdpad.com>
Date: Wed, 3 Jan 2018 15:59:04 +0000
Subject: [PATCH] RISC-V: Add support for FreeBSD

gcc/ChangeLog

2018-02-18  Ruslan Bukin  <br@bsdpad.com>
	    Kito Cheng  <kito.cheng@gmail.com>

	* config.gcc (riscv*-*-freebsd*): New.
	* config/riscv/freebsd.h: New.

libgcc/ChangeLog

2018-02-18  Ruslan Bukin  <br@bsdpad.com>

	* libgcc/config.host: Support RISC-V FreeBSD.
---
 gcc/config.gcc             |  9 ++++++++
 gcc/config/riscv/freebsd.h | 54 ++++++++++++++++++++++++++++++++++++++++++++++
 libgcc/config.host         |  4 ++++
 3 files changed, 67 insertions(+)
 create mode 100644 gcc/config/riscv/freebsd.h

diff --git a/gcc/config.gcc b/gcc/config.gcc
index c52fecf..01b5a92 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -2086,6 +2086,15 @@ riscv*-*-elf* | riscv*-*-rtems*)
 	  ;;
 	esac
 	;;
+riscv*-*-freebsd*)
+	tm_file="${tm_file} elfos.h ${fbsd_tm_file} riscv/freebsd.h"
+	tmake_file="${tmake_file} riscv/t-riscv"
+	gnu_ld=yes
+	gas=yes
+	# Force .init_array support.  The configure script cannot always
+	# automatically detect that GAS supports it, yet we require it.
+	gcc_cv_initfini_array=yes
+	;;
 mips*-*-netbsd*)			# NetBSD/mips, either endian.
 	target_cpu_default="MASK_ABICALLS"
 	tm_file="elfos.h ${tm_file} mips/elf.h ${nbsd_tm_file} mips/netbsd.h"
diff --git a/gcc/config/riscv/freebsd.h b/gcc/config/riscv/freebsd.h
new file mode 100644
index 0000000..019b22f
--- /dev/null
+++ b/gcc/config/riscv/freebsd.h
@@ -0,0 +1,54 @@
+/* Definitions for RISC-V FreeBSD systems with ELF format.
+   Copyright (C) 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/>.  */
+
+#undef WCHAR_TYPE
+#define WCHAR_TYPE "int"
+
+#undef WCHAR_TYPE_SIZE
+#define WCHAR_TYPE_SIZE 32
+
+#undef  SUBTARGET_EXTRA_SPECS
+#define SUBTARGET_EXTRA_SPECS \
+  { "fbsd_dynamic_linker", FBSD_DYNAMIC_LINKER }
+
+#undef CC1_SPEC
+#define CC1_SPEC "%(cc1_cpu) %{profile:-p}"
+
+/* Provide a LINK_SPEC appropriate for FreeBSD.  Here we provide support
+   for the special GCC options -static and -shared, which allow us to
+   link things in one of these three modes by applying the appropriate
+   combinations of options at link-time.
+
+   When the -shared link option is used a final link is not being
+   done.  */
+
+#undef LINK_SPEC
+#define LINK_SPEC "						\
+  -melf" XLEN_SPEC "lriscv					\
+  %{p:%nconsider using `-pg' instead of `-p' with gprof (1) }	\
+  %{v:-V}							\
+  %{assert*} %{R*} %{rpath*} %{defsym*}				\
+  %{shared:-Bshareable %{h*} %{soname*}}			\
+  %{symbolic:-Bsymbolic}					\
+  %{static:-Bstatic}						\
+  %{!shared:							\
+      %{!static:						\
+        %{rdynamic:-export-dynamic}				\
+        -dynamic-linker " FBSD_DYNAMIC_LINKER "}		\
+        %{static:-static}}"
diff --git a/libgcc/config.host b/libgcc/config.host
index 96d55a4..11b4aca 100644
--- a/libgcc/config.host
+++ b/libgcc/config.host
@@ -1128,6 +1128,10 @@ riscv*-*-linux*)
 	extra_parts="$extra_parts crtbegin.o crtend.o crti.o crtn.o crtendS.o crtbeginT.o"
 	md_unwind_header=riscv/linux-unwind.h
 	;;
+riscv*-*-freebsd*)
+	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 crtendS.o crtbeginT.o"
+	;;
 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"
-- 
2.7.4


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-04-06 20:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-18  3:08 [PATCH v2] RISC-V: Support for FreeBSD Kito Cheng
2018-02-20 21:26 ` Jim Wilson
2018-02-22  6:35   ` Kito Cheng
2018-02-22 18:33     ` Jim Wilson
2018-04-06  3:48       ` Kito Cheng
2018-04-06 20:07         ` Jim Wilson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).