From: Timo Sirainen Date: Mon, 23 Mar 2020 16:28:34 +0000 (+0200) Subject: configure: Add --with-fuzzer=clang to use clang fuzzer X-Git-Tag: 2.3.14.rc1~182 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=715d3aca5a3fc6afb1ab43252d3a1e3ccab4c8bb;p=thirdparty%2Fdovecot%2Fcore.git configure: Add --with-fuzzer=clang to use clang fuzzer --- diff --git a/configure.ac b/configure.ac index aa6e9e6441..ae17717948 100644 --- a/configure.ac +++ b/configure.ac @@ -310,6 +310,7 @@ AC_CHECK_HEADERS(strings.h stdint.h unistd.h dirent.h malloc.h \ CC_CLANG AC_LD_WHOLE_ARCHIVE DC_DOVECOT_HARDENING +DC_DOVECOT_FUZZER DC_DOVECOT_CFLAGS DOVECOT_NSL diff --git a/m4/dovecot.m4 b/m4/dovecot.m4 index 2b5d8957e5..02bdd406a1 100644 --- a/m4/dovecot.m4 +++ b/m4/dovecot.m4 @@ -335,6 +335,27 @@ AC_DEFUN([DC_DOVECOT_HARDENING],[ DOVECOT_WANT_UBSAN ]) +AC_DEFUN([DC_DOVECOT_FUZZER],[ + AC_ARG_WITH(fuzzer, + AS_HELP_STRING([--with-fuzzer=clang], [Build with clang fuzzer (default: no)]), + with_fuzzer=$withval, + with_fuzzer=no) + AS_IF([test x$with_fuzzer = xclang], [ + CFLAGS="$CFLAGS -fsanitize=fuzzer-no-link" + # use $LIB_FUZZING_ENGINE for linking if it exists + FUZZER_LDFLAGS=${LIB_FUZZING_ENGINE--fsanitize=fuzzer} + # May need to use CXXLINK for linking, which wants sources to + # be compiled with -fPIE + FUZZER_CPPFLAGS='$(AM_CPPFLAGS) -fPIE -DPIE' + ], [test x$with_fuzzer != xno], [ + AC_MSG_ERROR([Unknown fuzzer $with_fuzzer]) + ]) + AC_SUBST([FUZZER_CPPFLAGS]) + AC_SUBST([FUZZER_LDFLAGS]) + AM_CONDITIONAL([USE_FUZZER], [test "x$with_fuzzer" != "xno"]) + +]) + AC_DEFUN([DC_DOVECOT],[ AC_ARG_WITH(dovecot, [ --with-dovecot=DIR Dovecot base directory],