New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

all: port to RISC-V #27532

Open
tklauser opened this Issue Sep 6, 2018 · 16 comments

Comments

Projects
None yet
9 participants
@tklauser
Copy link
Member

tklauser commented Sep 6, 2018

This issue serves to track the port to the RISC-V architecture. There is an out-of-tree port at https://github.com/riscv/riscv-go based on Go 1.8 which - according to riscv/riscv-go#19 - is no longer maintained and would need quite some work to be updated to the current Go tip.

Also see https://golang.org/cl/106256#message-2d9a5c5b89ad55b8b7999f794983f993649232c8 and https://groups.google.com/forum/#!searchin/golang-dev/RISC%7Csort:date/golang-dev/VpsyGdi-sQQ/FMu6IB_2CwAJ where @josharian summarized the current state of the existing port.

The GOARCH values riscv and riscv64 were reserved in https://golang.org/cl/106256. These values are already used by gccgo. Additional changes were made to debug/elf (https://golang.org/cl/107339), cmd/cgo (https://golang.org/cl/110066), cmd/dist and cmd/types (https://golang.org/cl/118618) in order be able to generate type definition files in the x/sys/unix package (https://golang.org/cl/133735).

/cc @bradfitz @ianlancetaylor @josharian

@gopherbot

This comment has been minimized.

Copy link

gopherbot commented Sep 6, 2018

Change https://golang.org/cl/133735 mentions this issue: unix: add support for linux/riscv64

gopherbot pushed a commit to golang/sys that referenced this issue Sep 6, 2018

unix: add support for linux/riscv64
Add syscall wrappers, error constants and types for linux/riscv64

Switch docker image to Ubuntu 18.10 in order to get qemu supporting
riscv64. Also set the uname release string for qemu to 4.15 (the first
Linux kernel version with riscv64 support), because otherwise running
the generating C program in mkerrors.sh on a host with an older kernel
would fail with a "FATAL: kernel too old".

Note that linux/riscv64 is currently only usable using gccgo.

Updates golang/go#27532

Change-Id: Ic420f842342418443474cac72d38adff14d1b938
Reviewed-on: https://go-review.googlesource.com/133735
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>

@bradfitz bradfitz added this to the Unplanned milestone Sep 6, 2018

@bradfitz bradfitz added the help wanted label Sep 6, 2018

@davidlt

This comment has been minimized.

Copy link

davidlt commented Sep 16, 2018

/cc myself as Fedora/RISC-V maintainer.

I would be happy to incl. this into the distribution (once it compiles) and do some testing.

@gedw99

This comment has been minimized.

Copy link

gedw99 commented Oct 3, 2018

Thanks for raising this.

Does anyone know where I can get hardware to test on ?

@gedw99

This comment has been minimized.

Copy link

gedw99 commented Oct 3, 2018

New house, CPU and fgpa efforts are going on using risc-v.
Quite a turning point and opportunity for golang programmers.

Here is the main news feed on all of it:
https://riscv.org/news/

@junland

This comment has been minimized.

Copy link

junland commented Oct 3, 2018

@gedw99 At the moment SiFive is the only company that has produced a RISC-V dev board (HiFive Unleashed). One caveat to this board is the price, which is around $1,000 USD.

@hugelgupf

This comment has been minimized.

Copy link
Contributor

hugelgupf commented Oct 16, 2018

cc @GanShun and @rjoleary the three of us were also about to start looking at a port. We got a couple of SiFive boards to try it out on.

@bradfitz

This comment has been minimized.

Copy link
Member

bradfitz commented Oct 16, 2018

@hugelgupf, when you're far enough along to want a builder set up, file a bug and copy me and I'd be more than happy to help.

@jasonmoo

This comment has been minimized.

Copy link

jasonmoo commented Oct 17, 2018

I recently starting using qemu to run a riscv fedora build. Here are the links in case it's useful for devving without a board.

https://github.com/riscv/riscv-qemu
https://fedoraproject.org/wiki/Architectures/RISC-V/Installing#Download_the_latest_disk_image
https://fedoraproject.org/wiki/Architectures/RISC-V/Installing#Boot_under_qemu

Using dnf install gccgo I've been able to build and run go apps in emulation.

@davidlt

This comment has been minimized.

Copy link

davidlt commented Oct 17, 2018

Just reminder that RISC-V is supported in released versions of QEMU and libvirt, which makes it easy to setup multiple VMs with management. See: https://fedoraproject.org/wiki/Architectures/RISC-V/Installing#Boot_with_libvirt

Note, that our libffi does not support Go closures thus some functionality does not work. The patch exist already, but I need to backport it to our libffi version. Should I bump priority on this?

@tklauser

This comment has been minimized.

Copy link
Member Author

tklauser commented Nov 22, 2018

FWIW, I started rebasing the Go 1.18-based https://github.com/riscv/go-riscv to current Go tip at https://github.com/tklauser/go-riscv. It currently builds on linux/amd64 but cannot generate valid riscv64 binaries yet.

I currently lack the time and resources to really push it forward but maybe someone else working on it might find it useful.

@bradfitz

This comment has been minimized.

Copy link
Member

bradfitz commented Dec 13, 2018

Just saw that you can apparently run RISC-V in the cloud via an FPGA AWS instance:

https://www.cnx-software.com/2017/02/22/amazon-ec2-f1-instances-put-xilinx-virtex-ultrascale-fpga-boards-in-the-cloud/

That might be a possible temporary builder strategy.

@jasonmoo

This comment has been minimized.

Copy link

jasonmoo commented Dec 14, 2018

@bradfitz https://fires.im/ is a risc-v deployment on aws fpgas but the underlying risc-v implementation only runs up to something like 100mhz. Working with a team that's doing some research in that area and it seems to be the norm. So far emulation has been the most performant by far.

@davidlt

This comment has been minimized.

Copy link

davidlt commented Dec 14, 2018

QEMU supports up to 8 cores (MTTCG - multi-threaded TCG), which is great if you can compile in parallel.

Alternatively contact Palmer Dabbelt from SiFive and ask for a free SiFive HiFive Unleashed board (multiple projects have received one for porting efforts).

@gopherbot

This comment has been minimized.

Copy link

gopherbot commented Jan 16, 2019

Change https://golang.org/cl/157899 mentions this issue: unix: use Renameat2 to implement Renameat on linux/riscv64

@gopherbot

This comment has been minimized.

Copy link

gopherbot commented Jan 16, 2019

Change https://golang.org/cl/157900 mentions this issue: unix: use int8 for RawSockaddrUnix.Path on linux/riscv64

@gopherbot

This comment has been minimized.

Copy link

gopherbot commented Jan 16, 2019

Change https://golang.org/cl/157901 mentions this issue: unix: add assembly for riscv64 syscalls

gopherbot pushed a commit to golang/sys that referenced this issue Jan 16, 2019

unix: use Renameat2 to implement Renameat on linux/riscv64
On linux/riscv64, the renameat syscall no longer exists and has been
superseded by renameat2. Use Renameat2 to implement Renameat on
linux/riscv64.

Based on a patch by Ryan O'Leary.

Updates golang/go#27532

Change-Id: I7c60c7f824750408265f67397b8ac1fa7226f425
Reviewed-on: https://go-review.googlesource.com/c/157899
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>

gopherbot pushed a commit to golang/sys that referenced this issue Jan 16, 2019

unix: use int8 for RawSockaddrUnix.Path on linux/riscv64
On linux/riscv64, char defaults to unsigned, so explicitly make
RawSockaddrUnix.Path signed.

Patch by Ryan O'Leary.

Updates golang/go#27532

Change-Id: If99a3953462ad98f61d8fafcda3ebb71b44e6018
Reviewed-on: https://go-review.googlesource.com/c/157900
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>

@bradfitz bradfitz added the arch-riscv label Feb 16, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment