-
Notifications
You must be signed in to change notification settings - Fork 107
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
Fix build failures and expand test coverage #535
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Benchmarks
Benchmark suite | Current: 99c52b9 | Previous: 3f37f51 | Ratio |
---|---|---|---|
Dhrystone |
1327 Average DMIPS over 10 runs |
1317 Average DMIPS over 10 runs |
0.99 |
Coremark |
954.362 Average iterations/sec over 10 runs |
956.978 Average iterations/sec over 10 runs |
1.00 |
This comment was automatically generated by workflow using github-action-benchmark.
make ENABLE_JIT=1 clean && make ENABLE_Zba=0 ENABLE_JIT=1 check -j$(nproc) | ||
make ENABLE_JIT=1 clean && make ENABLE_Zbb=0 ENABLE_JIT=1 check -j$(nproc) | ||
make ENABLE_JIT=1 clean && make ENABLE_Zbc=0 ENABLE_JIT=1 check -j$(nproc) | ||
make ENABLE_JIT=1 clean && make ENABLE_Zbs=0 ENABLE_JIT=1 check -j$(nproc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about repeating all diverse configuration tests with JIT enabled?
make distclean && make ENABLE_Zba=0 check -j$(nproc) | ||
make distclean && make ENABLE_Zbb=0 check -j$(nproc) | ||
make distclean && make ENABLE_Zbc=0 check -j$(nproc) | ||
make distclean && make ENABLE_Zbs=0 check -j$(nproc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe also add:
make distclean && make ENABLE_Zifencei=0 check -j$(nproc)
Hmmm, it seems CI fails due to insufficient memory. Any ideas on how we can reduce the memory usage? |
ba5521c
to
08146d9
Compare
@@ -7,7 +7,7 @@ BIN := $(OUT)/rv32emu | |||
CONFIG_FILE := $(OUT)/.config | |||
-include $(CONFIG_FILE) | |||
|
|||
CFLAGS = -std=gnu99 -O2 -Wall -Wextra |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are modifying this, do we also want to add -Wshadow
to catch more problems :) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this depends on whether our coding style aims to forbid local variables from shadowing other variables?
Sorry for the misleading description. The CI failure is due to the addition of more tests, causing excessive http requests to github.com during the fetch-checksum, which results in a 403 too many requests error. Here’s the error log:
|
This comment was marked as outdated.
This comment was marked as outdated.
I noticed that we make frequent requests to fetch the checksum file and store it in $(BIN_DIR)/sha1sum-linux-image. To reduce the number of requests, we could modify the code to check if the checksum file already exists and is less than a day old. If it’s up-to-date, we can skip fetching it again. This way, we minimize unnecessary requests. Any thoughts? |
Yes, create an issue for tracking. |
Add the -Werror flag to the CFLAGS to treat all warnings as errors during the build process. This ensures that warnings are blocked by CI, enforcing cleaner code and preventing builds from succeeding with any warnings
When using make 'ENABLE_JIT=1', the following error is observed: src/jit.c:1760:17: error: ‘do_sret’ defined but not used [-Werror=unused-function] 1760 | static void do_##inst(struct jit_state *state UNUSED, riscv_t *rv UNUSED, \ | ^~~ Add "SYSTEM" to the EXT_LIST, which cause SERT to be add SKIP_LIST during template generation. The prevents the generatoin of unused JIT code for the SERT instruction. Fixes: fc0d878 ("Preliminary support for trap handling during block emulation")
08146d9
to
89a7356
Compare
I'll help review the pull request this week. Thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Except for the occasional rate limit exceed issue when fetching checksums in CI, everything else LGTM!
I'm surprised there are so many compilation issues. Thanks for your work!
Add compiler matrix strategy to test builds with both gcc and clang compilers. This ensures the codebase compiles and passes tests with different compilers.
When using 'make ENABLE_Zba=0 ENABLE_JIT=1', the following errors are observed: src/jit.c:1760:17: error: ‘do_sh3add’ defined but not used [-Werror=unused-function] src/jit.c:1760:17: error: ‘do_sh2add’ defined but not used [-Werror=unused-function] src/jit.c:1760:17: error: ‘do_sh1add’ defined but not used [-Werror=unused-function] Include 'Zba' in EXT_LIST to ensure instructions like 'sh3add', 'sh2add', and 'sh1add' are properly handled, resolving unused function errors during JIT builds.
Add a new test case to the CI pipeline to verify JIT functionality when the Zba extension is disabled. This ensures better coverage and prevents regressions for this specific configuration.
When using 'make ENABLE_Zbb=0 ENABLE_JIT=1', the following errors are observed: src/jit.c:1760:17: error: ‘do_rev8’ defined but not used [-Werror=unused-function] src/jit.c:1760:17: error: ‘do_orcb’ defined but not used [-Werror=unused-function] src/jit.c:1760:17: error: ‘do_rori’ defined but not used [-Werror=unused-function] src/jit.c:1760:17: error: ‘do_ror’ defined but not used [-Werror=unused-function] src/jit.c:1760:17: error: ‘do_rol’ defined but not used [-Werror=unused-function] src/jit.c:1760:17: error: ‘do_zexth’ defined but not used [-Werror=unused-function] src/jit.c:1760:17: error: ‘do_sexth’ defined but not used [-Werror=unused-function] src/jit.c:1760:17: error: ‘do_sextb’ defined but not used [-Werror=unused-function] src/jit.c:1760:17: error: ‘do_minu’ defined but not used [-Werror=unused-function] src/jit.c:1760:17: error: ‘do_maxu’ defined but not used [-Werror=unused-function] src/jit.c:1760:17: error: ‘do_min’ defined but not used [-Werror=unused-function] src/jit.c:1760:17: error: ‘do_max’ defined but not used [-Werror=unused-function] src/jit.c:1760:17: error: ‘do_cpop’ defined but not used [-Werror=unused-function] src/jit.c:1760:17: error: ‘do_ctz’ defined but not used [-Werror=unused-function] src/jit.c:1760:17: error: ‘do_clz’ defined but not used [-Werror=unused-function] src/jit.c:1760:17: error: ‘do_xnor’ defined but not used [-Werror=unused-function] src/jit.c:1760:17: error: ‘do_orn’ defined but not used [-Werror=unused-function] src/jit.c:1760:17: error: ‘do_andn’ defined but not used [-Werror=unused-function] Include 'Zbb' in EXT_LIST to ensure instructions like 'rev8', 'orcb', and 'rori' are properly handled, resolving unused function errors during JIT builds.
Add a new test case to the CI pipeline to verify JIT functionality when the Zbb extension is disabled. This ensures better coverage and prevents regressions for this specific configuration.
When using 'make ENABLE_Zbc=0 ENABLE_JIT=1', the following errors are observed: src/jit.c:1760:17: error: ‘do_clmulr’ defined but not used [-Werror=unused-function] src/jit.c:1760:17: error: ‘do_clmulh’ defined but not used [-Werror=unused-function] src/jit.c:1760:17: error: ‘do_clmul’ defined but not used [-Werror=unused-function] Include 'Zbc' in EXT_LIST to ensure instructions like 'clmulr', 'clmulh', and 'clmul' are properly handled, resolving unused function errors during JIT builds.
Add a new test case to the CI pipeline when the Zbc is disabled. This ensures better coverage and prevents regressions for this specific configuration.
Add a new test case to the CI pipeline when the Zbs is disabled. This ensures better coverage and prevents regressions for this specific configuration.
89a7356
to
d302919
Compare
src/emulate.c
Outdated
@@ -688,6 +708,7 @@ static void block_translate(riscv_t *rv, block_t *block) | |||
remove_next_nth_ir(rv, ir, block, count - 1); \ | |||
} | |||
|
|||
#if RV32_HAS(MOP_FUSION) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this to line 686, as COMBINE_MEM_OPS
macro is only utilized when MOP_FUSION
is enabled and for readability, such that:
#if RV32_HAS(MOP_FUSION)
#define COMBINE_MEM_OPS(RW)
...
src/emulate.c
Outdated
@@ -702,7 +723,9 @@ static inline void remove_next_nth_ir(const riscv_t *rv, | |||
block->ir_tail = ir; | |||
block->n_insn -= n; | |||
} | |||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this since line 826 cover the condition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack
src/emulate.c
Outdated
|
||
#if RV32_HAS(MOP_FUSION) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this since line 686 cover this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your comment.
I noticed that line 686 isn’t protected by the macro (if RV32_HAS(MOP_FUSION)). Perhaps you mean the code starting from line 711 is protected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your comment. I noticed that line 686 isn’t protected by the macro (if RV32_HAS(MOP_FUSION)). Perhaps you mean the code starting from line 711 is protected?
Check this:
#if RV32_HAS(MOP_FUSION)
#define COMBINE_MEM_OPS(RW)
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. The macro should start covering from line 686 instead, as 'remove_next_nth_ir' is used inside the '#define COMBINE_MEM_OPS(RW)'.
src/emulate.c
Outdated
static uint64_t ctr = 0; | ||
static inline void update_time(riscv_t *rv) | ||
{ | ||
rv->csr_time[0] = ctr & 0xFFFFFFFF; | ||
rv->csr_time[1] = ctr >> 32; | ||
} | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this since line 84 covers the condition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack
src/emulate.c
Outdated
static uint64_t ctr = 0; | ||
static inline void update_time(riscv_t *rv) | ||
{ | ||
rv->csr_time[0] = ctr & 0xFFFFFFFF; | ||
rv->csr_time[1] = ctr >> 32; | ||
} | ||
#endif | ||
|
||
#if RV32_HAS(Zicsr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack
May I know if the remaining tests will still be executed in case any single test fails? |
Based on the current configuration, if any single test fails, the remaining tests will not be executed. Should we consider allowing the other tests to continue running even if one test fails? |
When using 'make ENABLE_Zicsr=0 CC=clang', the following error is observed: src/emulate.c:83:20: error: unused function 'update_time' [-Werror,-Wunused-function] 83 | static inline void update_time(riscv_t *rv) | ^~~~~~~~~~~ 1 error generated Fix this by guarding the update_time function definition with RV32_HAS(Zicsr) macro. This ensures the function is only defined when the Zicsr is enabled.
Yes, I think revealing all errors or warnings at once for each build flag is a better approach. Moreover, the validation process for both compilers only takes around 3 to 5 minutes based on previous actions log. |
When using 'make ENABLE_MOP_FUSION=0 CC=clang', the following error is observed: src/emulate.c:695:20: error: unused function 'remove_next_nth_ir' [-Werror,-Wunused-function] 695 | static inline void remove_next_nth_ir(const riscv_t *rv, | ^~~~~~~~~~~~~~~~~~ 1 error generated. Fix by gurading the 'remove_next_nth_ir' function and the 'COMBINE_MEM_OPS' macro with the 'RV32_HAS(MOP_FUSION)' macro. This ensures both are only included when MOP FUSION is enabled, preventing the Clang warning and maintaining proper functionality.
When using 'make ENABLE_MBLOCK_CHAINING=0 CC=clang', the following errors are observed: src/emulate.c:555:19: error: unused function 'insn_is_unconditional_branch' [-Werror,-Wunused-function] 555 | FORCE_INLINE bool insn_is_unconditional_branch(uint8_t opcode) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/emulate.c:582:19: error: unused function 'insn_is_direct_branch' [-Werror,-Wunused-function] 582 | FORCE_INLINE bool insn_is_direct_branch(uint8_t opcode) | ^~~~~~~~~~~~~~~~~~~~~ Fix this by guarding the 'insn_is_unconditional_branch' and 'insn_is_direct_branch' function definition with RV32_HAS(BLOCK_CHAINING) macro. This ensures the functions are only defined when the BLOCK_CHAINING is enabled.
When using 'make make ENABLE_EXT_C=0 ENABLE_JIT=1 CC=clang', the following errors are observed: rc/t2c.c:77:1: error: unused function 't2c_gen_ra_addr' [-Werror,-Wunused-function] 77 | T2C_LLVM_GEN_ADDR(ra, X, rv_reg_ra); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/t2c.c:64:31: note: expanded from macro 'T2C_LLVM_GEN_ADDR' 64 | FORCE_INLINE LLVMValueRef t2c_gen_##reg##_addr( \ | ^~~~~~~~~~~~~~~~~~~~ <scratch space>:75:1: note: expanded from here 75 | t2c_gen_ra_addr | ^~~~~~~~~~~~~~~ src/t2c.c:78:1: error: unused function 't2c_gen_sp_addr' [-Werror,-Wunused-function] 78 | T2C_LLVM_GEN_ADDR(sp, X, rv_reg_sp); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/t2c.c:64:31: note: expanded from macro 'T2C_LLVM_GEN_ADDR' 64 | FORCE_INLINE LLVMValueRef t2c_gen_##reg##_addr( \ | ^~~~~~~~~~~~~~~~~~~~ Fix this by guarding the 't2c_gen_ra_addr' and 't2c_gen_sp_addr' function definition with RV32_HAS(EXT_C) macro. This ensures the functions are only defined when the EXT_C is enabled.
When using 'make ENABLE_EXT_M=0 ENABLE_JIT=1 CC=clang', the following error is observed: src/jit.c:728:20: error: unused function 'emit_alu64_imm8' [-Werror,-Wunused-function] 728 | static inline void emit_alu64_imm8(struct jit_state *state, | ^~~~~~~~~~~~~~~ Fix this by guarding the 'emit_alu64_imm8' function definition with RV32_HAS(EXT_M) macro. This ensures the function is only defined when the EXT_M is enabled.
When using 'make ENABLE_UBSAN=1 check CC=clang', the following error is observed: src/emulate.c:1110:13: runtime error: call to function do_fuse1 through pointer to incorrect function type 'bool (*)(struct riscv_internal *, const struct rv_insn *, unsigned long, unsigned int)' /home/eleanor/code/rv32emu/src/emulate.c:415: note: do_fuse1 defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/emulate.c:1110:13 After fixing the first error with 'do_fuse1', similar errors were observed for other functions like 'do_fuse2', 'do_fuse3', 'do_fuse4', and 'do_jal'. The root cause was type mismatches in parameter declarations, where 'rv_insn_t *' was used instead of the expected 'const rv_insn_t *'. Since 'do_jal' was generated by the 'RVOP' macro in 'rv32emu_template.c', the macro was also corrected. These changes resolve the UBSAN errors and align all function pointers and implementations.
When building with make 'ENABLE_JIT=1 ENABLE_SYSTEM=1', the following error is observed: src/emulate.c:45:13: error: ‘need_clear_block_map’ defined but not used [-Werror=unused-variable] 45 | static bool need_clear_block_map = false; | ^~~~~~~~~~~~~~~~~~~~ Fix this by guarding the 'need_clear_block_map' definition with the RV32_HAS(SYSTEM) and !RV32_HAS(JIT) macros. This ensures the variable is only defined when the macros indicate it is needed.
Building with 'ENABLE_JIT=1, ENABLE_SYSTEM=1, and ENABLE_ELF_LOADER=0' causes the following errors: src/riscv.c:582:18: error: use of undeclared identifier 'attr' 582 | u8250_delete(attr->uart); | ^ src/riscv.c:583:17: error: use of undeclared identifier 'attr' 583 | plic_delete(attr->plic); | ^ These errors occur because attr is not defined under these conditions. Fix this by adjusting the guard for attr to (RV32_HAS(SYSTEM) && !RV32_HAS(ELF_LOADER)), ensuring it is defined as needed.
Add a new test case to the CI pipeline when the Zifencei is disabled. This ensures better coverage and prevents regressions for this specific configuration.
Add a new test case to the CI pipeline to verify JIT functionality when the Zicsr extension is disabled. This ensures better coverage and prevents regressions for this specific configuration.
Add a new test case to the CI pipeline to verify JIT functionality when the Zifencei extension is disabled. This ensures better coverage and prevents regressions for this specific configuration.
Add a new test case to the CI pipeline to verify JIT functionality when the MOP_FUSION extension is disabled. This ensures better coverage and prevents regressions for this specific configuration.
Add a new test case to the CI pipeline to verify JIT functionality when the BLOCK_CHAINING extension is disabled. This ensures better coverage and prevents regressions for this specific configuration.
In 'mk/toolchain.mk', we have |
d302919
to
3f37f51
Compare
Ensure that subsequent steps are executed regardless of the success or failure of previous steps while providing more explicit control over step execution.
3f37f51
to
99c52b9
Compare
The current action we are using, |
Got it. Looking forward to that! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Thank @eleanorLYJ for contributing! |
Fix build failures and expand test coverage
Fix build issues and enhance build system tests
Improve our build system testing and fix various build issues discovered in the process
CI Improvements
Build Fixes
$(LDFLAGS)
Testing Done