From: Evgeny Vereshchagin Date: Wed, 14 Apr 2021 09:20:31 +0000 (+0000) Subject: build-system: add --enable-fuzzers X-Git-Tag: lxc-5.0.0~189^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=38718ccca04a09b0774c8c19e87d711112fc1525;p=thirdparty%2Flxc.git build-system: add --enable-fuzzers Signed-off-by: Evgeny Vereshchagin --- diff --git a/configure.ac b/configure.ac index aa7f59a19..094fe146b 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am index 69e80d751..638d19607 100644 --- a/src/tests/Makefile.am +++ b/src/tests/Makefile.am @@ -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 \