summaryrefslogtreecommitdiff
path: root/Makefile.rules
diff options
context:
space:
mode:
authorIvan Poddubny <ivan.poddubny@gmail.com>2015-10-10 23:20:55 +0300
committerIvan Poddubny <ivan.poddubny@gmail.com>2015-10-12 13:31:32 -0500
commit486b172b50ae5b525d03ea7467bdb4ffa7ad90fd (patch)
tree2c53eb70d40f715f7874d98cfe9a8676d6c85915 /Makefile.rules
parent1c799b1f1ecc37b7fb39dd205a35720e16fe37d7 (diff)
Build: Add menuselect options for using compiler sanitizers
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
Diffstat (limited to 'Makefile.rules')
-rw-r--r--Makefile.rules20
1 files changed, 20 insertions, 0 deletions
diff --git a/Makefile.rules b/Makefile.rules
index a274c9572..1031f2def 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=@