Edit this page | Blame

Building Guix packages for RISC-V

To build a Guix package, say the hello package, for RISC-V, run

$ guix build --target=riscv64-linux-gnu hello

If you don't have access to RISC-V hardware, you can run hello using QEMU like so.

$ guix shell qemu -- qemu-riscv64 $(guix build --target=riscv64-linux-gnu hello)/bin/hello
Hello, world!

`guix shell qemu' provides a temporary environment in which qemu is installed. You can think of it as a python "virtual environment", but for all packages, instead of just python packages!

The hello executable above is dynamically linked. But, you might want a statically linked hello for running in more limited environments such as the spike RISC-V ISA simulator. To build a statically linked hello, you need a modified package definition. Unfortunately, each package is different, and it is not possible to automagically create statically linked versions of any given Guix package. For the hello package however, this is very simple, and the following package definition will do.

(use-modules (gnu packages base)
             (guix build-system gnu))

(static-package hello)

To build this statically linked hello, put the above code in a file, say hello-static.scm, and run

$ guix build --target=riscv64-linux-gnu -f hello-static.scm

Run it in spike like so.

$ guix shell spike -- spike $(guix build riscv-pk)/bin/pk $(guix build --target=riscv64-linux-gnu -f hello-static.scm)/bin/hello
bbl loader
Hello, world!

It works!

Statically linked packages from the guix-bioinformatics channel

The guix-bioinformatics channel provides statically linked versions of smithwaterman and wfmash.

To use the guix-bioinformatics channel, drop the following into your ~/.config/guix/channels.scm and run a `guix pull'.

(use-modules (guix ci))

(list (channel
       (name 'gn-bioinformatics)
       (url "https://git.genenetwork.org/guix-bioinformatics/guix-bioinformatics.git")
       (branch "master"))
       %default-guix-channel "https://ci.guix.gnu.org"))

After a `guix pull', you should be able to build smithwaterman-static, wfmash-static, etc. for RISC-V like so.

$ guix build --target=riscv64-linux-gnu smithwaterman-static
$ guix build --target=riscv64-linux-gnu wfmash-static
(made with skribilo)