Skip to content

Commit dc98a6c

Browse files
liuzikaiPeterRugg
authored andcommitted
Fix C emulator and test script for OCaml emulator
The generated C emulator misses z_set_Misa_C. Supply a dummy implementation. Fix the test script to supply dtc to OCaml emulator for non-Linux machine.
1 parent a4b72e9 commit dc98a6c

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ BBV_DIR?=../bbv
188188
C_WARNINGS ?=
189189
#-Wall -Wextra -Wno-unused-label -Wno-unused-parameter -Wno-unused-but-set-variable -Wno-unused-function
190190
C_INCS = $(addprefix $(SAIL_RISCV_DIR)/c_emulator/,riscv_prelude.h riscv_platform_impl.h riscv_platform.h riscv_softfloat.h)
191-
C_SRCS = $(addprefix $(SAIL_RISCV_DIR)/c_emulator/,riscv_prelude.c riscv_platform_impl.c riscv_platform.c riscv_softfloat.c)
191+
C_SRCS = $(addprefix $(SAIL_RISCV_DIR)/c_emulator/,riscv_prelude.c riscv_platform_impl.c riscv_platform.c riscv_softfloat.c) handwritten_support/c_emulator_fix.c
192192

193193
SOFTFLOAT_DIR = $(SAIL_RISCV_DIR)/c_emulator/SoftFloat-3e
194194
SOFTFLOAT_INCDIR = $(SOFTFLOAT_DIR)/source/include

handwritten_support/c_emulator_fix.c

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/* The generated C emulator is missing this function.
2+
Up to this point, only used by --disable-compressed/-C.
3+
Make a dummy implementation of it.
4+
*/
5+
6+
#include <stdio.h>
7+
#include <stdlib.h>
8+
#include <stdint.h>
9+
10+
struct zMisa;
11+
12+
typedef int unit;
13+
typedef uint64_t mach_bits;
14+
15+
unit z_set_Misa_C(struct zMisa *, mach_bits) {
16+
fprintf(stderr, "z_set_Misa_C is not supported\n");
17+
exit(EXIT_FAILURE);
18+
}

test/run_tests.sh

+7-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ cd $DIR
66
RISCVDIR="$DIR/.."
77
RISCVTESTDIR="$RISCVDIR/sail-riscv/test"
88

9+
DTC_PATH=$(which dtc)
10+
if [ -z "$DTC_PATH" ]; then
11+
echo "dtc not found. Install it via your package manager."
12+
exit 1
13+
fi
14+
915
RED='\033[0;91m'
1016
GREEN='\033[0;92m'
1117
YELLOW='\033[0;93m'
@@ -71,7 +77,7 @@ for test in $RISCVTESTDIR/riscv-tests/rv64*.elf; do
7177
if [[ $(basename $test) =~ $pat ]];
7278
then continue
7379
fi
74-
if $RISCVDIR/ocaml_emulator/cheri_riscv_ocaml_sim_RV64 "$test" >"${test/.elf/.out}" 2>&1 && grep -q SUCCESS "${test/.elf/.out}"
80+
if $RISCVDIR/ocaml_emulator/cheri_riscv_ocaml_sim_RV64 -with-dtc "$DTC_PATH" "$test" >"${test/.elf/.out}" 2>&1 && grep -q SUCCESS "${test/.elf/.out}"
7581
then
7682
green "OCaml-64 $(basename $test)" "ok"
7783
else

0 commit comments

Comments
 (0)