]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Enable LLVM's address sanitizer for clang builds
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 5 Jul 2017 17:36:55 +0000 (13:36 -0400)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 5 Jul 2017 17:36:55 +0000 (13:36 -0400)
configure
configure.ac
scripts/travis/build.sh

index ae703ba00b3d3ab0d53ab12ed400370218268970..2107741c562267e6739bf899aea2ee4ca5fbee5f 100755 (executable)
--- a/configure
+++ b/configure
@@ -739,6 +739,7 @@ enable_developer
 enable_largefile
 enable_strict_dependencies
 enable_werror
+enable_llvm_address_sanitizer
 enable_openssl_version_check
 with_rlm_FOO_lib_dir
 with_rlm_FOO_include_dir
@@ -1415,6 +1416,9 @@ Optional Features:
   --disable-largefile     omit support for large files
   --enable-strict-dependencies  fail configure on lack of module dependancy.
   --enable-werror         causes the build to fail if any warnings are generated.
+  --enable-llvm-address-sanitizer
+                          build with support for LLVM's address sanitizer (if
+                          building with clang).
   --disable-openssl-version-check
                           disable vulnerable OpenSSL version check
 
@@ -5232,6 +5236,19 @@ if test "${enable_werror+set}" = set; then :
 fi
 
 
+# Check whether --enable-llvm-address-sanitizer was given.
+if test "${enable_llvm_address_sanitizer+set}" = set; then :
+  enableval=$enable_llvm_address_sanitizer;  case "$enableval" in
+  no)
+    llvm_address_sanitizer=no
+    ;;
+  *)
+    llvm_address_sanitizer=yes
+  esac
+
+fi
+
+
 # Check whether --enable-openssl-version-check was given.
 if test "${enable_openssl_version_check+set}" = set; then :
   enableval=$enable_openssl_version_check;
@@ -12442,12 +12459,19 @@ $as_echo "$ax_cv_cc_weverything_flag" >&6; }
     fi
   fi
 
+        if test "x$llvm_address_sanitizer" = "xyes" && test "x$ax_cv_cc_clang" = "xyes"; then
+    devcflags="$devcflags -fsanitize=address -fno-omit-frame-pointer"
+    devldflags="$devldflags -fsanitize=address"
+  fi
+
   { $as_echo "$as_me:${as_lineno-$LINENO}: Developer CFLAGS are \"$devcflags\"" >&5
 $as_echo "$as_me: Developer CFLAGS are \"$devcflags\"" >&6;}
   { $as_echo "$as_me:${as_lineno-$LINENO}: Developer LDFLAGS are \"$devldflags\"" >&5
 $as_echo "$as_me: Developer LDFLAGS are \"$devldflags\"" >&6;}
 
   CFLAGS="$CFLAGS $devcflags"
+  LDFLAGS="$LDFLAGS $devldflags"
+
         if test "x$EXPERIMENTAL" != "xno"; then
     { $as_echo "$as_me:${as_lineno-$LINENO}: is developer build, enabling experimental modules implicitly, disable with --without-experimental-modules" >&5
 $as_echo "$as_me: is developer build, enabling experimental modules implicitly, disable with --without-experimental-modules" >&6;}
index 952854191b70a1d66c44c16c3962c959eb28ff39..f6f7919fb41615908462bae3d3b846413776b647 100644 (file)
@@ -238,6 +238,22 @@ AC_ARG_ENABLE(werror,
   esac ]
 )
 
+dnl #
+dnl #  Enable the -fsanitize=address and link in the address sanitizer
+dnl #  libraries.
+dnl #
+AC_ARG_ENABLE(llvm-address-sanitizer,
+[AS_HELP_STRING([--enable-llvm-address-sanitizer],
+                [build with support for LLVM's address sanitizer (if building with clang).])],
+[ case "$enableval" in
+  no)
+    llvm_address_sanitizer=no
+    ;;
+  *)
+    llvm_address_sanitizer=yes
+  esac ]
+)
+
 dnl #
 dnl #  extra argument: --disable-openssl-version-check
 dnl #
@@ -1535,10 +1551,20 @@ if test "x$developer" = "xyes"; then
     fi
   fi
 
+  dnl #
+  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 -fno-omit-frame-pointer"
+    devldflags="$devldflags -fsanitize=address"
+  fi
+
   AC_MSG_NOTICE([Developer CFLAGS are "$devcflags"])
   AC_MSG_NOTICE([Developer LDFLAGS are "$devldflags"])
 
   CFLAGS="$CFLAGS $devcflags"
+  LDFLAGS="$LDFLAGS $devldflags"
+
   dnl #
   dnl #  Enable experimental modules (we want to know if code changes breaks one of them)
   dnl #
index c49a8aea74b3621a8201fc4813adfd3e46ad06f2..f98332ad0822ee622502186b611cb4916176c1eb 100755 (executable)
@@ -1,5 +1,7 @@
 #!/bin/sh -e
 
+enable_llvm_address_sanitizer=""
+
 #
 #  If this Travis matrix element does not require the build, we still need to run
 #  configure to make sure any autoconf generated files (tls-h et al) are still
@@ -11,15 +13,25 @@ if [ "${DO_BUILD}" = 'no' ]; then
     exit 0
 fi
 
+#
+#  Enable address sanitizer for the clang builds
+#
+if $CC -v 2>&1 | grep clang > /dev/null; then
+    enable_address_sanitizer="--enable-llvm-address-sanitizer"
+else
+    enable_address_sanitizer=""
+fi
+
 #
 #  Configure the server as per the build matrix
 #
-#  We specify -with-rlm-python-bin because Otherwise travis picks up 
+#  We specify -with-rlm-python-bin because Otherwise travis picks up
 #  /opt/python, which doesn't have .so available
 #
 echo "Performing full configuration"
 CFLAGS="${BUILD_CFLAGS}" ./configure -C \
     --enable-werror \
+    $enable_address_sanitizer \
     --prefix=$HOME/freeradius \
     --with-shared-libs=$LIBS_SHARED \
     --with-threads=$LIBS_OPTIONAL \