Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compare with libriscv #288

Open
jserv opened this issue Dec 9, 2023 · 1 comment
Open

Compare with libriscv #288

jserv opened this issue Dec 9, 2023 · 1 comment
Assignees
Labels
research Study certain topics

Comments

@jserv
Copy link
Contributor

jserv commented Dec 9, 2023

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:

  • Perform a performance comparison between libriscv and rv32emu, focusing on both interpreter and binary translation modes, evaluating each separately.
  • Compile a list of techniques employed in libriscv that warrant examination and potential adoption in rv32emu. Subsequently, create corresponding GitHub issues to track this process.

Reference:

@jserv jserv added the research Study certain topics label Dec 25, 2023
@jserv
Copy link
Contributor Author

jserv commented Dec 29, 2023

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:

  • clang-17
--- 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} -fuse-ld=lld")
+               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.

@henrybear327 henrybear327 removed their assignment May 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
research Study certain topics
Projects
None yet
Development

No branches or pull requests

3 participants