summaryrefslogtreecommitdiffstats
path: root/configure.ac
diff options
context:
space:
mode:
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac73
1 files changed, 72 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index 1ad1341..43017bf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -156,6 +156,76 @@ case "$GLOBAL_CFLAGS" in
AC_DEFINE([HAVE_FVISIBILITY], [1], [Define if compiled with -fvisibility=hidden])
esac
+AC_ARG_WITH([fuzzers],
+ [AS_HELP_STRING([--with-fuzzers],
+ [build fuzzers and libplist with sanitizers (default is no)])],
+ [build_fuzzers=true],
+ [build_fuzzers=false])
+if test "x$build_fuzzers" = "xtrue"; then
+ AS_COMPILER_FLAG([-fsanitize=address], [
+ SANITIZER_FLAGS+=" -fsanitize=address"
+ ASAN_AVAILABLE=yes
+ ], [])
+ if test "$ASAN_AVAILABLE" = "yes"; then
+ AS_COMPILER_FLAG([-fsanitize=address -fsanitize-address-use-after-scope], [
+ SANITIZER_FLAGS+=" -fsanitize-address-use-after-scope"
+ ], [])
+ SANITIZERS+="ASAN "
+ fi
+
+ AS_COMPILER_FLAG([-fsanitize=undefined], [
+ SANITIZER_FLAGS+=" -fsanitize=undefined"
+ UBSAN_AVAILABLE=yes
+ ], [])
+
+ if test "$UBSAN_AVAILABLE" = "yes"; then
+ SANITIZERS+="UBSAN "
+ fi
+
+ if test -z "$SANITIZER_FLAGS"; then
+ AC_MSG_ERROR([compiler doesn't support -fsanitize=address nor -fsanitize=undefined])
+ fi
+
+ COVERAGE_CHECKS="trace-pc-guard trace-cmp edge"
+ for COV_CHECK in $COVERAGE_CHECKS; do
+ AS_COMPILER_FLAG([-fsanitize-coverage=$COV_CHECK], [
+ if test -z "$SAN_COV_FLAGS"; then
+ SAN_COV_FLAGS="$COV_CHECK"
+ else
+ SAN_COV_FLAGS+=",$COV_CHECK"
+ fi
+ ], [])
+ done
+ if test -n "$SAN_COV_FLAGS"; then
+ SANITIZER_FLAGS+=" -fsanitize-coverage=$SAN_COV_FLAGS"
+ else
+ AC_MSG_WARN([No sanitizer coverage supported by compiler])
+ fi
+
+ CFLAGS="-O1"
+
+ AS_COMPILER_FLAG([-fno-omit-frame-pointer], [
+ CFLAGS+=" -fno-omit-frame-pointer"
+ ], [])
+
+ AS_COMPILER_FLAG([-gline-tables-only], [
+ CFLAGS+=" -gline-tables-only"
+ ],
+ [
+ CFLAGS+=" -g"
+ ])
+
+ CFLAGS+=" -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION"
+ CFLAGS+=" $SANITIZER_FLAGS"
+ CXXFLAGS="$CFLAGS -std=c++11"
+ EXTRA_CONF+=" Build fuzzers ...........: yes
+"
+ EXTRA_CONF+=" Enabled sanitizers ......: $SANITIZERS
+"
+ AS_COMPILER_FLAGS(TEST_CFLAGS, [$CFLAGS])
+fi
+AM_CONDITIONAL([BUILD_FUZZERS],[test "x$build_fuzzers" = "xtrue"])
+
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
AC_OUTPUT([
@@ -168,6 +238,7 @@ include/Makefile
tools/Makefile
cython/Makefile
test/Makefile
+fuzz/Makefile
doxygen.cfg
])
@@ -178,7 +249,7 @@ Configuration for $PACKAGE $VERSION:
Install prefix ..........: $prefix
Debug code ..............: $debug
Python bindings .........: $cython_python_bindings
-
+$EXTRA_CONF
Now type 'make' to build $PACKAGE $VERSION,
and then 'make install' for installation.
"