From 11e2e5f6b59a3479f17d78f9e0b8748798b5bd24 Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Mon, 1 May 2017 18:06:45 +0100 Subject: [PATCH] Problem: address sanitizer support in CI is hacky Solution: import better solution from zproject and add a new autoconf option --- ci_build.sh | 3 +-- configure.ac | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/ci_build.sh b/ci_build.sh index 5da9eeca..9e442749 100755 --- a/ci_build.sh +++ b/ci_build.sh @@ -16,8 +16,7 @@ if [ $BUILD_TYPE == "default" ]; then CONFIG_OPTS+=("--prefix=${BUILD_PREFIX}") if [ -n "$ADDRESS_SANITIZER" ] && [ "$ADDRESS_SANITIZER" == "enabled" ]; then - CONFIG_OPTS+=("CFLAGS=-fsanitize=address") - CONFIG_OPTS+=("CXXFLAGS=-fsanitize=address") + CONFIG_OPTS+=("--enable-address-sanitizer=yes") fi if [ -z $CURVE ]; then diff --git a/configure.ac b/configure.ac index 5701a2f3..c10f8445 100644 --- a/configure.ac +++ b/configure.ac @@ -127,6 +127,22 @@ if test "x$zmq_militant" = "xyes"; then AC_DEFINE(ZMQ_ACT_MILITANT, 1, [Enable militant API assertions]) fi +# Memory mis-use detection +AC_MSG_CHECKING([whether to enable ASan]) +AC_ARG_ENABLE(address-sanitizer, [AS_HELP_STRING([--enable-address-sanitizer=yes/no], + [Build with GCC Address Sanitizer instrumentation])], + [ZMQ_ASAN="$enableval"]) + +if test "x${ZMQ_ASAN}" == "xyes"; then + CFLAGS="${CFLAGS} -fsanitize=address" + CXXFLAGS="${CXXFLAGS} -fsanitize=address" + + AM_CONDITIONAL(ENABLE_ASAN, true) + AC_MSG_RESULT([yes]) +else + AM_CONDITIONAL(ENABLE_ASAN, false) + AC_MSG_RESULT([no]) +fi # By default compiling with -Werror except OSX. libzmq_werror="yes"