Build: Added testing compiler to support the system sanitizes
authorBadalyan Vyacheslav <slavon.net@gmail.com>
Wed, 10 Feb 2016 05:40:32 +0000 (05:40 +0000)
committerBadalyan Vyacheslav <slavon.net@gmail.com>
Wed, 10 Feb 2016 05:40:32 +0000 (05:40 +0000)
In older versions of the compiler was not sanitizes.
Compilers other than GCC can not support the Usan and TSAN
or have other options for *FLAGS.

ASTERISK-25767 #close
Reported by: Badalyan Vyacheslav
Tested by: Badalyan Vyacheslav

Change-Id: Iefce6608221fa87884b82ae3cb5649b7b1804916

build_tools/cflags.xml
build_tools/menuselect-deps.in
configure
configure.ac

index 43f7d56..763f07e 100644 (file)
@@ -85,6 +85,7 @@
                        <support_level>core</support_level>
                </member>
                <member name="ADDRESS_SANITIZER" displayname="Address Sanitizer">
+                       <depend>HAVE_ADDRESS_SANITIZER</depend>
                        <support_level>extended</support_level>
                        <conflict>THREAD_SANITIZER</conflict>
                        <conflict>LEAK_SANITIZER</conflict>
                        <conflict>DEBUG_CHAOS</conflict>
                </member>
                <member name="THREAD_SANITIZER" displayname="Thread Sanitizer">
+                       <depend>HAVE_THREAD_SANITIZER</depend>
                        <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">
+                       <depend>HAVE_LEAK_SANITIZER</depend>
                        <support_level>extended</support_level>
                        <conflict>ADDRESS_SANITIZER</conflict>
                        <conflict>THREAD_SANITIZER</conflict>
                        <conflict>DEBUG_CHAOS</conflict>
                </member>
                <member name="UNDEFINED_SANITIZER" displayname="Undefined Behavior Sanitizer">
+                       <depend>HAVE_UNDEFINED_SANITIZER</depend>
                        <support_level>extended</support_level>
                        <conflict>ADDRESS_SANITIZER</conflict>
                        <conflict>THREAD_SANITIZER</conflict>
index edeb848..f194482 100644 (file)
@@ -73,3 +73,7 @@ WINARCH=@PBX_WINARCH@
 ZLIB=@PBX_ZLIB@
 TIMERFD=@PBX_TIMERFD@
 NATIVE_ARCH=@AST_NATIVE_ARCH@
+HAVE_ADDRESS_SANITIZER=@AST_ADDRESS_SANITIZER@
+HAVE_LEAK_SANITIZER=@AST_LEAK_SANITIZER@
+HAVE_THREAD_SANITIZER=@AST_THREAD_SANITIZER@
+HAVE_UNDEFINED_SANITIZER=@AST_UNDEFINED_SANITIZER@
index c382032..a7ddb51 100755 (executable)
--- a/configure
+++ b/configure
@@ -697,6 +697,10 @@ AST_TRAMPOLINES
 AST_DECLARATION_AFTER_STATEMENT
 GC_LDFLAGS
 GC_CFLAGS
+AST_UNDEFINED_SANITIZER
+AST_LEAK_SANITIZER
+AST_THREAD_SANITIZER
+AST_ADDRESS_SANITIZER
 PBX_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
 PBX_PTHREAD_RWLOCK_INITIALIZER
 AST_ASTERISKSSL
@@ -17613,6 +17617,134 @@ CFLAGS="$saved_CFLAGS"
 
 
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for -fsanitize=address support" >&5
+$as_echo_n "checking for -fsanitize=address support... " >&6; }
+saved_sanitize_CFLAGS="${CFLAGS}"
+saved_sanitize_LDFLAGS="${LDFLAGS}"
+CFLAGS="-fsanitize=address -fno-omit-frame-pointer"
+LDFLAGS="-fsanitize=address"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+int x = 1;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+       AST_ADDRESS_SANITIZER=1
+else
+  AST_ADDRESS_SANITIZER=
+       { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+CFLAGS="${saved_sanitize_CFLAGS}"
+LDFLAGS="${saved_sanitize_LDFLAGS}"
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for -fsanitize=thread support" >&5
+$as_echo_n "checking for -fsanitize=thread support... " >&6; }
+saved_sanitize_CFLAGS="${CFLAGS}"
+saved_sanitize_LDFLAGS="${LDFLAGS}"
+CFLAGS="-fno-omit-frame-pointer -pie -fPIE -fsanitize=thread"
+LDFLAGS="-fsanitize=thread -pie -fPIE"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+int x = 1;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+       AST_THREAD_SANITIZER=1
+else
+  AST_THREAD_SANITIZER=
+       { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+CFLAGS="${saved_sanitize_CFLAGS}"
+LDFLAGS="${saved_sanitize_LDFLAGS}"
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for -fsanitize=leak support" >&5
+$as_echo_n "checking for -fsanitize=leak support... " >&6; }
+saved_sanitize_CFLAGS="${CFLAGS}"
+saved_sanitize_LDFLAGS="${LDFLAGS}"
+CFLAGS="-fno-omit-frame-pointer -fsanitize=leak"
+LDFLAGS="-fsanitize=leak"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+int x = 1;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+       AST_LEAK_SANITIZER=1
+else
+  AST_LEAK_SANITIZER=
+       { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+CFLAGS="${saved_sanitize_CFLAGS}"
+LDFLAGS="${saved_sanitize_LDFLAGS}"
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for -fsanitize=undefined support" >&5
+$as_echo_n "checking for -fsanitize=undefined support... " >&6; }
+saved_sanitize_CFLAGS="${CFLAGS}"
+saved_sanitize_LDFLAGS="${LDFLAGS}"
+CFLAGS="-fno-omit-frame-pointer -fsanitize=undefined"
+LDFLAGS="-fsanitize=undefined"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+int x = 1;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+       AST_UNDEFINED_SANITIZER=1
+else
+  AST_UNDEFINED_SANITIZER=
+       { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+CFLAGS="${saved_sanitize_CFLAGS}"
+LDFLAGS="${saved_sanitize_LDFLAGS}"
+
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -ffunction-sections support" >&5
 $as_echo_n "checking for -ffunction-sections support... " >&6; }
 saved_CFLAGS="${CFLAGS}"
index 723b0af..14b63da 100644 (file)
@@ -1051,6 +1051,70 @@ AST_GCC_ATTRIBUTE(may_alias)
 AST_GCC_ATTRIBUTE(constructor)
 AST_GCC_ATTRIBUTE(destructor)
 
+AC_MSG_CHECKING(for -fsanitize=address support)
+saved_sanitize_CFLAGS="${CFLAGS}"
+saved_sanitize_LDFLAGS="${LDFLAGS}"
+CFLAGS="-fsanitize=address -fno-omit-frame-pointer"
+LDFLAGS="-fsanitize=address"
+AC_COMPILE_IFELSE(
+       [AC_LANG_PROGRAM([], [int x = 1;])],
+       AC_MSG_RESULT(yes)
+       [AST_ADDRESS_SANITIZER=1],
+       [AST_ADDRESS_SANITIZER=]
+       AC_MSG_RESULT(no)
+)
+CFLAGS="${saved_sanitize_CFLAGS}"
+LDFLAGS="${saved_sanitize_LDFLAGS}"
+AC_SUBST(AST_ADDRESS_SANITIZER)
+
+AC_MSG_CHECKING(for -fsanitize=thread support)
+saved_sanitize_CFLAGS="${CFLAGS}"
+saved_sanitize_LDFLAGS="${LDFLAGS}"
+CFLAGS="-fno-omit-frame-pointer -pie -fPIE -fsanitize=thread"
+LDFLAGS="-fsanitize=thread -pie -fPIE"
+AC_COMPILE_IFELSE(
+       [AC_LANG_PROGRAM([], [int x = 1;])],
+       AC_MSG_RESULT(yes)
+       [AST_THREAD_SANITIZER=1],
+       [AST_THREAD_SANITIZER=]
+       AC_MSG_RESULT(no)
+)
+CFLAGS="${saved_sanitize_CFLAGS}"
+LDFLAGS="${saved_sanitize_LDFLAGS}"
+AC_SUBST(AST_THREAD_SANITIZER)
+
+AC_MSG_CHECKING(for -fsanitize=leak support)
+saved_sanitize_CFLAGS="${CFLAGS}"
+saved_sanitize_LDFLAGS="${LDFLAGS}"
+CFLAGS="-fno-omit-frame-pointer -fsanitize=leak"
+LDFLAGS="-fsanitize=leak"
+AC_COMPILE_IFELSE(
+       [AC_LANG_PROGRAM([], [int x = 1;])],
+       AC_MSG_RESULT(yes)
+       [AST_LEAK_SANITIZER=1],
+       [AST_LEAK_SANITIZER=]
+       AC_MSG_RESULT(no)
+)
+CFLAGS="${saved_sanitize_CFLAGS}"
+LDFLAGS="${saved_sanitize_LDFLAGS}"
+AC_SUBST(AST_LEAK_SANITIZER)
+
+AC_MSG_CHECKING(for -fsanitize=undefined support)
+saved_sanitize_CFLAGS="${CFLAGS}"
+saved_sanitize_LDFLAGS="${LDFLAGS}"
+CFLAGS="-fno-omit-frame-pointer -fsanitize=undefined"
+LDFLAGS="-fsanitize=undefined"
+AC_COMPILE_IFELSE(
+       [AC_LANG_PROGRAM([], [int x = 1;])],
+       AC_MSG_RESULT(yes)
+       [AST_UNDEFINED_SANITIZER=1],
+       [AST_UNDEFINED_SANITIZER=]
+       AC_MSG_RESULT(no)
+)
+CFLAGS="${saved_sanitize_CFLAGS}"
+LDFLAGS="${saved_sanitize_LDFLAGS}"
+AC_SUBST(AST_UNDEFINED_SANITIZER)
+
 AC_MSG_CHECKING(for -ffunction-sections support)
 saved_CFLAGS="${CFLAGS}"
 CFLAGS="${CFLAGS} -ffunction-sections"