elves / elvish

Powerful scripting language & versatile interactive shell
https://elv.sh/
BSD 2-Clause "Simplified" License
5.65k stars 299 forks source link

RISC-V binaries #1811

Closed IngwiePhoenix closed 3 months ago

IngwiePhoenix commented 4 months ago

What new feature should Elvish have?

I just built Elvish on my VisionFive2 - and by verbatin this works out perfectly!

root@riscboi ~# go install src.elv.sh/cmd/elvish@latest
go: downloading src.elv.sh v0.20.1
go: downloading pkg.nimblebun.works/go-lsp v1.1.0
go: downloading github.com/sourcegraph/jsonrpc2 v0.2.0
go: downloading golang.org/x/sys v0.16.0
root@riscboi ~# elvish --version
0.20.1
root@riscboi ~# uname -a
Linux riscboi 6.6.0-g076ede06c00a #29 SMP Tue Feb 13 00:01:46 CET 2024 riscv64 GNU/Linux

So, since this works quite well, I wanted to request RISC-V (riscv64) binaries.

Output of "elvish -version"

0.20.1

Code of Conduct

krader1961 commented 4 months ago

This is a reasonable request but it requires that the CI/CD environment used by the project support that architecture. Although I've been contributing changes for several years I've never looked at how the pre-built binaries are built. I think it's done using https://cirrus-ci.org/ which, AFAICT, does not support Risc-V at this time. It's not obvious that the number of users running Elvish on Risc-V is large enough today to justify setting up a build environment on something like the https://cloud-v.co/ service.

xiaq commented 3 months ago

I think it's done using https://cirrus-ci.org/ which, AFAICT, does not support Risc-V at this time.

The binaries are built from my own VPSs, not from Cirrus CI (or GitHub Actions, which Elvish also uses). All the binaries are cross-compiled using the tools/buildall.elv script. Since they are cross-compiled, the architecture of the builders themselves are not relevant.

It would still be nice if I can get a RISC-V test runner to make sure that everything actually works as expected. I may try to set up one in future but that's another project.

In any case, RISC-V is pretty cool, so I just added that to tools/buildall.elv in 7f24110d79fd4287d280bccb8c6b90345f677e05 and HEAD builds are now available from https://dl.elv.sh/linux-riscv64/. I haven't added them to https://elv.sh/get because they weren't built for the last release and I'd like to keep the JavaScript simple, but I'll add it after the 0.21.0 release.

IngwiePhoenix commented 3 months ago

A test runner? Well; does your VPS have docker? You could utilize QEMU + Docker to do that. There is a smaller emulator out there but I can't remember the name... That said, how do I run the tests? Would be happy to take my board for a spin and run the whole suite.

xiaq commented 3 months ago

A test runner? Well; does your VPS have docker? You could utilize QEMU + Docker to do that. There is a smaller emulator out there but I can't remember the name...

Aha. I knew there's a qemu emulator for RISC-V but I was under the (apparently wrong) impression that you can't easily run qemu inside docker - but come to think of it, maybe KVM inside docker is messy but an emulator shouldn't need any special permissions.

Docker certainly simplifies things a bit, maybe I can even do it on GitHub Actions (my VPSs are quite underpowered). It still seems to be some non-trivial amount of work, and I may or may not get to that soon. I'd certainly accept contributions :)

That said, how do I run the tests? Would be happy to take my board for a spin and run the whole suite.

Just go test ./... works! Or use make test which does slightly more things.

xiaq commented 1 month ago

@zhsj taught me about qemu-user-static and it's a breeze to use. We're now running tests on both riscv64 and s390x! https://github.com/elves/elvish/actions/runs/10402716105