Add UndefinedBehaviorSanitizer support

This commit is contained in:
Ben Noordhuis 2023-11-01 05:00:43 +01:00
parent a9957cdcee
commit 83e6fca8be

View file

@ -50,6 +50,8 @@ prefix=/usr/local
#CONFIG_ASAN=y #CONFIG_ASAN=y
# use memory sanitizer # use memory sanitizer
#CONFIG_MSAN=y #CONFIG_MSAN=y
# use UB sanitizer
#CONFIG_UBSAN=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
@ -133,6 +135,10 @@ ifdef CONFIG_MSAN
CFLAGS+=-fsanitize=memory -fno-omit-frame-pointer CFLAGS+=-fsanitize=memory -fno-omit-frame-pointer
LDFLAGS+=-fsanitize=memory -fno-omit-frame-pointer LDFLAGS+=-fsanitize=memory -fno-omit-frame-pointer
endif endif
ifdef CONFIG_UBSAN
CFLAGS+=-fsanitize=undefined -fno-omit-frame-pointer
LDFLAGS+=-fsanitize=undefined -fno-omit-frame-pointer
endif
ifdef CONFIG_WIN32 ifdef CONFIG_WIN32
LDEXPORT= LDEXPORT=
else else
@ -163,6 +169,7 @@ endif
ifeq ($(CROSS_PREFIX),) ifeq ($(CROSS_PREFIX),)
ifndef CONFIG_ASAN ifndef CONFIG_ASAN
ifndef CONFIG_MSAN ifndef CONFIG_MSAN
ifndef CONFIG_UBSAN
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
@ -170,6 +177,7 @@ endif
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)