Skip to content
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

Closed
tklauser opened this issue Sep 6, 2018 · 219 comments
Closed

all: port to RISC-V #27532

tklauser opened this issue Sep 6, 2018 · 219 comments
Labels
arch-riscv Issues solely affecting the riscv64 architecture. FeatureRequest FrozenDueToAge help wanted
Milestone

Comments

@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 riscvarchive/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
Copy link
Contributor

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
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
@davidlt
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.

@ghost
Copy link

ghost commented Oct 3, 2018

Thanks for raising this.

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

@ghost
Copy link

ghost 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
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
Copy link
Contributor

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
Copy link
Contributor

@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
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
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
Copy link
Member Author

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
Copy link
Contributor

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
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
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
Copy link
Contributor

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

@gopherbot
Copy link
Contributor

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

@gopherbot
Copy link
Contributor

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
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
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 Issues solely affecting the riscv64 architecture. label Feb 16, 2019
@tklauser
Copy link
Member Author

tklauser commented Feb 19, 2019

Issue for setting up a qemu-based RISC-V builder: #30262

halstead pushed a commit to openembedded/openembedded-core that referenced this issue Mar 20, 2019
Although RISC-V 64-bit doesn't have official golang support there are
forks that now exist with at least some support and work is ongoing in
the upstream tree. In order to be able to use the goarch class add
support for RISC-V.

For more details see here:
golang/go#27532

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
halstead pushed a commit to openembedded/openembedded-core that referenced this issue Mar 21, 2019
Although RISC-V 64-bit doesn't have official golang support there are
forks that now exist with at least some support and work is ongoing in
the upstream tree. In order to be able to use the goarch class add
support for RISC-V.

For more details see here:
golang/go#27532

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
jpuhlman pushed a commit to MontaVista-OpenSourceTechnology/poky that referenced this issue Mar 29, 2019
Source: poky
MR: 00000
Type: Integration
Disposition: Merged from poky
ChangeID: 2187d06
Description:

Although RISC-V 64-bit doesn't have official golang support there are
forks that now exist with at least some support and work is ongoing in
the upstream tree. In order to be able to use the goarch class add
support for RISC-V.

For more details see here:
golang/go#27532

(From OE-Core rev: 91e3b2a762124bf5cf923654ef3a7c871b84c82f)

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Signed-off-by: Jeremy Puhlman <jpuhlman@mvista.com>
@gopherbot
Copy link
Contributor

Change https://golang.org/cl/217301 mentions this issue: [release-branch.go1.14] go/analysis/passes/asmdecl: add support for riscv64

gopherbot pushed a commit to golang/sys that referenced this issue Jan 31, 2020
…syscalls

While the linux/riscv64 port is not yet upstream, most of the syscalls package
already has linux/riscv64 support and this will make testing and development
easier.

Updates golang/go#27532

Change-Id: I6e505be55fdbb2942fb6e4f34c040e7b82809630
Reviewed-on: https://go-review.googlesource.com/c/sys/+/177799
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
(cherry picked from commit 4c3a928)
Reviewed-on: https://go-review.googlesource.com/c/sys/+/217300
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
gopherbot pushed a commit to golang/sys that referenced this issue Jan 31, 2020
Updates golang/go#27532

Change-Id: I7250f272ff46f2765d498a97644fb570ae745a6c
Reviewed-on: https://go-review.googlesource.com/c/sys/+/206860
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
(cherry picked from commit 2f3576d)
Reviewed-on: https://go-review.googlesource.com/c/sys/+/217339
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
gopherbot pushed a commit to golang/tools that referenced this issue Jan 31, 2020
…iscv64

Updates golang/go#27532

Change-Id: I9598b610c0b6710644988e5cea7661b2681a0314
Reviewed-on: https://go-review.googlesource.com/c/tools/+/216337
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
(cherry picked from commit 628e9aa)
Reviewed-on: https://go-review.googlesource.com/c/tools/+/217301
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
@gopherbot
Copy link
Contributor

Change https://golang.org/cl/217359 mentions this issue: go.mod: update golang.org/x/sys to fix riscv64 build

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/211917 mentions this issue: cmd/internal/obj/riscv: rework instruction generation

@davidlt
Copy link

davidlt commented Feb 6, 2020

Would it be possible to upload rc1 binaries to the download page?

@bradfitz
Copy link
Contributor

bradfitz commented Feb 6, 2020

@davidlt, RISC-V is still considered an experimental port in Go 1.14 so we won't be providing downloads.

@aurel32
Copy link

aurel32 commented Feb 6, 2020

@davidlt It is quite easy to bootstrap golang from another architecture (e.g. amd64), see for example:
https://github.com/carlosedp/riscv-bringup/blob/master/build-golang.md

@carlosedp
Copy link

I've also built Go 1.14rc1 for riscv64 and made the tarball available on https://github.com/carlosedp/riscv-bringup/releases.

gopherbot pushed a commit that referenced this issue Mar 15, 2020
Rework instruction generation so that multiple instructions are generated
from a single obj.Prog, rather than the current approach where obj.Progs
are rewritten. This allows the original obj.Prog to remain intact, before
being converted into an architecture specific instruction form.

This simplifies the code and removes a level of indirection that results
from trying to manipulate obj.Prog.To/obj.Prog.From into forms that match
the instruction encoding. Furthermore, the errors reported make more sense
since it matches up with the actual assembly that was parsed.

Note that the CALL/JMP/JALR type sequences have not yet been migrated to
this framework and will likely be converted at a later time.

Updates #27532

Change-Id: I9fd12562ed1db0a08cfdc32793897d2a1920ebaa
Reviewed-on: https://go-review.googlesource.com/c/go/+/211917
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
gopherbot pushed a commit to golang/net that referenced this issue Mar 24, 2020
Done using:

  go get golang.org/x/sys/unix@latest
  go mod tidy

Updates golang/go#27532

Change-Id: Ibb984f35d969b4f93a492f24560bc957f9dafb65
Reviewed-on: https://go-review.googlesource.com/c/net/+/217359
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
@4a6f656c
Copy link
Contributor

@dmitshur - is there anything preventing this issue from being closed?

@marcopeereboom
Copy link

cgo support :)

@tklauser
Copy link
Member Author

cgo support for riscv is tracked in #36641

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/240377 mentions this issue: doc: add riscv64 to ports list

gopherbot pushed a commit that referenced this issue Jul 1, 2020
Mention support for the 64-bit RISC-V instruction set (GOARCH=riscv64)
in the "Installing Go from source" document. Also sort the list of
supported instruction sets alphabetically.

Updates #27532

Change-Id: I07a443044a41a803853978dd7f7446de89ecceb5
Reviewed-on: https://go-review.googlesource.com/c/go/+/240377
Reviewed-by: Alberto Donizetti <alb.donizetti@gmail.com>
@advancedwebdeveloper
Copy link

Anyone having a a desire to support RISC-V for https://go.googlesource.com/gollvm/ ?

xhit added a commit to xhit/go that referenced this issue Aug 27, 2020
Mention valid combination GOOS=linux and GOARCH=riscv64
in the "Installing Go from source" document.

Updates golang#27532
@gopherbot
Copy link
Contributor

Change https://golang.org/cl/250997 mentions this issue: doc: add linux/riscv64 valid combination

gopherbot pushed a commit that referenced this issue Aug 28, 2020
Mention valid combination GOOS=linux and GOARCH=riscv64
in the "Installing Go from source" document.

Updates #27532

Change-Id: I8c1406087132f5c82a2eee5dbcda95d53c64d263
GitHub-Last-Rev: ee74ff9
GitHub-Pull-Request: #41063
Reviewed-on: https://go-review.googlesource.com/c/go/+/250997
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
@tklauser
Copy link
Member Author

Experimental support was added in Go 1.14 and Go 1.15 improved stability and performance. Support for cgo on linux/riscv64 is tracked in #36641.

Thus, I'm considering basic support for RISC-V to be done and am closing this issue. Let's open separate, specific issues for any further development (e.g. gollvm support) and improvements.

Thanks everybody for contributing!

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/257917 mentions this issue: dashboard: add linux-riscv64-jsing builder (reverse)

gopherbot pushed a commit to golang/build that referenced this issue Oct 16, 2020
Also use this as the riscv64 slowbot, since linux-riscv64-unleashed has
been MIA for quite some time.

For golang/go#27532

Change-Id: I01309a66b96d4c35dbc9d1e08f55f5357b0acba0
Reviewed-on: https://go-review.googlesource.com/c/build/+/257917
Trust: Joel Sing <joel@sing.id.au>
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
@golang golang locked and limited conversation to collaborators Oct 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-riscv Issues solely affecting the riscv64 architecture. FeatureRequest FrozenDueToAge help wanted
Projects
None yet
Development

No branches or pull requests