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 riscv64 devices.
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.
Project Goals
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.
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 ^_^
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...
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.
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.
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.
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.
docker run --platform linux/riscv64 --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -it swiftarm/swift:5.10.1-debian-unstable-riscv64 /bin/bash
Project Update
All development has now moved to swift-5.10.1-RELEASE and the main-branch. Older swift versions have proved to be too difficult and not viable to continue.
Test release of swift-5.10.1-RELEASE for riscv64 is now available!
A new project, Patches to Upstream, has been set up to track upstream patches being submitted to swift and all the supporting projects.
New riscv64 hardware is coming soon! In the coming weeks we will be receiving a new Pioneer Box will hugely reduce build times and increase productivity.
Thats all for now, hope you enjoy using swift on riscv64.
Thanks.
One more thing ~
Included in the release there is a special riscv64 version of the Vapor Toolbox.
The new Milk-V Pioneer riscv64 workstation has arrived! Sophon SG2042 cpu - 64 cores at 2GHz 128GB RAM 1TB nvme ssd
Performance is looking very good in initial testing.
swift-5.10.1-RELEASE - V2 is now available.
This release fixes the -Xlinker -latomic requirement.
This also enables us to use this version to bootstrap future swift builds on riscv64.
Fully bootstrapped builds with macros support should be available soon.
The Swift Community Apt Repository has been upgraded to support the riscv64 architecture.
If you have a riscv64 device running Linux - Debian or Ubuntu, swift can now be installed using the apt package manager.
Great to hear things are moving forward! Have you tried running the compiler validation test suite on RISC-V? It would be interesting to know how that does.
Up till now we have just been focussing on achieving a successful build so have been building with no tests activated.
This was mainly due to the very slow build times of 24+ hours on the VisionFive2 boards.
Now that we have the new Pioneer Workstation we can start running all the tests and posting the results.
I am expecting lots of interesting failures.
Very good to know. I shall cease trying to get it working on 5.7.3 immediately. When you first built 5.10.1 that was without a working swiftc compiler installed I assume? As that is the path that I will need to follow.
If you are still trying to get Swift into Debian and are not talking about RISC-V specifically, I suggest you try to get 5.8 or 5.9 in first, as both probably did not require a prebuilt Swift compiler to build the full Swift compiler quickly, ie with the bootstrapping mode. Once that's in, you could then use that prebuilt Debian compiler to build an updated Swift 5.10 or 6.0, which pretty much require such a prebuilt Swift compiler.
Alternately, you'd have to build the 5.10 compiler purely from C++ first, then rebuild the full Swift 5.10 compiler with that bootstrap C++-only Swift 5.10 compiler.
@SteveM
You will need to build a 5.10.1-release without bootstrapping first by adding these extra flags to the buildbot preset in the build-presets.ini file.
You can then use this version to build a fully bootstrapped version.
This is all you need to do to build 5.10.1 versions for arm64 and x86_64.
Building for riscv64 is another story and there are too many patches needed at the moment to expect it to build using the official Debian build method you are working on.
As well as swift, there are also 18 sub projects that need patching. A lot of the patches are minor but some are major workarounds and are not suitable to be included in official releases.
There is also the issue of the gold linker not being available on riscv64 which requires the build to be modified to default to the lld linker.
@Finagolfin
I built 5.6.3 for Debian and got it into unstable and testing, but it started to FTBFS due to other changes such as with glibc. Right now 5.7.3 is in Debian unstable and will migrate to testing in a few days. Only x86_64 and arm64 for now.
When I was working on 5.6.3 I was under the impression that it was the last version of Swift that could be built with a C++ compiler, and that I would need to use Swift 5.6.3 to build 5.7.3 and that to build 5.8.1 and so on. But it seems that in reality we can still build with a C++ compiler, it just has missing features, but it can in turn be used to build itself again with all of the features. Maybe I should leapfrog to 5.9 or 5.10.
@futurejones
I don't mind having to make a large number of patches for RISC-V and have a compiler that is potentially buggy as long as only the RISC-V version is impacted. I will have to carefully plan out the 5.10.1 build for Debian as it would also need to build for x86_64 and arm64 at the same time with the same set of build files. Thank you for the guidance on how to pull it off. I might just give it a try on x86_64 and arm64 to see if I can't just skip all of the inbetween versions.
OK, once that's in, can installation of that prebuilt 5.7.3 package be made a requirement to build 5.10.1? If so, you may be best off jumping to 5.10 that way.
Yes, that is what I referred to earlier when I said, "Alternately, you'd have to build the 5.10 compiler purely from C++ first...", but as Neil points out, that is a more involved process.
Sure, I'm just suggesting that using a prebuilt 5.7 or 5.8 may be an easier way for you to make that jump to 5.10.