Skip to content

Commit 6e5e324

Browse files
committed
Add ENABLE_UBSAN option in Makefile for undefined behavior detection
Add support for the ENABLE_UBSAN option in the Makefile, enabling the use of UBSan for detecting undefined behavior during testing.
1 parent d511c1e commit 6e5e324

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,12 @@ ifeq ("$(CC_IS_EMCC)", "1")
136136
CFLAGS += -mtail-call
137137
endif
138138

139+
ENABLE_UBSAN ?= 0
140+
ifeq ("$(ENABLE_UBSAN)", "1")
141+
CFLAGS += -fsanitize=undefined -fno-sanitize=alignment -fno-sanitize-recover=all
142+
LDFLAGS += -fsanitize=undefined -fno-sanitize=alignment -fno-sanitize-recover=all
143+
endif
144+
139145
$(OUT)/emulate.o: CFLAGS += -foptimize-sibling-calls -fomit-frame-pointer -fno-stack-check -fno-stack-protector
140146

141147
# Clear the .DEFAULT_GOAL special variable, so that the following turns

0 commit comments

Comments
 (0)