From e36e62c0631f73627ff3caec5752eefe37a14948 Mon Sep 17 00:00:00 2001 From: Chris Liddell Date: Thu, 24 Sep 2020 16:59:20 +0100 Subject: Allow configure caller to choose a sanitizer Our "sanitize" target just uses address sanitizer. With this commit, we'll still default to address, but the caller can do: --with-santizer=memory to opt for the "memory" sanitizer instead. --- configure.ac | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index d6f346b76..758010970 100644 --- a/configure.ac +++ b/configure.ac @@ -473,17 +473,28 @@ dnl check for sanitize support dnl ---------------------------- AC_MSG_CHECKING([compiler/linker address santizer support]) +AC_ARG_WITH([sanitizer], AC_HELP_STRING([--with-sanitizer=@<:@address/memory@:>@], + [Sanitizer for 'sanitize' target (defaults to 'address')]), + [SANITIZER=$with_sanitizer], [SANITIZER=address]) + CFLAGS_SANITIZE="" -CFLAGS_SANITIZE_TRY="-fsanitize=address -fno-omit-frame-pointer" +CFLAGS_SANITIZE_TRY="-fsanitize=$SANITIZER -fno-omit-frame-pointer" CFLAGS_SAVED="$CFLAGS" CFLAGS="$CFLAGS_SANITIZE_TRY" - AC_LINK_IFELSE( [AC_LANG_PROGRAM([#include ], [ return(0); ])], - [CFLAGS_SANITIZE="$CFLAGS"], [CFLAGS_SANITIZE="'****************ADDRESS_SANITIZER_NOT_SUPPORTED*********************'"]) + [CFLAGS_SANITIZE="$CFLAGS"], + [ + if test x"$with_sanitizer" != x; then + AC_MSG_ERROR([--with-sanitizer=$with_sanitizer not supported by compiler]) + else + CFLAGS_SANITIZE="'****************ADDRESS_SANITIZER_NOT_SUPPORTED*********************'" + fi + ] + ) CFLAGS="$CFLAGS_SAVED" -- cgit v1.2.1