]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Build: Add menuselect options for using compiler sanitizers 17/1417/1
authorIvan Poddubny <ivan.poddubny@gmail.com>
Sat, 10 Oct 2015 20:20:55 +0000 (23:20 +0300)
committerIvan Poddubny <ivan.poddubny@gmail.com>
Mon, 12 Oct 2015 18:23:13 +0000 (21:23 +0300)
This patch adds menuselect options for building Asterisk with
various sanitizers provided by gcc and clang.

When one of *SANITIZER flags is set in menuselect, the appropriate
option is added to CFLAGS ad LDFLAGS for the build.

Information on sanitizers in the project wiki:
https://github.com/google/sanitizers/wiki

GCC Manual:
https://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html

Clang Compiler User's Manual:
http://clang.llvm.org/docs/UsersManual.html#controlling-code-generation

ASTERISK-24718 #close
Reported by: Badalian Vyacheslav

Change-Id: Iafa51b792b7bcb20e848b99d16cf362d08590fa0

Makefile.rules
build_tools/cflags.xml

index 54df636c2f050a76e46825214755f7f8775f0430..d5dd5e39a4a54a105c67abb4fe07ff69eb1c5c84 100644 (file)
 # 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=@
index 95af0acb4190269409e147020a301cc36ca70707..b5c447be6abbd6b442ddb59d8298281fcfd41ef9 100644 (file)
                <member name="MALLOC_DEBUG" displayname="Keep Track of Memory Allocations">
                        <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>
+               </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>
+               </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>