From: Evgeny Vereshchagin Date: Tue, 28 Jul 2020 04:17:40 +0000 (+0000) Subject: build-sys: add support for --enable-fuzzing-engine X-Git-Tag: v2.37-rc1~527^2~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=75196cd8be5d0ab3d724bd318de98b9e0ae7038a;p=thirdparty%2Futil-linux.git build-sys: add support for --enable-fuzzing-engine Signed-off-by: Evgeny Vereshchagin --- diff --git a/Makefile.am b/Makefile.am index 429b6289a7..12cb86cba4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -10,14 +10,24 @@ AM_CPPFLAGS += \ -D_PATH_VENDORDIR=\"${vendordir}\" endif +if FUZZING_ENGINE +if !OSS_FUZZ +AM_CPPFLAGS += \ + -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION +endif +endif + AM_CFLAGS = -fsigned-char $(WARN_CFLAGS) -AM_LDFLAGS = $(ASAN_LDFLAGS) $(UBSAN_LDFLAGS) +AM_CXXFLAGS = $(AM_CFLAGS) +AM_LDFLAGS = $(ASAN_LDFLAGS) $(UBSAN_LDFLAGS) $(FUZZING_ENGINE_LDFLAGS) # Add gettext stuff to the global LDADD for systems with separate libintl # library. The LTLIBINTL is generated by AM_GNU_GETTEXT macro. # LDADD = $(LTLIBINTL) +LIB_FUZZING_ENGINE ?= -fsanitize=fuzzer + # Automake (at least up to 1.10) mishandles dist_man_MANS inside conditionals. # Unlike with other dist primaries, the files are not distributed if the # conditional is false. diff --git a/configure.ac b/configure.ac index 8815d270b8..94b6ab0682 100644 --- a/configure.ac +++ b/configure.ac @@ -193,8 +193,16 @@ AC_ARG_ENABLE([fuzzing-engine], AS_HELP_STRING([--enable-fuzzing-engine], [compile with fuzzing engine]), [], [enable_fuzzing_engine=no] ) +AS_IF([test "x$enable_fuzzing_engine" = xyes -a "x$LIB_FUZZING_ENGINE" = x], [ + UL_WARN_ADD([-fno-omit-frame-pointer]) + UL_WARN_ADD([-gline-tables-only]) + UL_WARN_ADD([-fsanitize=fuzzer-no-link]) + FUZZING_ENGINE_LDFLAGS="-fsanitize=fuzzer-no-link" +]) +AC_SUBST([FUZZING_ENGINE_LDFLAGS]) AC_PROG_CXX -AM_CONDITIONAL([FUZZING_ENGINE], [test x$enable_fuzzing_engine = xyes]) +AM_CONDITIONAL([FUZZING_ENGINE], [test "x$enable_fuzzing_engine" = xyes]) +AM_CONDITIONAL([OSS_FUZZ], [test "x$LIB_FUZZING_ENGINE" != x]) dnl libtool-2 LT_INIT