[v2] RISC-V: Support for FreeBSD

Message ID CA+yXCZCEh4c_8pFP2=ERtL7K1XNShqtWvPxjccNf9NEr=QZ94Q@mail.gmail.com
State New
Headers show
Series
  • [v2] RISC-V: Support for FreeBSD
Related show

Commit Message

Kito Cheng Feb. 18, 2018, 3:08 a.m.
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

Comments

Jim Wilson Feb. 20, 2018, 9:26 p.m. | #1
On Sat, Feb 17, 2018 at 7:08 PM, Kito Cheng <kito.cheng@gmail.com> wrote:
> 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 :)


This looks OK.

> Copyright part, Ruslan has sent to fsf-records@gnu.org but no echo,

> I've forward that to assign@gnu.org again.


I saw the email.  I checked the FSF copyright list and see that it
hasn't been recorded yet.  The FSF copyright clerk sometimes takes a
few weeks to respond.  Hopefully this will be competed on the FSF side
soon.

Jim
Kito Cheng Feb. 22, 2018, 6:34 a.m. | #2
Hi Jim:

> I saw the email.  I checked the FSF copyright list and see that it

> hasn't been recorded yet.  The FSF copyright clerk sometimes takes a

> few weeks to respond.  Hopefully this will be competed on the FSF side

> soon.


I don't family with copyright matters, so we can't commit this patch yet
until Ruslan send the signed copy and FSF signed it? right?

thanks :)
Jim Wilson Feb. 22, 2018, 6:33 p.m. | #3
On Wed, Feb 21, 2018 at 10:34 PM, Kito Cheng <kito.cheng@gmail.com> wrote:
> I don't family with copyright matters, so we can't commit this patch yet

> until Ruslan send the signed copy and FSF signed it? right?


Yes, I'd prefer that the FSF sign it and add it to the copyright list
before we commit the patch.

Jim
Kito Cheng April 6, 2018, 3:48 a.m. | #4
Hi Jim:

Theodore Teah sent an mail say "Your assignment/disclaimer process
with the FSF is currently complete.".

Could you help us to commit that?

Thanks :)

On Fri, Feb 23, 2018 at 2:33 AM, Jim Wilson <jimw@sifive.com> wrote:
> On Wed, Feb 21, 2018 at 10:34 PM, Kito Cheng <kito.cheng@gmail.com> wrote:

>> I don't family with copyright matters, so we can't commit this patch yet

>> until Ruslan send the signed copy and FSF signed it? right?

>

> Yes, I'd prefer that the FSF sign it and add it to the copyright list

> before we commit the patch.

>

> Jim
Jim Wilson April 6, 2018, 8:07 p.m. | #5
On Thu, Apr 5, 2018 at 8:48 PM, Kito Cheng <kito.cheng@gmail.com> wrote:
> Theodore Teah sent an mail say "Your assignment/disclaimer process

> with the FSF is currently complete.".

>

> Could you help us to commit that?


Committed.  With some riscv{32,64}-{elf,linux,freebsd} cross compiler
build tests, to make sure the patch is still OK with current sources.

I also noticed that Nathan Sidwell accidentally truncated the
copyright message at the end of the gcc/ChangeLog file back on March
21, and I committed a fix for that too.

Jim

Patch

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