Add MemorySanitizer support

This commit is contained in:
Ben Noordhuis 2023-11-01 04:30:34 +01:00
parent f8b3a2e93c
commit cd4579d106

View file

@ -48,6 +48,8 @@ prefix=/usr/local
#CONFIG_PROFILE=y #CONFIG_PROFILE=y
# use address sanitizer # use address sanitizer
#CONFIG_ASAN=y #CONFIG_ASAN=y
# use memory sanitizer
#CONFIG_MSAN=y
# include the code for BigInt/BigFloat/BigDecimal and math mode # include the code for BigInt/BigFloat/BigDecimal and math mode
CONFIG_BIGNUM=y CONFIG_BIGNUM=y
@ -127,6 +129,10 @@ ifdef CONFIG_ASAN
CFLAGS+=-fsanitize=address -fno-omit-frame-pointer CFLAGS+=-fsanitize=address -fno-omit-frame-pointer
LDFLAGS+=-fsanitize=address -fno-omit-frame-pointer LDFLAGS+=-fsanitize=address -fno-omit-frame-pointer
endif endif
ifdef CONFIG_MSAN
CFLAGS+=-fsanitize=memory -fno-omit-frame-pointer
LDFLAGS+=-fsanitize=memory -fno-omit-frame-pointer
endif
ifdef CONFIG_WIN32 ifdef CONFIG_WIN32
LDEXPORT= LDEXPORT=
else else
@ -155,15 +161,15 @@ endif
# examples # examples
ifeq ($(CROSS_PREFIX),) ifeq ($(CROSS_PREFIX),)
ifdef CONFIG_ASAN ifndef CONFIG_ASAN
PROGS+= ifndef CONFIG_MSAN
else
PROGS+=examples/hello examples/hello_module examples/test_fib PROGS+=examples/hello examples/hello_module examples/test_fib
ifndef CONFIG_DARWIN ifndef CONFIG_DARWIN
PROGS+=examples/fib.so examples/point.so PROGS+=examples/fib.so examples/point.so
endif endif
endif endif
endif endif
endif
all: $(OBJDIR) $(OBJDIR)/quickjs.check.o $(OBJDIR)/qjs.check.o $(PROGS) all: $(OBJDIR) $(OBJDIR)/quickjs.check.o $(OBJDIR)/qjs.check.o $(PROGS)