build-system: add --enable-fuzzers

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
This commit is contained in:
Evgeny Vereshchagin 2021-04-14 09:20:31 +00:00
parent b9f3cd48ec
commit 38718ccca0
2 changed files with 37 additions and 0 deletions

View File

@ -62,6 +62,7 @@ if test "x$valid_compiler" = "xno"; then
fi
AC_PROG_GCC_TRADITIONAL
AC_PROG_CXX
AC_ENABLE_SHARED
AC_ENABLE_STATIC
# Check binaries
@ -205,6 +206,13 @@ AC_ARG_ENABLE([no_undefined],
[enable_no_undefined=$enableval], [enable_no_undefined=yes])
AM_CONDITIONAL([ENABLE_NO_UNDEFINED], [test "x$enable_no_undefined" = "xyes"])
AC_ARG_ENABLE([fuzzers],
[AS_HELP_STRING([--enable-fuzzers], [compile with fuzzers])],
[enable_fuzzers=$enableval], [enable_fuzzers=no])
AM_CONDITIONAL([ENABLE_FUZZERS], [test "x$enable_fuzzers" = "xyes"])
AM_CONDITIONAL([OSS_FUZZ], [test "x$LIB_FUZZING_ENGINE" != x])
# Allow disabling rpath
AC_ARG_ENABLE([rpath],
[AS_HELP_STRING([--enable-rpath], [set rpath in executables [default=no]])],
@ -476,6 +484,13 @@ else
AC_MSG_RESULT([no])
fi
if test "x$enable_fuzzers" = "xyes" -a "x$LIB_FUZZING_ENGINE" = x; then
CC_CHECK_FLAGS_APPEND([AM_CFLAGS],[CFLAGS],[ \
-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION \
-fsanitize=fuzzer-no-link])
AC_SUBST(AM_CFLAGS)
fi
# Optional test binaries
AC_ARG_ENABLE([tests],
[AS_HELP_STRING([--enable-tests], [build test/example binaries [default=no]])],
@ -1124,6 +1139,7 @@ Debugging:
- Coverity: $enable_coverity_build
- mutex debugging: $enable_mutex_debugging
- tests: $enable_tests
- fuzzers: $enable_fuzzers
Paths:
- Logs in configpath: $enable_configpath_log

View File

@ -791,6 +791,27 @@ bin_SCRIPTS += lxc-test-lxc-attach \
endif
endif
if ENABLE_FUZZERS
LIB_FUZZING_ENGINE ?= -fsanitize=fuzzer
# https://google.github.io/oss-fuzz/getting-started/new-project-guide/#Requirements
nodist_EXTRA_fuzz_lxc_config_read_SOURCES = dummy.cxx
fuzz_lxc_config_read_SOURCES = fuzz-lxc-config-read.c
fuzz_lxc_config_read_CFLAGS = $(AM_CFLAGS)
fuzz_lxc_config_read_CXXFLAGS = $(AM_CFLAGS)
fuzz_lxc_config_read_LDFLAGS = $(AM_LDFLAGS) -static
fuzz_lxc_config_read_LDADD = $(LDADD) $(LIB_FUZZING_ENGINE)
nodist_EXTRA_fuzz_lxc_define_load_SOURCES = dummy.cxx
fuzz_lxc_define_load_SOURCES = fuzz-lxc-define-load.c
fuzz_lxc_define_load_CFLAGS = $(AM_CFLAGS)
fuzz_lxc_define_load_CXXFLAGS = $(AM_CFLAGS)
fuzz_lxc_define_load_LDFLAGS = $(AM_LDFLAGS) -static
fuzz_lxc_define_load_LDADD = $(LDADD) $(LIB_FUZZING_ENGINE)
bin_PROGRAMS += fuzz-lxc-config-read \
fuzz-lxc-define-load
endif
endif
EXTRA_DIST = basic.c \