Skip to content

feat: Add support for RISC-V architecture #16

feat: Add support for RISC-V architecture

feat: Add support for RISC-V architecture #16

# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
name: riscv64-qemu-test
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
env:
RISCV_CROSSCOMPILE: "ON"
riscv_gnu_toolchain_download_path: "https://github.com/riscv-collab/riscv-gnu-toolchain/releases/download/2025.07.03/riscv64-glibc-ubuntu-24.04-gcc-nightly-2025.07.03-nightly.tar.xz"
RISCV_PATH: "/opt/riscv"
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install dependencies
run: |
sudo apt update
sudo apt install -y --no-install-recommends \
qemu-user qemu-user-static \
wget \
build-essential \
cmake \
libgflags-dev \
libsnappy-dev \
zlib1g-dev \
libbz2-dev \
liblz4-dev \
libzstd-dev \
git \
python3 \
clang \
golang \
libboost-dev \
libstdc++-12-dev
sudo mkdir -p $RISCV_PATH
wget ${riscv_gnu_toolchain_download_path} -O riscv-toolchain.tar.xz
sudo tar -xvf riscv-toolchain.tar.xz -C $RISCV_PATH --strip-components=1
sudo sed -i "s|libdir='/mnt/riscv/riscv64-unknown-linux-gnu/lib'|libdir='$RISCV_PATH/riscv64-unknown-linux-gnu/lib'|g" $RISCV_PATH/riscv64-unknown-linux-gnu/lib/libatomic.la
- name: Build and test
run: |
export PATH=$RISCV_PATH/bin:$PATH
export LD_LIBRARY_PATH="/opt/riscv/lib:$LD_LIBRARY_PATH"
export QEMU_LD_PREFIX=$RISCV_PATH/sysroot
CC=riscv64-unknown-linux-gnu-gcc \
CXX=riscv64-unknown-linux-gnu-g++ \
./x.py build \
-DCMAKE_SYSTEM_NAME=Linux \
-DCMAKE_SYSTEM_PROCESSOR=riscv64 \
-DCMAKE_CROSSCOMPILING=TRUE \
--unittest -j4
qemu-riscv64 -L $QEMU_LD_PREFIX -cpu rv64,v=true,vext_spec=v1.0,zba=true,zbb=true ./build/unittest