From 7c70de7ece336b07aa6fdf85492dbc675365e7e4 Mon Sep 17 00:00:00 2001 From: Fangjun Kuang Date: Sun, 25 Feb 2024 23:46:06 +0800 Subject: [PATCH] Add CI test with qemu for riscv64 --- .github/workflows/riscv64-linux.yaml | 65 ++++++++++++++++++-- cmake/onnxruntime-linux-riscv64-static.cmake | 2 +- cmake/onnxruntime-linux-riscv64.cmake | 2 +- 3 files changed, 63 insertions(+), 6 deletions(-) diff --git a/.github/workflows/riscv64-linux.yaml b/.github/workflows/riscv64-linux.yaml index 8e8aa0762..04d196a8f 100644 --- a/.github/workflows/riscv64-linux.yaml +++ b/.github/workflows/riscv64-linux.yaml @@ -4,7 +4,6 @@ on: push: branches: - master - - riscv64 paths: - '.github/workflows/riscv64-linux.yaml' - 'CMakeLists.txt' @@ -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 @@ -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: | @@ -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: | @@ -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 diff --git a/cmake/onnxruntime-linux-riscv64-static.cmake b/cmake/onnxruntime-linux-riscv64-static.cmake index 4113e8dc0..8e7c2611f 100644 --- a/cmake/onnxruntime-linux-riscv64-static.cmake +++ b/cmake/onnxruntime-linux-riscv64-static.cmake @@ -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}") diff --git a/cmake/onnxruntime-linux-riscv64.cmake b/cmake/onnxruntime-linux-riscv64.cmake index 0d03c1265..748a2bb52 100644 --- a/cmake/onnxruntime-linux-riscv64.cmake +++ b/cmake/onnxruntime-linux-riscv64.cmake @@ -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}")