From d8a93ff67917fdc02f2539ba6f03edc09870f535 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 8 Sep 2014 20:01:10 +0300 Subject: In configure add option --enable-sanitize This option add run time checks for buffer overflows and some other memory related things. Not recommended for production. --- configure.in | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'configure.in') diff --git a/configure.in b/configure.in index e236c25fe..6b0604e07 100644 --- a/configure.in +++ b/configure.in @@ -271,6 +271,29 @@ AC_ARG_ENABLE( ) +# +# adress sanitize +# +AC_ARG_ENABLE( + [sanitize], + AC_HELP_STRING( + [--enable-sanitize], + [ + Enables or Disables Sanitize Address Checking (SANITIZE is disabled by default) + ] + ), + [ + enable_sanitize="$enableval" + case $enableval in + "no");; + "yes");; + *) AC_MSG_ERROR([[invalid argument --enable-sanitize=$disableval... stopping]]);; + esac + ], + [enable_sanitize="no"] +) + + # # Renewal # @@ -575,6 +598,39 @@ if test "$enable_lto" != "no" ; then fi +# +# sanitize Support test +# +if test "$enable_sanitize" != "no" ; then + + OLD_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -fsanitize=address" + + OLD_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS -fsanitize=address" + + AC_MSG_CHECKING([whether $CC supports -fsanitize=address]) + AC_RUN_IFELSE( + [AC_LANG_SOURCE([ + int main(int argc, char **argv){ + return 0; + } + ])], + [ + AC_MSG_RESULT([yes]) + ], + [ + AC_MSG_RESULT([no]) + CFLAGS="$OLD_CFLAGS" + LDFLAGS="$OLD_LDFLAGS" + ], + [ + AC_MSG_RESULT([guessing no]) + ] + ) +fi + + AC_DEFUN(AC_CHECK_COMPILER_WFLAG, [ AC_MSG_CHECKING([whether $CC supports -W$1]) -- cgit v1.2.3-60-g2f50