Skip to content

Setup development environment (archrv rootfs ver.)

Yang Liu edited this page Apr 1, 2024 · 2 revisions

Prerequisites

The author of this document uses x86_64 Arch Linux. Machines with other distros and architectures should also work.

Install QEMU

Install the latest version of qemu-user-static and qemu-user-static-binfmt. At the time of writing this document, the latest version is 8.2.2. Older versions should also work just fine, but I haven't tested them.

Setup the container

For detailed guidance, please refer to Setup Arch Linux RISC V Development Environment, here are some minor suggestions for it:

  1. Use the latest image from https://archriscv.felixc.at/images/, the link in the original doc is a bit outdated.
  2. Change the selected mirror in /etc/pacman.d/mirrorlist to the one that suits you.

Install packages

# These are the most important ones, other missing packages should be easily figured out along the way.
pacman -S python clang

Test RVV supporting

# First, test your clang version, which should be equal to or higher than 17.0.6.
clang --version
# Next, compile and run a sample rvv intrinsic program to test the toolchain and QEMU support on the Vector extension.
mkdir demo && cd demo
wget https://raw.githubusercontent.com/riscv-non-isa/rvv-intrinsic-doc/main/examples/common.h
wget https://raw.githubusercontent.com/riscv-non-isa/rvv-intrinsic-doc/main/examples/rvv_strlen.c
clang rvv_strlen.c -o rvv_strlen -I. -march=rv64gcv # Outputs nothing
./rvv_strlen # Outputs pass

If an Illegal instruction error is encountered when running ./rvv_strlen, try to set QEMU_CPU=rv64,v=true env. var. before entering the container to enable QEMU RVV support.

Setup virtualenv and activate it

virtualenv venv
source venv/bin/activate

After this, you should see (venv) before the normal terminal prompt. From now on, anything related to Python goes into the venv folder you created (see which python). Run deactivate to exit the virtual environment.

Compiling and test numpy

git clone https://github.com/plctlab/numpy
cd numpy
# You can use the default GCC compiler, but at the time of writing this document, GCC 13.2.1 does not provide RVV 1.0 intrinsics.
export CC=clang CXX=clang++
# There will be some Python packages missing, like spin itself, install them.
spin test -v