]> git.kaiwu.me - quickjs.git/commitdiff
Add UndefinedBehaviorSanitizer support
authorBen Noordhuis <info@bnoordhuis.nl>
Wed, 1 Nov 2023 04:00:43 +0000 (05:00 +0100)
committerCharlie Gordon <github@chqrlie.org>
Sun, 11 Feb 2024 19:37:24 +0000 (20:37 +0100)
Makefile

index e47a5ef9420370a0d806bf0ce39fc90aa70a4312..03d77ed3e423ac64043918ccefcfac6315e7680c 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -46,6 +46,8 @@ PREFIX?=/usr/local
 # use memory sanitizer
 #CONFIG_MSAN=y
 # include the code for BigFloat/BigDecimal, math mode and faster large integers
+# use UB sanitizer
+#CONFIG_UBSAN=y
 CONFIG_BIGNUM=y
 
 OBJDIR=.obj
@@ -148,6 +150,10 @@ ifdef CONFIG_MSAN
 CFLAGS+=-fsanitize=memory -fno-omit-frame-pointer
 LDFLAGS+=-fsanitize=memory -fno-omit-frame-pointer
 endif
+ifdef CONFIG_UBSAN
+CFLAGS+=-fsanitize=undefined -fno-omit-frame-pointer
+LDFLAGS+=-fsanitize=undefined -fno-omit-frame-pointer
+endif
 ifdef CONFIG_WIN32
 LDEXPORT=
 else
@@ -184,6 +190,7 @@ endif
 ifeq ($(CROSS_PREFIX),)
 ifndef CONFIG_ASAN
 ifndef CONFIG_MSAN
+ifndef CONFIG_UBSAN
 PROGS+=examples/hello examples/hello_module examples/test_fib
 ifdef CONFIG_SHARED_LIBS
 PROGS+=examples/fib.so examples/point.so
@@ -191,6 +198,7 @@ endif
 endif
 endif
 endif
+endif
 
 all: $(OBJDIR) $(OBJDIR)/quickjs.check.o $(OBJDIR)/qjs.check.o $(PROGS)