diff --git a/Makefile.rules b/Makefile.rules index a274c9572913587b093132540f3f98ddeb27b85c..1031f2defe38bd1e934e6d66cfb4016d628d5828 100644 --- a/Makefile.rules +++ b/Makefile.rules @@ -27,6 +27,26 @@ # extra cflags to build dependencies. Recursively expanded. MAKE_DEPS=-MD -MT $@ -MF .$(subst /,_,$@).d -MP +ifeq ($(findstring ADDRESS_SANITIZER,$(MENUSELECT_CFLAGS)),ADDRESS_SANITIZER) + _ASTLDFLAGS+=-fsanitize=address + _ASTCFLAGS+=-fno-omit-frame-pointer -fsanitize=address +endif + +ifeq ($(findstring THREAD_SANITIZER,$(MENUSELECT_CFLAGS)),THREAD_SANITIZER) + _ASTLDFLAGS+=-fsanitize=thread -pie -fPIE + _ASTCFLAGS+=-fno-omit-frame-pointer -pie -fPIE -fsanitize=thread +endif + +ifeq ($(findstring LEAK_SANITIZER,$(MENUSELECT_CFLAGS)),LEAK_SANITIZER) + _ASTLDFLAGS+=-fsanitize=leak + _ASTCFLAGS+=-fno-omit-frame-pointer -fsanitize=leak +endif + +ifeq ($(findstring UNDEFINED_SANITIZER,$(MENUSELECT_CFLAGS)),UNDEFINED_SANITIZER) + _ASTLDFLAGS+=-fsanitize=undefined + _ASTCFLAGS+=-fno-omit-frame-pointer -fsanitize=undefined +endif + ifeq ($(NOISY_BUILD),) ECHO_PREFIX=@ CMD_PREFIX=@ diff --git a/build_tools/cflags.xml b/build_tools/cflags.xml index b91cf5af5b28ba27752d0e1c12dc44df53db94d7..43f7d5612331f68fbee66b3c828434678ba999a2 100644 --- a/build_tools/cflags.xml +++ b/build_tools/cflags.xml @@ -84,6 +84,34 @@ <conflict>MALLOC_DEBUG</conflict> <support_level>core</support_level> </member> + <member name="ADDRESS_SANITIZER" displayname="Address Sanitizer"> + <support_level>extended</support_level> + <conflict>THREAD_SANITIZER</conflict> + <conflict>LEAK_SANITIZER</conflict> + <conflict>UNDEFINED_SANITIZER</conflict> + <conflict>MALLOC_DEBUG</conflict> + <conflict>DEBUG_CHAOS</conflict> + </member> + <member name="THREAD_SANITIZER" displayname="Thread Sanitizer"> + <support_level>extended</support_level> + <conflict>ADDRESS_SANITIZER</conflict> + <conflict>LEAK_SANITIZER</conflict> + <conflict>UNDEFINED_SANITIZER</conflict> + </member> + <member name="LEAK_SANITIZER" displayname="Leak Sanitizer"> + <support_level>extended</support_level> + <conflict>ADDRESS_SANITIZER</conflict> + <conflict>THREAD_SANITIZER</conflict> + <conflict>UNDEFINED_SANITIZER</conflict> + <conflict>MALLOC_DEBUG</conflict> + <conflict>DEBUG_CHAOS</conflict> + </member> + <member name="UNDEFINED_SANITIZER" displayname="Undefined Behavior Sanitizer"> + <support_level>extended</support_level> + <conflict>ADDRESS_SANITIZER</conflict> + <conflict>THREAD_SANITIZER</conflict> + <conflict>LEAK_SANITIZER</conflict> + </member> <member name="BUSYDETECT_TONEONLY" displayname="Enable additional comparision of only the tone duration not the silence part"> <conflict>BUSYDETECT_COMPARE_TONE_AND_SILENCE</conflict> <defaultenabled>no</defaultenabled>