mirror of
https://github.com/tmux/tmux.git
synced 2025-09-02 13:37:12 +00:00
Scaffold for oss-fuzz, from Sergey Nizovtsev.
This commit is contained in:
47
configure.ac
47
configure.ac
@ -21,6 +21,26 @@ SAVED_CFLAGS="$CFLAGS"
|
||||
SAVED_CPPFLAGS="$CPPFLAGS"
|
||||
SAVED_LDFLAGS="$LDFLAGS"
|
||||
|
||||
# Is this oss-fuzz build?
|
||||
AC_ARG_ENABLE(
|
||||
fuzzing,
|
||||
AC_HELP_STRING(--enable-fuzzing, build fuzzers)
|
||||
)
|
||||
AC_ARG_VAR(
|
||||
FUZZING_LIBS,
|
||||
AC_HELP_STRING(libraries to link fuzzing targets with)
|
||||
)
|
||||
|
||||
# Set up convenient fuzzing defaults before initializing compiler.
|
||||
if test "x$enable_fuzzing" = xyes; then
|
||||
AC_DEFINE(NEED_FUZZING)
|
||||
test "x$CC" == x && CC=clang
|
||||
test "x$FUZZING_LIBS" == x && \
|
||||
FUZZING_LIBS="-fsanitize=fuzzer"
|
||||
test "x$SAVED_CFLAGS" == x && \
|
||||
AM_CFLAGS="-g -fsanitize=fuzzer-no-link,address"
|
||||
fi
|
||||
|
||||
# Set up the compiler in two different ways and say yes we may want to install.
|
||||
AC_PROG_CC
|
||||
AM_PROG_CC_C_O
|
||||
@ -54,8 +74,11 @@ if test "x$enable_static" = xyes; then
|
||||
LDFLAGS="$AM_LDFLAGS $SAVED_LDFLAGS"
|
||||
fi
|
||||
|
||||
# Do we need fuzzers?
|
||||
AM_CONDITIONAL(NEED_FUZZING, test "x$enable_fuzzing" = xyes)
|
||||
|
||||
# Is this gcc?
|
||||
AM_CONDITIONAL(IS_GCC, test "x$GCC" = xyes)
|
||||
AM_CONDITIONAL(IS_GCC, test "x$GCC" = xyes -a "x$enable_fuzzing" != xyes)
|
||||
|
||||
# Is this Sun CC?
|
||||
AC_EGREP_CPP(
|
||||
@ -117,8 +140,6 @@ AC_REPLACE_FUNCS([ \
|
||||
getline \
|
||||
getprogname \
|
||||
memmem \
|
||||
recallocarray \
|
||||
reallocarray \
|
||||
setenv \
|
||||
setproctitle \
|
||||
strcasestr \
|
||||
@ -130,6 +151,26 @@ AC_REPLACE_FUNCS([ \
|
||||
])
|
||||
AC_FUNC_STRNLEN
|
||||
|
||||
# Clang sanitizers wrap reallocarray even if it isn't available on the target
|
||||
# system. When compiled it always returns NULL and crashes the program. To
|
||||
# detect this we need a more complicated test.
|
||||
AC_MSG_CHECKING([for working reallocarray])
|
||||
AC_RUN_IFELSE([AC_LANG_PROGRAM(
|
||||
[#include <stdlib.h>],
|
||||
[return (reallocarray(NULL, 1, 1) == NULL);]
|
||||
)],
|
||||
AC_MSG_RESULT(yes),
|
||||
[AC_LIBOBJ(reallocarray) AC_MSG_RESULT([no])]
|
||||
)
|
||||
AC_MSG_CHECKING([for working recallocarray])
|
||||
AC_RUN_IFELSE([AC_LANG_PROGRAM(
|
||||
[#include <stdlib.h>],
|
||||
[return (recallocarray(NULL, 1, 1, 1) == NULL);]
|
||||
)],
|
||||
AC_MSG_RESULT(yes),
|
||||
[AC_LIBOBJ(recallocarray) AC_MSG_RESULT([no])]
|
||||
)
|
||||
|
||||
# Look for clock_gettime. Must come before event_init.
|
||||
AC_SEARCH_LIBS(clock_gettime, rt)
|
||||
|
||||
|
Reference in New Issue
Block a user