rv32emu uses a Kconfig-based build
system. This document covers JIT compiler setup and detailed build-time
options.
The tier-2 JIT compiler in rv32emu leverages LLVM for powerful optimization.
The target system must have LLVM installed; versions 18
through 21 are accepted, and LLVM 20+ is the validated default exercised by
CI on both macOS (arm64, Homebrew) and Linux (x86-64, Ubuntu 24.04). If LLVM
is not installed, only the tier-1 JIT compiler will be used for performance
enhancement.
- macOS:
brew install llvm@20(LLVM 18, 19, and 21 are also accepted) - Ubuntu Linux / Debian:
sudo apt-get install llvm-20-dev clang-20 lld-20— the-devpackage is required because T2C builds against<llvm-c/*.h>and links viallvm-config. On releases that don't ship LLVM 20 in the base repos (Ubuntu 24.04 caps at llvm-18), add apt.llvm.org first. LLVM 18, 19, and 21 are also accepted.
The Makefile auto-detects llvm-config in $PATH (preferring the newest
supported version) and the matching Homebrew prefix; override with
make LLVM_CONFIG=/path/to/llvm-config to pin a specific install.
Build the emulator with JIT compiler using the predefined configuration:
$ make jit_defconfig
$ makeAlternatively, use the legacy command-line option (for backward compatibility):
$ make ENABLE_JIT=1If you don't want the JIT compilation feature, simply build with the following:
$ make defconfig
$ makeThere are three ways to customize the build.
Use predefined configurations for common use cases:
$ make defconfig # Default: SDL enabled, all extensions
$ make mini_defconfig # Minimal: no SDL, basic extensions only
$ make jit_defconfig # JIT: enables tiered JIT compilation
$ make system_defconfig # System: enables Linux system emulation
$ make system_jit_defconfig # System+JIT: enables Linux system emulation with JIT
$ make wasm_defconfig # WebAssembly: build for browser deploymentUse the menu-driven interface to customize options:
$ make configOverride individual options on the command line (for backward compatibility):
$ make ENABLE_EXT_F=0 # Build without floating-point support
$ make ENABLE_SDL=0 # Build without SDL supportENABLE_RV32E: RV32E Base Integer Instruction SetENABLE_EXT_M: Standard Extension for Integer Multiplication and DivisionENABLE_EXT_A: Standard Extension for Atomic InstructionsENABLE_EXT_F: Standard Extension for Single-Precision Floating Point InstructionsENABLE_EXT_C: Standard Extension for Compressed Instructions (RV32C.D excluded)EXT_V(Kconfig only — noENABLE_EXT_Vshim): Standard Extension for Vector Instructions (experimental: decode plus partial execution;VLENdefaults to 128, override at the make line withVLEN=<n>; selecting V auto-selects F). Enable viamake config.ENABLE_Zba: Standard Extension for Address Generation InstructionsENABLE_Zbb: Standard Extension for Basic Bit-Manipulation InstructionsENABLE_Zbc: Standard Extension for Carry-Less Multiplication InstructionsENABLE_Zbs: Standard Extension for Single-Bit InstructionsENABLE_Zicsr: Control and Status Register (CSR)ENABLE_Zifencei: Instruction-Fetch FenceENABLE_GDBSTUB: GDB remote debugging supportENABLE_SDL: Display and Event System Calls for running video gamesENABLE_JIT: Tier-1 (template) JIT for hot basic blocks. Wired throughmk/compat.mkso command-line override is supported.ENABLE_T2C: Tier-2 LLVM JIT layered on top ofJIT. Auto-selected byjit_defconfigwhen a supported LLVM is detected (18-21, LLVM 20+ validated). SetENABLE_T2C=0(or disable inmake config) to stay on Tier-1 only.T2C_OPT_LEVEL: LLVM optimization level for the tier-2 JIT (0-3, default 3). Visible only whenT2C=y.ENABLE_SYSTEM: System emulation for booting the RV32 Linux kernel (MMU, UART, virtio, timer).ENABLE_GOLDFISH_RTC: Goldfish RTC peripheral; selectable only whenSYSTEM=yandELF_LOADER=n.ENABLE_ELF_LOADER: In system mode, run user ELF binaries directly instead of booting a kernel image. Required to runmake checkagainst the system build.ENABLE_SDL_MIXER: SDL2_mixer audio (depends onSDL=y).ENABLE_MOP_FUSION: Macro-operation fusion in the IR (default on).ENABLE_BLOCK_CHAINING: Chain translated blocks to bypass the dispatcher (default on).ENABLE_LTO: Link-time optimization (default on; requires GCC or Clang).ENABLE_UBSAN: Build with-fsanitize=undefinedto surface UB at runtime.ENABLE_ARCH_TEST: Build the RISCOF-driven arch-test harness; see riscof.md.INITRD_SIZE: System mode only — initrd reservation in MiB.mk/system.mkauto-sizes from the on-diskrootfs.cpio(file size + 2 MiB) when present, otherwise defaults to 32 MiB. Override on the make line, e.g.make system ENABLE_SYSTEM=1 INITRD_SIZE=64for SDL workloads that bundle larger assets.VLEN: V extension vector length in bits (default 128). Override on the make line, e.g.make VLEN=256. SeeEXT_Vabove for enabling vector support.