Skip to content

Conversation

jserv
Copy link
Contributor

@jserv jserv commented Oct 15, 2025

This introduces SYSTEM_MMIO feature flag to properly gate MMIO-related code in JIT. This flag is enabled only when SYSTEM=1 and ELF_LOADER=0 (Linux kernel mode), preventing compilation errors when both SYSTEM and ELF_LOADER are enabled.


Summary by cubic

Fix JIT build when SYSTEM and ELF_LOADER are both enabled by gating MMIO code to Linux kernel mode only. This prevents compilation errors while keeping MMIO for kernel emulation.

  • Bug Fixes
    • Introduced RV32_FEATURE_SYSTEM_MMIO (enabled when SYSTEM=1 and ELF_LOADER=0).
    • Switched JIT MMIO checks to RV32_HAS(SYSTEM_MMIO) in jit.c and rv32_jit.c.
    • Scoped MMIO macros in system.h behind !RV32_HAS(ELF_LOADER) to avoid conflicts.

This introduces SYSTEM_MMIO feature flag to properly gate MMIO-related
code in JIT. This flag is enabled only when SYSTEM=1 and ELF_LOADER=0
(Linux kernel mode), preventing compilation errors when both SYSTEM and
ELF_LOADER are enabled.
Copy link
Collaborator

@ChinYikMing ChinYikMing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The compilation error can be reproduced via make ENABLE_SYSTEM=1 ENABLE_ELF_LOADER=1 ENABLE_JIT=1 -j8 without these changes.

Sample errors:

...

src/jit.c: In function ‘jit_mmio_read_wrapper’:
src/jit.c:1401:5: error: implicit declaration of function ‘MMIO_READ’ [-Werror=implicit-function-declaration]
 1401 |     MMIO_READ();
      |     ^~~~~~~~~
src/jit.c:1399:41: error: unused parameter ‘rv’ [-Werror=unused-parameter]
 1399 | uint32_t jit_mmio_read_wrapper(riscv_t *rv, uint32_t addr)
      |                                ~~~~~~~~~^~
src/jit.c:1399:54: error: unused parameter ‘addr’ [-Werror=unused-parameter]
 1399 | uint32_t jit_mmio_read_wrapper(riscv_t *rv, uint32_t addr)
      |                                             ~~~~~~~~~^~~~
src/jit.c: In function ‘jit_mmu_handler’:
src/jit.c:1430:9: error: implicit declaration of function ‘MMIO_WRITE’ [-Werror=implicit-function-declaration]
 1430 |         MMIO_WRITE();
      |         ^~~~~~~~~~
src/jit.c:1424:14: error: variable ‘val’ set but not used [-Werror=unused-but-set-variable]
 1424 |     uint32_t val;
 
 ...

With these changes applied, the compilation errors are gone.

LGTM!

@jserv jserv merged commit e8f24f4 into master Oct 19, 2025
27 of 33 checks passed
@jserv jserv deleted the fix-jit-build branch October 19, 2025 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants