diff mbox series

[ovs-dev,v2,1/8] configure: add --enable-asan option

Message ID 647e9fe267af1fadb877cafcd3f00aec238b41d4.1621517561.git.grive@u256.net
State New
Headers show
Series RCU: Add blocking mode for debugging | expand

Commit Message

Gaetan Rivet May 20, 2021, 1:35 p.m. UTC
Add a configure option to enable ASAN in a simple way.
Adding an AC variable to allow checking for support in the testsuite.

Signed-off-by: Gaetan Rivet <grive@u256.net>
---
 .ci/linux-build.sh |  4 ++--
 NEWS               |  1 +
 acinclude.m4       | 16 ++++++++++++++++
 configure.ac       |  1 +
 tests/atlocal.in   |  1 +
 5 files changed, 21 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/.ci/linux-build.sh b/.ci/linux-build.sh
index 0210d6a77..19600a668 100755
--- a/.ci/linux-build.sh
+++ b/.ci/linux-build.sh
@@ -229,10 +229,10 @@  fi
 if [ "$ASAN" ]; then
     # This will override default option configured in tests/atlocal.in.
     export ASAN_OPTIONS='detect_leaks=1'
+    EXTRA_OPTS="$EXTRA_OPTS --enable-asan"
     # -O2 generates few false-positive memory leak reports in test-ovsdb
     # application, so lowering optimizations to -O1 here.
-    CLFAGS_ASAN="-O1 -fno-omit-frame-pointer -fno-common -fsanitize=address"
-    CFLAGS_FOR_OVS="${CFLAGS_FOR_OVS} ${CLFAGS_ASAN}"
+    CFLAGS_FOR_OVS="${CFLAGS_FOR_OVS} -O1"
 fi
 
 save_OPTS="${OPTS} $*"
diff --git a/NEWS b/NEWS
index 402ce5969..79e18b85b 100644
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,7 @@  Post-v2.15.0
    - DPDK:
      * OVS validated with DPDK 20.11.1. It is recommended to use this version
        until further releases.
+   - New configure option '--enable-asan' enables AddressSanitizer.
 
 
 v2.15.0 - 15 Feb 2021
diff --git a/acinclude.m4 b/acinclude.m4
index 15a54d636..615e7f962 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -58,6 +58,22 @@  AC_DEFUN([OVS_ENABLE_WERROR],
    fi
    AC_SUBST([SPARSE_WERROR])])
 
+dnl OVS_ENABLE_ASAN
+AC_DEFUN([OVS_ENABLE_ASAN],
+  [AC_ARG_ENABLE(
+    [asan],
+    [AC_HELP_STRING([--enable-asan],
+                    [Enable the Address Sanitizer])],
+    [ASAN_ENABLED=yes], [ASAN_ENABLED=no])
+   AC_SUBST([ASAN_ENABLED])
+   AC_CONFIG_COMMANDS_PRE([
+     if test "$ASAN_ENABLED" = "yes"; then
+         OVS_CFLAGS="$OVS_CFLAGS -fno-omit-frame-pointer"
+         OVS_CFLAGS="$OVS_CFLAGS -fno-common -fsanitize=address"
+     fi
+   ])
+  ])
+
 dnl OVS_CHECK_LINUX
 dnl
 dnl Configure linux kernel source tree
diff --git a/configure.ac b/configure.ac
index c077034d4..eec5a9d1b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -182,6 +182,7 @@  OVS_CONDITIONAL_CC_OPTION([-Wno-unused-parameter], [HAVE_WNO_UNUSED_PARAMETER])
 OVS_CONDITIONAL_CC_OPTION([-mavx512f], [HAVE_AVX512F])
 OVS_CHECK_CC_OPTION([-mavx512f], [CFLAGS="$CFLAGS -DHAVE_AVX512F"])
 OVS_ENABLE_WERROR
+OVS_ENABLE_ASAN
 OVS_ENABLE_SPARSE
 OVS_CTAGS_IDENTIFIERS
 OVS_CHECK_DPCLS_AUTOVALIDATOR
diff --git a/tests/atlocal.in b/tests/atlocal.in
index cfca7e192..f61e752bf 100644
--- a/tests/atlocal.in
+++ b/tests/atlocal.in
@@ -220,6 +220,7 @@  export OVS_SYSLOG_METHOD
 OVS_CTL_TIMEOUT=30
 export OVS_CTL_TIMEOUT
 
+ASAN_ENABLED='@ASAN_ENABLED@'
 # Add some default flags to make the tests run better under Address
 # Sanitizer, if it was used for the build.
 #