aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorBruce Lai <bruce.lai@sifive.com>2023-03-22 00:53:16 -0700
committerlibyuv LUCI CQ <libyuv-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-04-10 00:50:25 +0000
commit646fc1b21444db4cc9d4f2c9478b0748941574f5 (patch)
tree82af1f505062e687f2af089e0f67a47d82bdd672 /docs
parent0200037a5a058650cb2e2e2cca1545a362e52013 (diff)
downloadlibyuv-646fc1b21444db4cc9d4f2c9478b0748941574f5.tar.gz
Enable RISC-V cmake build & qemu test
1. Provide script to build qemu & clang locally 2. Enable risc-v cmake build with clang 3. Enable test with qemu 4. Update doc to introduce how to cross-build & test with qemu Signed-off-by: Bruce Lai <bruce.lai@sifive.com> Change-Id: I7ce8315993b0e8300e8fd5b1632610a91a4e9f52 Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/4401740 Reviewed-by: Frank Barchard <fbarchard@chromium.org> Commit-Queue: Frank Barchard <fbarchard@chromium.org>
Diffstat (limited to 'docs')
-rw-r--r--docs/getting_started.md33
1 files changed, 33 insertions, 0 deletions
diff --git a/docs/getting_started.md b/docs/getting_started.md
index 15b19ab2..ff1c185a 100644
--- a/docs/getting_started.md
+++ b/docs/getting_started.md
@@ -220,6 +220,39 @@ Install cmake: http://www.cmake.org/
make -j4
make package
+## Building RISC-V target with cmake
+
+### Prerequisite: build risc-v clang toolchain and qemu
+
+If you don't have prebuilt clang and riscv64 qemu, run the script to download source and build them.
+
+ ./riscv_script/prepare_toolchain_qemu.sh
+
+After running script, clang & qemu are built in `build-toolchain-qemu/riscv-clang/` & `build-toolchain-qemu/riscv-qemu/`.
+
+### Cross-compile for RISC-V target
+ cmake -B out/Release/ -DTEST=ON \
+ -DCMAKE_BUILD_TYPE=Release \
+ -DCMAKE_TOOLCHAIN_FILE="./riscv_script/riscv-clang.cmake" \
+ -DTOOLCHAIN_PATH={TOOLCHAIN_PATH} \
+ -DUSE_RVV=ON .
+ cmake --build out/Release/
+
+
+### Run on QEMU
+
+To test RVV on user mode QEMU, we need to hack `source/cpu_id.cc`. By forcing `RiscvCpuCaps` to read from a dummy cpuinfo file instead of the host `/proc/cpuinfo`. Because the program detects CPU Caps from `/proc/cpuinfo` and determines whether to use RVV originally.
+
+ sed -i 's+RiscvCpuCaps("/proc/cpuinfo+RiscvCpuCaps("../../unit_test/testdata/riscv64_rvv.txt+g' source/cpu_id.cc
+
+#### Run libyuv_unittest on QEMU
+ cd out/Release/
+ USE_RVV=ON \
+ TOOLCHAIN_PATH={TOOLCHAIN_PATH} \
+ QEMU_PREFIX_PATH={QEMU_PREFIX_PATH} \
+ ../../riscv_script/run_qemu.sh libyuv_unittest
+
+
## Setup for Arm Cross compile
See also https://www.ccoderun.ca/programming/2015-12-20_CrossCompiling/index.html