SBCL on Fedora Linux on RISC-V QEMU on Arch Linux on x86_64

Charles Zhang, or karlosz, has put in the work to port SBCL to 64-bit RISC-V Linux. I wanted to play around with SBCL on RISC-V and dove in to setting up an environment on my laptop. On this page I recount what I did, to spare you a little research and tinkering.


Since RISC-V hardware is still really expensive, the most reasonable and easy way to run a RISC-V machine is an emulator. I went with QEMU, which supports RISC-V since August 2018, because it is easy to install on my Linux distribution, Arch Linux. The package qemu-arch-extra is up to date and contains the emulator.

Fedora Linux

As my RISC-V targeting operating system, I use Fedora Linux. They explain in their Wiki how to install the image on the emulator. I am using the tested disk image from January 2019, because I had no luck getting a nightly image to run.

To run the tested image, I downloaded the compressed disk image (...sda1.raw.xz) as well as the bbl and imitramfs files from the same directory. Then I could start a VM with the following QEMU invocation:

qemu-system-riscv64 -nographic -machine virt -smp 4 -m 2G \
  -kernel bbl-5.0.0-0.rc2.git0.1.0.riscv64.fc30.riscv64 \
  -object rng-random,filename=/dev/urandom,id=rng0 \
  -device virtio-rng-device,rng=rng0 -append "console=ttyS0 ro root=/dev/vda" \
  -device virtio-blk-device,drive=hd0 \
  -drive file=Fedora-Developer-Rawhide-20190126.n.0-sda1.raw,format=raw,id=hd0 \
  -device virtio-net-device,netdev=usernet \
  -netdev user,id=usernet,hostfwd=tcp::10000-:22 \
  -initrd initramfs-5.0.0-0.rc2.git0.1.0.riscv64.fc30.riscv64.img

Afterwards I could connect via SSH to the machine on port 10000 of localhost. The root password is riscv.

SSH Configuration

To cross build SBCL, I needed an interactionless ssh login. The easiest way (or let's say, the only way I know) to set this up is with SSH keys. So, I copied my public key into /root/.ssh/authorized_keys on the VM, because I intended to run the target build as root.


To build SBCL, I need a copy of the SBCL source on the host and on the target machine. On the target machine it has to be the cloned git repository of the SBCL sources.

After I downloaded the sources to /root/sbcl/ on the target machine and to some arbitrary location on the host machine, I couldstart the build with

$ ./ -p 10000 sync root@localhost /root/sbcl SBCL_ARCH=riscv

on the host machine and then

$ ./

in the target machine's source directory, to build all the contribs. The default build only builds sb-posix and sb-bsd-sockets.

As of my writing this text everything should build without errors except for the sb-posix contrib. It compiles correctly, but fails a test, since it does not like being run as root.

To have the install script install sb-posix anyway, I needed to touch /root/sbcl/obj/asdf-cache/sb-posix/test-passed.test-report.

Finally, I ran ./ in the target machine's source directory.

Happy hacking.