diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f42abd739..a11ecc0ad 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -73,6 +73,18 @@ jobs: run: | make ENABLE_UBSAN=1 clean check make ENABLE_JIT=1 ENABLE_UBSAN=1 clean check + - name: valgrind check (without JIT) + run: | + make clean + make ENABLE_SDL=0 ENABLE_JIT=0 ENABLE_VALGRIND=1 + valgrind --leak-check=full --show-leak-kinds=all --error-exitcode=1 ./build/rv32emu ./build/hello.elf + valgrind --leak-check=full --show-leak-kinds=all --error-exitcode=1 ./build/rv32emu ./build/aes.elf + - name: valgrind check (with JIT) + run: | + make clean + make ENABLE_SDL=0 ENABLE_JIT=1 ENABLE_VALGRIND=1 + valgrind --leak-check=full --show-leak-kinds=all --error-exitcode=1 ./build/rv32emu ./build/hello.elf + valgrind --leak-check=full --show-leak-kinds=all --error-exitcode=1 ./build/rv32emu ./build/aes.elf host-arm64: needs: [detect-code-related-file-changes] diff --git a/Makefile b/Makefile index 63b55fdd9..328e42c27 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,14 @@ CFLAGS = -std=gnu99 -O2 -Wall -Wextra CFLAGS += -Wno-unused-label CFLAGS += -include src/common.h +ENABLE_VALGRIND ?= 0 +ifeq ("$(ENABLE_UBSAN)", "1") +# according to gcc's man page: "If you use multiple -O options, with or without level numbers, the last such option is the one that is effective." +# In order to use Valgrind, we need to compile with -g +CFLAGS += -g +LDFLAGS += -g +endif + # Enable link-time optimization (LTO) ENABLE_LTO ?= 1 ifeq ($(call has, LTO), 1)