Open jserv opened 7 months ago
Build libriscv and its command line interface.
$ git clone https://github.com/fwsGonzo/libriscv
$ cd libriscv/emulator
$ ./build.sh
Since libriscv relies on latest C++ features, recent clang might be required. Consider the following changes:
--- a/emulator/CMakeLists.txt
+++ b/emulator/CMakeLists.txt
@@ -43,7 +43,7 @@ endif()
if (LTO)
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto=full")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}") else() include(CheckIPOSupported) check_ipo_supported(RESULT supported OUTPUT error) --- a/emulator/build.sh +++ b/emulator/build.sh @@ -3,8 +3,8 @@ set -e
mkdir -p .build pushd .build -cmake .. -DCMAKE_BUILD_TYPE=Release -make -j6 +cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=clang++-17 +make -j6 VERBOSE=1 popd
if test -f ".build/rvmicro"; then
Use rvlinux
to execute ELF files.
It is important to comprehend the reasons behind libriscv's superior performance compared to rv32emu in pure interpreter mode.
libriscv is a compact yet comprehensive RISC-V userspace emulator library crafted for effortless embedding and extensive adaptability. It boasts a high-performing interpreter and an experimental binary translator, driven by TinyCC. When binary translation is activated, libtcc seamlessly integrates into the RISC-V emulator, taking on the role of the compiler for binary translation.
Interestingly, both libriscv and rv32emu share some common concepts and objectives. It would be valuable to engage in a comparative analysis to explore aspects such as interpretation and binary translation performance, techniques for ensuring secure sandboxed execution, and strategies for implementing userspace RISC-V emulation.
Expected outcomes:
Reference: