Rename CLANG_DEBUG_FLAGS -> ASAN_FLAGS in makefile and enable them for GCC, because GCC supports ASan these days

git-svn-id: https://svn.eduke32.com/eduke32@6549 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2017-12-10 03:24:39 +00:00
parent 882877054b
commit b65458ebfe
2 changed files with 17 additions and 11 deletions

View file

@ -585,21 +585,27 @@ ifneq ($(ALLOCACHE_AS_MALLOC),0)
COMPILERFLAGS += -DDEBUG_ALLOCACHE_AS_MALLOC COMPILERFLAGS += -DDEBUG_ALLOCACHE_AS_MALLOC
endif endif
# See http://clang.llvm.org/docs/UsersManual.html#controlling-code-generation # See https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
# for a list of possible UBSan options. # and https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.html
# Clang 3.2 does only supports -fsanitize=address for the AddressSanitizer # for a list of possible ASan and UBsan options.
CLANG_DEBUG_FLAGS := -fsanitize=address -fsanitize=bounds,enum,float-cast-overflow,object-size
#CLANG_DEBUG_FLAGS := $(CLANG_DEBUG_FLAGS),signed-integer-overflow ASAN_FLAGS := -fsanitize=address -fsanitize=bounds,enum,float-cast-overflow
#CLANG_DEBUG_FLAGS := $(CLANG_DEBUG_FLAGS),unsigned-integer-overflow ASAN_FLAGS := $(ASAN_FLAGS),signed-integer-overflow,unsigned-integer-overflow
#CLANG_DEBUG_FLAGS := $(CLANG_DEBUG_FLAGS) -fsanitize-undefined-trap-on-error ASAN_FLAGS := $(ASAN_FLAGS),undefined,return,null,pointer-overflow,float-divide-by-zero
#ASAN_FLAGS := $(ASAN_FLAGS) -fsanitize-undefined-trap-on-error
ifeq (0,$(FORCEDEBUG)) ifeq (0,$(FORCEDEBUG))
COMPILERFLAGS += -DNDEBUG COMPILERFLAGS += -DNDEBUG
else else
COMPILERFLAGS += -DDEBUGGINGAIDS=$(FORCEDEBUG) COMPILERFLAGS += -DDEBUGGINGAIDS=$(FORCEDEBUG)
ifneq (0,$(CLANG))
ifeq (2,$(FORCEDEBUG)) ifeq (2,$(FORCEDEBUG))
COMMONFLAGS += $(CLANG_DEBUG_FLAGS) ifneq (0,$(CLANG))
COMMONFLAGS += $(ASAN_FLAGS)
else ifneq (,$(filter 1 2 3 4 5 6,$(GCC_MAJOR)))
ifneq (,$(filter 0 1,$(GCC_MINOR)))
COMMONFLAGS += $(ASAN_FLAGS)
endif
endif endif
endif endif
endif endif

View file

@ -955,7 +955,7 @@ $(foreach i,$(components),$(eval $(call OBJECTRULES,$i)))
# Comment out the following rule to debug a-c.o # Comment out the following rule to debug a-c.o
$(engine_obj)/a-c.$o: $(engine_src)/a-c.cpp | $(engine_obj) $(engine_obj)/a-c.$o: $(engine_src)/a-c.cpp | $(engine_obj)
$(COMPILE_STATUS) $(COMPILE_STATUS)
$(RECIPE_IF) $(subst -O$(OPTLEVEL),-O2,$(subst $(CLANG_DEBUG_FLAGS),,$(COMPILER_CXX))) $(engine_cflags) -c $< -o $@ $(RECIPE_RESULT_COMPILE) $(RECIPE_IF) $(subst -O$(OPTLEVEL),-O2,$(subst $(ASAN_FLAGS),,$(COMPILER_CXX))) $(engine_cflags) -c $< -o $@ $(RECIPE_RESULT_COMPILE)
$(engine_obj)/rev.$o: $(engine_src)/rev.cpp | $(engine_obj) $(engine_obj)/rev.$o: $(engine_src)/rev.cpp | $(engine_obj)
$(COMPILE_STATUS) $(COMPILE_STATUS)