Skip to content

Commit

Permalink
Add CI test with qemu for riscv64
Browse files Browse the repository at this point in the history
  • Loading branch information
csukuangfj committed Feb 25, 2024
1 parent 481d211 commit 7c70de7
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 6 deletions.
65 changes: 61 additions & 4 deletions .github/workflows/riscv64-linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
push:
branches:
- master
- riscv64
paths:
- '.github/workflows/riscv64-linux.yaml'
- 'CMakeLists.txt'
Expand Down Expand Up @@ -51,6 +50,36 @@ jobs:
with:
key: ${{ matrix.os }}-riscv64-${{ matrix.lib_type }}

- name: cache-qemu
id: cache-qemu
uses: actions/cache@v4
with:
path: qemu-install
key: qemu-riscv-install-20240225

- name: install-qemu-build-deps
if: steps.cache-qemu.outputs.cache-hit != 'true'
run: |
sudo apt-get update
sudo apt-get install autoconf automake autotools-dev ninja-build
- name: checkout-qemu
if: steps.cache-qemu.outputs.cache-hit != 'true'
uses: actions/checkout@v3
with:
repository: qemu/qemu
path: qemu

- name: qemu
if: steps.cache-qemu.outputs.cache-hit != 'true'
run: |
cd qemu
./configure --prefix=$GITHUB_WORKSPACE/qemu-install --target-list=riscv64-linux-user --disable-system
make -j2
make install
ls -lh $GITHUB_WORKSPACE/qemu-install
ls -lh $GITHUB_WORKSPACE/qemu-install/bin
- name: cache-toolchain
id: cache-toolchain
uses: actions/cache@v4
Expand All @@ -72,6 +101,13 @@ jobs:
export PATH=$GITHUB_WORKSPACE/toolchain/bin:$PATH
riscv64-unknown-linux-gnu-gcc --version
- name: Display qemu-riscv64 -h
shell: bash
run: |
export PATH=$GITHUB_WORKSPACE/qemu-install/bin:$PATH
export QEMU_LD_PREFIX=$GITHUB_WORKSPACE/toolchain/sysroot
qemu-riscv64 -h
- name: build riscv64-linux
shell: bash
run: |
Expand All @@ -97,6 +133,27 @@ jobs:
file build-riscv64-linux-gnu/bin/sherpa-onnx
- name: Test sherpa-onnx
shell: bash
run: |
export PATH=$GITHUB_WORKSPACE/toolchain/bin:$PATH
export PATH=$GITHUB_WORKSPACE/qemu-install/bin:$PATH
export QEMU_LD_PREFIX=$GITHUB_WORKSPACE/toolchain/sysroot
ls -lh ./build-riscv64-linux-gnu/bin
echo "----------sherpa-onnx----------"
qemu-riscv64 ./build-riscv64-linux-gnu/bin/sherpa-onnx --help
readelf -d ./build-riscv64-linux-gnu/bin/sherpa-onnx
echo "----------sherpa-onnx-offline----------"
qemu-riscv64 ./build-riscv64-linux-gnu/bin/sherpa-onnx-offline --help
readelf -d ./build-riscv64-linux-gnu/bin/sherpa-onnx-offline
echo "----------sherpa-onnx-offline-tts----------"
qemu-riscv64 ./build-riscv64-linux-gnu/bin/sherpa-onnx-offline-tts --help
readelf -d ./build-riscv64-linux-gnu/bin/sherpa-onnx-offline-tts
- name: Copy files
shell: bash
run: |
Expand All @@ -118,9 +175,9 @@ jobs:
lib_type=${{ matrix.lib_type }}
if [[ $lib_type == "shared" ]]; then
cp -a build-riscv64-linux-gnu/install/lib $dst/
rm -v $dst/lib/libasound.so
rm -v $dst/lib/libonnxruntime.so
rm -v $dst/lib/libsherpa-onnx-fst.so
rm -fv $dst/lib/libasound.so
rm -fv $dst/lib/libonnxruntime.so
rm -fv $dst/lib/libsherpa-onnx-fst.so
fi
tree $dst
Expand Down
2 changes: 1 addition & 1 deletion cmake/onnxruntime-linux-riscv64-static.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2022-2023 Xiaomi Corporation
# Copyright (c) 2022-2024 Xiaomi Corporation
message(STATUS "CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")
message(STATUS "CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")

Expand Down
2 changes: 1 addition & 1 deletion cmake/onnxruntime-linux-riscv64.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2022-2023 Xiaomi Corporation
# Copyright (c) 2022-2024 Xiaomi Corporation
message(STATUS "CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")
message(STATUS "CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")

Expand Down

0 comments on commit 7c70de7

Please sign in to comment.