|
| 1 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +# or more contributor license agreements. See the NOTICE file |
| 3 | +# distributed with this work for additional information |
| 4 | +# regarding copyright ownership. The ASF licenses this file |
| 5 | +# to you under the Apache License, Version 2.0 (the |
| 6 | +# "License"); you may not use this file except in compliance |
| 7 | +# with the License. You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, |
| 12 | +# software distributed under the License is distributed on an |
| 13 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +# KIND, either express or implied. See the License for the |
| 15 | +# specific language governing permissions and limitations |
| 16 | +# under the License. |
| 17 | + |
| 18 | +name: riscv64-qemu-test |
| 19 | + |
| 20 | +on: [push, pull_request] |
| 21 | + |
| 22 | +jobs: |
| 23 | + test: |
| 24 | + runs-on: ubuntu-latest |
| 25 | + env: |
| 26 | + RISCV_CROSSCOMPILE: "ON" |
| 27 | + 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" |
| 28 | + RISCV_PATH: "/opt/riscv" |
| 29 | + |
| 30 | + steps: |
| 31 | + - uses: actions/checkout@v4 |
| 32 | + with: |
| 33 | + submodules: recursive |
| 34 | + |
| 35 | + - name: Install dependencies |
| 36 | + run: | |
| 37 | + sudo apt update |
| 38 | + sudo apt install -y --no-install-recommends \ |
| 39 | + qemu-user qemu-user-static \ |
| 40 | + wget \ |
| 41 | + build-essential \ |
| 42 | + cmake \ |
| 43 | + libgflags-dev \ |
| 44 | + libsnappy-dev \ |
| 45 | + zlib1g-dev \ |
| 46 | + libbz2-dev \ |
| 47 | + liblz4-dev \ |
| 48 | + libzstd-dev \ |
| 49 | + git \ |
| 50 | + python3 \ |
| 51 | + clang \ |
| 52 | + golang \ |
| 53 | + libboost-dev \ |
| 54 | + libstdc++-12-dev |
| 55 | + sudo mkdir -p $RISCV_PATH |
| 56 | + wget ${riscv_gnu_toolchain_download_path} -O riscv-toolchain.tar.xz |
| 57 | + sudo tar -xvf riscv-toolchain.tar.xz -C $RISCV_PATH --strip-components=1 |
| 58 | + 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 |
| 59 | +
|
| 60 | + - name: Build and test |
| 61 | + run: | |
| 62 | + export PATH=$RISCV_PATH/bin:$PATH |
| 63 | + export LD_LIBRARY_PATH="/opt/riscv/lib:$LD_LIBRARY_PATH" |
| 64 | + export QEMU_LD_PREFIX=$RISCV_PATH/sysroot |
| 65 | + CC=riscv64-unknown-linux-gnu-gcc \ |
| 66 | + CXX=riscv64-unknown-linux-gnu-g++ \ |
| 67 | + ./x.py build \ |
| 68 | + -DCMAKE_SYSTEM_NAME=Linux \ |
| 69 | + -DCMAKE_SYSTEM_PROCESSOR=riscv64 \ |
| 70 | + -DCMAKE_CROSSCOMPILING=TRUE \ |
| 71 | + --unittest -j4 |
| 72 | + qemu-riscv64 -L $QEMU_LD_PREFIX -cpu rv64,v=true,vext_spec=v1.0,zba=true,zbb=true ./build/unittest |
0 commit comments