Support ASAN and UBSAN in Makefiles
This commit is contained in:
parent
42459f72c1
commit
3d20a3974c
19
Makefile
19
Makefile
|
@ -575,6 +575,25 @@ CXXFLAGS += -DNETSURF_HOMEPAGE=\"$(NETSURF_HOMEPAGE)\"
|
|||
CFLAGS += -DNETSURF_LOG_LEVEL=$(NETSURF_LOG_LEVEL)
|
||||
CXXFLAGS += -DNETSURF_LOG_LEVEL=$(NETSURF_LOG_LEVEL)
|
||||
|
||||
# If we're building the sanitizer goal, override things
|
||||
ifneq ($(filter-out sanitize,$(MAKECMDGOALS)),$(MAKECMDGOALS))
|
||||
override NETSURF_USE_SANITIZER := YES
|
||||
override NETSURF_RECOVER_SANITIZERS := NO
|
||||
endif
|
||||
|
||||
# If we're going to use the sanitizer set it up
|
||||
ifeq ($(NETSURF_USE_SANITIZER),YES)
|
||||
SAN_FLAGS := -fsanitize=address -fsanitize=undefined
|
||||
ifeq ($(NETSURF_RECOVER_SANITIZERS),NO)
|
||||
SAN_FLAGS += -fno-sanitize-recover
|
||||
endif
|
||||
else
|
||||
SAN_FLAGS :=
|
||||
endif
|
||||
CFLAGS += $(SAN_FLAGS)
|
||||
CXXFLAGS += $(SAN_FLAGS)
|
||||
LDFLAGS += $(SAN_FLAGS)
|
||||
|
||||
# and the logging filter
|
||||
CFLAGS += -DNETSURF_BUILTIN_LOG_FILTER=\"$(NETSURF_BUILTIN_LOG_FILTER)\"
|
||||
CXXFLAGS += -DNETSURF_BUILTIN_LOG_FILTER=\"$(NETSURF_BUILTIN_LOG_FILTER)\"
|
||||
|
|
|
@ -33,3 +33,9 @@
|
|||
|
||||
### To change flags to javascript binding generator
|
||||
# GBFLAGS:=-g
|
||||
|
||||
### To enable ASAN and UBSAN support in builds regardless of target
|
||||
# override NETSURF_USE_SANITIZERS := YES
|
||||
|
||||
### If you're using the sanitizers and you want it to stop on failure...
|
||||
# override NETSURF_RECOVER_SANITIZERS := NO
|
||||
|
|
|
@ -109,6 +109,11 @@ NETSURF_USE_LIBICONV_PLUG := YES
|
|||
# Valid options: YES, NO
|
||||
NETSURF_FS_BACKING_STORE := NO
|
||||
|
||||
# Enable the ASAN and UBSAN flags regardless of targets
|
||||
NETSURF_USE_SANITIZERS := NO
|
||||
# But recover after sanitizer failure
|
||||
NETSURF_RECOVER_SANITIZERS := YES
|
||||
|
||||
# Initial CFLAGS. Optimisation level etc. tend to be target specific.
|
||||
CFLAGS :=
|
||||
|
||||
|
|
|
@ -141,6 +141,7 @@ BASE_TESTCFLAGS := -std=c99 -g \
|
|||
-D_XOPEN_SOURCE=600 \
|
||||
-Itest -Iinclude -Icontent/handlers -Ifrontends -I. -I.. \
|
||||
-Dnsgtk \
|
||||
$(SAN_FLAGS) \
|
||||
$(shell pkg-config --cflags libcurl libparserutils libwapcaplet libdom libnsutils libutf8proc) \
|
||||
$(LIB_CFLAGS)
|
||||
TESTCFLAGS := $(BASE_TESTCFLAGS) \
|
||||
|
@ -149,6 +150,7 @@ TESTCFLAGS := $(BASE_TESTCFLAGS) \
|
|||
|
||||
TESTLDFLAGS := -L$(TESTROOT) \
|
||||
$(shell pkg-config --libs libcurl libparserutils libwapcaplet libdom libnsutils libutf8proc) -lz \
|
||||
$(SAN_FLAGS) \
|
||||
$(LIB_LDFLAGS)\
|
||||
$(COV_LDFLAGS)
|
||||
|
||||
|
@ -202,11 +204,12 @@ $(eval $(foreach SOURCE,$(sort $(filter %.c,$(NOCOV_TESTSOURCES))), \
|
|||
$(call compile_test_nocov_target_c,$(SOURCE),$(subst /,_,$(SOURCE:.c=.o)),$(subst /,_,$(SOURCE:.c=.d)))))
|
||||
|
||||
|
||||
.PHONY:test coverage
|
||||
.PHONY:test coverage sanitize
|
||||
|
||||
test: $(TESTROOT)/created $(TESTROOT)/libmalloc_fig.so $(addsuffix _test,$(TESTS))
|
||||
|
||||
coverage: test
|
||||
sanitize: test
|
||||
|
||||
$(TESTROOT)/created:
|
||||
$(VQ)echo " MKDIR: $(TESTROOT)"
|
||||
|
|
Loading…
Reference in New Issue