From aff3c16c080d810ff3c97fcd471ad03fcd30623f Mon Sep 17 00:00:00 2001 From: Bram Matthys Date: Sun, 12 May 2019 15:25:11 +0200 Subject: [PATCH] Provide --enable-asan and --disable-asan to toggle address sanitizer. Since we are currently pre-alpha I decided to enable it by default so we as devs don't forget to do so :) --- configure | 22 ++++++++++++++++++++-- configure.ac | 21 ++++++++++++++++++++- 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/configure b/configure index 74eaf64ec..3d62189e8 100755 --- a/configure +++ b/configure @@ -625,6 +625,7 @@ ac_includes_default="\ ac_subst_vars='LTLIBOBJS LIBOBJS UNRLINCDIR +IRCDLIBS URL PTHREAD_CFLAGS PTHREAD_LIBS @@ -673,7 +674,6 @@ HARDEN_BINCFLAGS HARDEN_LDFLAGS HARDEN_CFLAGS MKPASSWDLIBS -IRCDLIBS OBJEXT EXEEXT ac_ct_CC @@ -764,6 +764,7 @@ with_system_cares enable_ssl enable_dynamic_linking enable_werror +enable_asan enable_libcurl ' ac_precious_vars='build_alias @@ -1421,6 +1422,8 @@ Optional Features: rather than dynamically (noone knows if disabling dynamic linking actually does anything or not) --enable-werror Turn compilation warnings into errors (-Werror) + --disable-asan Disable address sanitizer and other debugging + options --enable-libcurl=DIR enable libcurl (remote include) support Optional Packages: @@ -3972,7 +3975,6 @@ fi - # We want to check for compiler flag support, but there is no way to make # clang's "argument unused" warning fatal. So we invoke the compiler through a # wrapper script that greps for this message. @@ -8773,6 +8775,15 @@ else fi + +# Check whether --enable-asan was given. +if test "${enable_asan+set}" = set; then : + enableval=$enable_asan; ac_cv_asan="no" +else + ac_cv_asan="yes" +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if FD_SETSIZE is large enough to allow $ac_fd file descriptors" >&5 $as_echo_n "checking if FD_SETSIZE is large enough to allow $ac_fd file descriptors... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -10153,6 +10164,13 @@ if test "$ac_cv_werror" = "yes" ; then CFLAGS="$CFLAGS -Werror" fi +if test "$ac_cv_asan" = "yes" ; then + CFLAGS="$CFLAGS -O0 -fno-inline -fsanitize=address -fno-omit-frame-pointer -DNOCLOSEFD" + IRCDLIBS="-fsanitize=address $IRCDLIBS" +fi + + + ac_config_files="$ac_config_files Makefile src/Makefile src/modules/Makefile src/modules/chanmodes/Makefile src/modules/usermodes/Makefile src/modules/snomasks/Makefile src/modules/extbans/Makefile src/modules/cap/Makefile src/modules/third/Makefile unrealircd" diff --git a/configure.ac b/configure.ac index 35073fcc4..266fad338 100644 --- a/configure.ac +++ b/configure.ac @@ -85,7 +85,6 @@ AC_CHECK_LIB(nsl, inet_ntoa, AC_CHECK_LIB(crypto, RAND_egd, AC_DEFINE(HAVE_RAND_EGD, 1, [Define if the libcrypto has RAND_egd])) -AC_SUBST(IRCDLIBS) AC_SUBST(MKPASSWDLIBS) dnl HARDENING START @@ -712,6 +711,18 @@ AC_ARG_ENABLE([werror], [ac_cv_werror="$enableval"], [ac_cv_werror="no"]) +dnl AC_ARG_ENABLE([asan], +dnl [AS_HELP_STRING([--enable-asan], +dnl [Enable address sanitizer and other debugging options, not recommended for production servers!])], +dnl [ac_cv_asan="$enableval"], +dnl [ac_cv_asan="no"]) + +AC_ARG_ENABLE([asan], + [AS_HELP_STRING([--disable-asan], + [Disable address sanitizer and other debugging options])], + [ac_cv_asan="no"], + [ac_cv_asan="yes"]) + AC_MSG_CHECKING([if FD_SETSIZE is large enough to allow $ac_fd file descriptors]) AC_COMPILE_IFELSE([ #include @@ -970,6 +981,14 @@ if test "$ac_cv_werror" = "yes" ; then CFLAGS="$CFLAGS -Werror" fi +dnl Address sanitizer build +if test "$ac_cv_asan" = "yes" ; then + CFLAGS="$CFLAGS -O0 -fno-inline -fsanitize=address -fno-omit-frame-pointer -DNOCLOSEFD" + IRCDLIBS="-fsanitize=address $IRCDLIBS" +fi + +AC_SUBST(IRCDLIBS) + AC_SUBST(UNRLINCDIR) AC_CONFIG_FILES([Makefile