From 52e075cb0c92bb8eed6473fbe0bbfe36e0f233ef Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Mon, 16 Jan 2017 09:34:13 +0300 Subject: [PATCH] Add AddressSanitizer support. Enable it by default in Travis CI builds. --- .travis.yml | 2 +- configure.ac | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index de8efd8..4c9a5fa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -68,7 +68,7 @@ before_script: - psql -U postgres -c 'CREATE DATABASE sbtest' script: - - ./autogen.sh && ./configure --enable-coverage --with-mysql --with-pgsql + - ./autogen.sh && ./configure --enable-coverage --enable-asan --with-mysql --with-pgsql - make - make distcheck - SBTEST_MYSQL_ARGS="--mysql-user=root" SBTEST_PGSQL_ARGS="--pgsql-user=postgres" make test diff --git a/configure.ac b/configure.ac index 02ea93f..dc79ed0 100644 --- a/configure.ac +++ b/configure.ac @@ -81,6 +81,7 @@ then OPTIMIZE_CFLAGS="-O2" GCOV_CFLAGS="-O0 --coverage" GCOV_LDFLAGS="-coverage" + ASAN_CFLAGS="-fsanitize=address" fi if test "$ax_cv_c_compiler_vendor" = "sun" then @@ -320,7 +321,6 @@ fi AC_CHECK_SIZEOF(size_t) # Checks for library functions. -AC_FUNC_MALLOC AC_FUNC_MMAP AC_FUNC_STRERROR_R @@ -400,6 +400,11 @@ AC_ARG_ENABLE([unreachable], [ac_warn_unreachable="$enableval"], [ac_warn_unreachable="no"]) +AC_ARG_ENABLE([asan], + [AS_HELP_STRING([--enable-asan], + [Enable AddressSanitizer @<:@default=no@:>@])], + [ac_asan="$enableval"], + [ac_asan="no"]) AC_ARG_ENABLE([fail], [AS_HELP_STRING([--disable-fail], @@ -427,6 +432,11 @@ else CFLAGS="${OPTIMIZE_CFLAGS} ${CFLAGS}" fi +if test "$with_asan" = "yes" +then + CFLAGS="${ASAN_CFLAGS} ${CFLAGS}" +fi + if test "$GCC" = "yes" then if test "$ac_warn_fail" = "yes"