Swift on RISC-V
I would like announce Swift on RISC-V, a new project I am currently working on.
The RISC-V ecosystem is growing at a phenomenal rate and 2023 will see the introduction of many new exciting and powerful devices. From small soc boards up to large 64 / 128 core workstations and servers.
Primarily the focus on this project will be on building the swift toolchain for
Most of the core programming languages and development tools are already available for the
riscv64 architecture and I think it is very important for the future of
Swift to be available for
riscv64 as well.
The main goals for the project are:-
- Setup and maintain a
riscv64 CI build server for Swift development and testing.
- Provide feedback and
#PR's to the Swift project for bugs and fixes required for RISC-V
- Port the swift toolchain to
riscv64 on Debian / Ubuntu OS's
- Build and distribute Swift for
riscv64 Debian and Ubuntu packages via the Swift Community Apt Repository.
- Build and distribute Swift
riscv64 Libraries for hardware functionality such as GPIO on the VisionFive2 board.
Project Status June 2023
- The Github organization and repositories have been setup.
- A Dev environment has been created using docker
- riscv64 hardware - Visionfive 2 boards have been received
- A Debian build server has been added to Swift Community CI Server
- The first have been #PR's uploaded to Swift repository.
Help is needed in many areas and everybody is welcome to join the project.
You can use Github Discussions or the
Swift Forums for any questions and support.
If someone can help getting the initial #PR's noticed and merged it would be very appreciated.
For more information on RISC-V and the RISC-V community please go to
this is is really cool!
i have a couple risc-v boards (visionfive2, hifive unmatched) so if there is any help needed with testing on real hardware etc i'd be willing to help out if possible ^_^
@andrekandore, how does the performance of the visionfive2 compare with the hifive unmatched?
visionfive 2 seems a bit better than unmatched i must say
especially the graphical performance on unmatched was not great, even with a beefy gpu (games like tux racer or whatever was fine) ... but it was very hard to use for graphical development...
i suspect it has to do with what was explain in this thread: Memory access is too slow - #13 by davidlt - HiFive Unmatched - SiFive Forums
Great, what is the current status of building the toolchain on one of those linux riscv64 boards? Can you run the Swift compiler validation suite on linux riscv64 yet? @ColemanCDA has been working on cross-compiling the Swift stdlib for riscv64, so that may be in good shape already.
You may want to set up a CI to cross-compile the Swift toolchain to linux riscv64, after which you could transfer it to the Visionfive2 board and run the Swift tests on it. That way, you don't have to build the Swift toolchain itself on the slower riscv64 board, but only use it for testing.
That is how I build the native Swift toolchain for Android that I distribute with the Termux app, I cross-compile that Swift toolchain package from linux x86_64 to Android AArch64, armv7, and x86_64.
I'd like to help out with this RISC-V port, but I have no idea how far along it is already. Also, will you be able to provide ssh access to a few contributors on this riscv64 board? That was a big problem with the prior armv7 CI, that such access was not available to debug build failures.
@Finagolfin, providing ssh access to the VisionFive board at the moment is not practical as the OS and firmware are not stable and are being frequently updated.
The best option for development at the moment is to use
docker on an arm64 or x86_64 machine and just use the riscv64 board for final verification of patches.
See here for more info Building a Developer Environment for Riscv64 With Docker.
Setting up a CI to cross-compile the Swift toolchain to linux riscv64 is a good idea and it would be great if somebody does this.
For myself one of the main purposes of this project is to assess to current state of the
riscv64 ecosystem and its ability to build the swift toolchain natively.
The initial issues I have found have been posted here - swift-riscv64/issues
One of the first issues that will need to be fixed is implementing the
swiftcall calling convention on
riscv64. If you could help with this that would be great.
Why would that matter for ssh access, the board may need to be rebooted sometimes? Since we would only need to log in once in awhile, I don't think that would be a big deal.
Yep, that's best for most, but I've never used Docker and don't want to. I always use real hardware and never emulators, as there are inevitably differences. Anyway, I don't think I'll have much time for this port.
What is your assessment so far? Once you get the toolchain natively compiling, it should be pretty easy to cross-compile it after that, so I can help with that.
Thanks, will keep tabs on those.
No background with that, doubt I'd help much. Glad you set this repo and CI up, so the community can contribute in whatever areas they know best.
@Finagolfin the VisionFive board is not in a rack in a cloud server farm somewhere. It is on my desk at home next to my iMac. These are prototype dev boards and updating the firmware and OS system is a bit more involved than a reboot.
PR's #66530 and #66699 have been approved and merged
Big thank you to everyone who helped with these.