Until a couple of weeks ago I assumed that RISC-V was still an experimental architecture that one would have to customize in VHDL or Verilog and use on an FPGA. So when Debian announced official support for the new architecture, I decided to have a closer look. It turns out there are several Raspberry Pi-class boards with RISC-V processors that run some flavor of Linux, and not surprisingly most vendors offer a Debian-based image for their boards.
While there are Fedora images for some boards, none of the Red Hat-based distributions have support for RISC-V yet, so I got an idea for an ambitious project: make AlmaLinux the first distribution in the Red Hat family that has proper support – whatever that means – for RISC-V. I used to work on MIRACLE LINUX before my employer joined AlmaLinux, so I have a rough idea how much work is involved in building the packages. I had never ported an entire distribution to a new CPU architecture though, so I was not sure if this is possible at all, and this is why I actually wanted to keep this below the radar. Despite that, I somehow happened to mention this project in a 1:1 with my manager, who immediately liked the idea and got me funding for a board. And this is how the ball started rolling.
Clearing the port
Since most available RISC-V boards offer performance that is comparable to a Raspberry Pi, packages like GCC take several hours, and an entire distribution will probably take weeks to build. Getting faster boards is currently out of question, so I will have to scale horizontally, building packages on multiple boards in parallel. Luckily, the build system that I wrote to build Debian packages is very good at scaling horizontally, so I spent some days adding support for RPM builds and a simple build scheduler, and got the build system to the point where it can rebuild an entire RPM-based distribution (modularity packages are the usual exception).
The starting point for the AlmaLinux port is a Fedora build root, since that is the only RPM-based distribution that had RISC-V packages at the time of writing. Fedora 34 is the closest to AlmaLinux 9, so this would be ideal for the initial build root, but there are no Fedora 34 packages for RISC-V. There are packages for Fedora 29 and Fedora 33 though, so I decided to start with AlmaLinux 8, which is based on RHEL8 (the latter is based on Fedora 29). To build AlmaLinux 9, I will first have to port Fedora 34, which should be possible with a Fedora 33 build root, but is very likely more work than a simple rebuild. Either way, I will write a more technical follow-up once I have some tangible results.