]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Check if sanitize-address-use-after-scope is support
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 5 Jul 2017 19:23:49 +0000 (15:23 -0400)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 5 Jul 2017 19:23:55 +0000 (15:23 -0400)
configure
configure.ac
m4/ax_cc.m4

index 6aa0cd93885fd40cbbbdad0bdbe96fd4b8e738c0..49c8bcab01e3d2e9c5d2f569f267363457d47057 100755 (executable)
--- a/configure
+++ b/configure
@@ -2460,6 +2460,8 @@ ac_config_headers="$ac_config_headers src/include/autoconf.h"
 
 
 
+
+
 
 
 
@@ -12460,7 +12462,59 @@ $as_echo "$ax_cv_cc_weverything_flag" >&6; }
   fi
 
         if test "x$llvm_address_sanitizer" = "xyes" && test "x$ax_cv_cc_clang" = "xyes"; then
-    devcflags="$devcflags -fsanitize=address -fsanitize-address-use-after-scope -fno-omit-frame-pointer"
+    devcflags="$devcflags -fsanitize=address -fno-omit-frame-pointer"
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for the compiler flag \"-fsanitize-address-use-after-scope\"" >&5
+$as_echo_n "checking for the compiler flag \"-fsanitize-address-use-after-scope\"... " >&6; }
+if ${ax_cv_cc_sanitize_address_use_after_scope+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+
+
+        CFLAGS_SAVED=$CFLAGS
+    CFLAGS="$CFLAGS -Werror -fsanitize=address -fsanitize-address-use-after-scope"
+
+    ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+return 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ax_cv_cc_sanitize_address_use_after_scope="yes"
+else
+  ax_cv_cc_sanitize_address_use_after_scope="no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+    ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+    CFLAGS="$CFLAGS_SAVED"
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_cc_sanitize_address_use_after_scope" >&5
+$as_echo "$ax_cv_cc_sanitize_address_use_after_scope" >&6; }
+
+    if test "x$ax_cv_cc_sanitize_address_use_after_scope" = "xyes"; then
+      devcflags="$devcflags -fsanitize-address-use-after-scope"
+    fi
+
     devldflags="$devldflags -fsanitize=address"
   fi
 
index a87e6a792542ac02d89fb50aa2546cc1c9501236..a6fa2b707175d0f16d66fa58563f288aa676e851 100644 (file)
@@ -1555,7 +1555,13 @@ if test "x$developer" = "xyes"; then
   dnl #  If running with clang, add in ASAN
   dnl #
   if test "x$llvm_address_sanitizer" = "xyes" && test "x$ax_cv_cc_clang" = "xyes"; then
-    devcflags="$devcflags -fsanitize=address -fsanitize-address-use-after-scope -fno-omit-frame-pointer"
+    devcflags="$devcflags -fsanitize=address -fno-omit-frame-pointer"
+
+    AX_CC_SANITZE_ADDRESS_USE_AFTER_SCOPE_FLAG
+    if test "x$ax_cv_cc_sanitize_address_use_after_scope" = "xyes"; then
+      devcflags="$devcflags -fsanitize-address-use-after-scope"
+    fi
+
     devldflags="$devldflags -fsanitize=address"
   fi
 
index 14236d3d650b9a5b1668a623f51fc9c1014ea402..1019a446f3fa7a8122a27f0c0b2b7d4b875679b6 100644 (file)
@@ -155,6 +155,25 @@ AC_DEFUN([AX_CC_PTHREAD_FLAG],[
   ])
 ])
 
+AC_DEFUN([AX_CC_SANITZE_ADDRESS_USE_AFTER_SCOPE_FLAG],[
+  AC_CACHE_CHECK([for the compiler flag "-fsanitize-address-use-after-scope"], [ax_cv_cc_sanitize_address_use_after_scope],[
+
+    dnl # Need -fsanitize=address else we get an unused argument error
+    CFLAGS_SAVED=$CFLAGS
+    CFLAGS="$CFLAGS -Werror -fsanitize=address -fsanitize-address-use-after-scope"
+
+    AC_LANG_PUSH(C)
+    AC_TRY_COMPILE(
+      [],
+      [return 0;],
+      [ax_cv_cc_sanitize_address_use_after_scope="yes"],
+      [ax_cv_cc_sanitize_address_use_after_scope="no"])
+    AC_LANG_POP
+
+    CFLAGS="$CFLAGS_SAVED"
+  ])
+])
+
 dnl #
 dnl #  Check if we have the choose expr builtin
 dnl #