[Asterisk-code-review] Build: Added testing compiler to support the system sanitizes (asterisk[11])

Anonymous Coward asteriskteam at digium.com
Wed Feb 10 13:24:54 CST 2016


Anonymous Coward #1000019 has submitted this change and it was merged.

Change subject: Build: Added testing compiler to support the system sanitizes
......................................................................


Build: Added testing compiler to support the system sanitizes

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
---
M build_tools/cflags.xml
M build_tools/menuselect-deps.in
M configure
M configure.ac
4 files changed, 204 insertions(+), 0 deletions(-)

Approvals:
  Anonymous Coward #1000019: Verified
  Joshua Colp: Looks good to me, approved
  George Joseph: Looks good to me, but someone else must approve



diff --git a/build_tools/cflags.xml b/build_tools/cflags.xml
index b5c447b..0b8852b 100644
--- a/build_tools/cflags.xml
+++ b/build_tools/cflags.xml
@@ -64,6 +64,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>
@@ -71,12 +72,14 @@
 			<conflict>MALLOC_DEBUG</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>
@@ -84,6 +87,7 @@
 			<conflict>MALLOC_DEBUG</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>
diff --git a/build_tools/menuselect-deps.in b/build_tools/menuselect-deps.in
index 2b5efc4..e9d3296 100644
--- a/build_tools/menuselect-deps.in
+++ b/build_tools/menuselect-deps.in
@@ -70,3 +70,7 @@
 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@
diff --git a/configure b/configure
index 569c428..1598f29 100755
--- a/configure
+++ b/configure
@@ -695,6 +695,10 @@
 AST_DECLARATION_AFTER_STATEMENT
 GC_LDFLAGS
 GC_CFLAGS
+AST_UNDEFINED_SANITIZER
+AST_LEAK_SANITIZER
+AST_THREAD_SANITIZER
+AST_ADDRESS_SANITIZER
 PBX_WEAKREF
 PBX_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
 PBX_PTHREAD_RWLOCK_INITIALIZER
@@ -16334,6 +16338,134 @@
 	;;
 esac
 
+{ $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}"
diff --git a/configure.ac b/configure.ac
index 997df00..5d03ecd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -965,6 +965,70 @@
 	;;
 esac
 
+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"

-- 
To view, visit https://gerrit.asterisk.org/2234
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Iefce6608221fa87884b82ae3cb5649b7b1804916
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 11
Gerrit-Owner: Badalian Vyacheslav <v.badalyan at open-bs.ru>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: George Joseph <george.joseph at fairview5.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>



More information about the asterisk-code-review mailing list