From 2164412bb54087b1c540893acf5384ef9bf03f1d Mon Sep 17 00:00:00 2001 From: Reiner Herrmann Date: Wed, 13 Oct 2021 21:27:59 +0000 Subject: build: allow building with sanitizer (#4594) --- configure | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'configure') diff --git a/configure b/configure index 33a4ca9fb..557f5beb2 100755 --- a/configure +++ b/configure @@ -711,6 +711,7 @@ ac_subst_files='' ac_user_opts=' enable_option_checking enable_analyzer +enable_sanitizer enable_apparmor enable_selinux enable_dbusproxy @@ -1368,6 +1369,8 @@ Optional Features: --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-analyzer enable GCC static analyzer + --enable-sanitizer=[address | memory | undefined] + enable a compiler-based sanitizer (debug) --enable-apparmor enable apparmor --enable-selinux SELinux labeling support --disable-dbusproxy disable dbus proxy @@ -3294,6 +3297,57 @@ if test "x$enable_analyzer" = "xyes"; then : fi +# Check whether --enable-sanitizer was given. +if test "${enable_sanitizer+set}" = set; then : + enableval=$enable_sanitizer; +else + enable_sanitizer=no +fi + +if test "x$enable_sanitizer" != "xno" ; then : + as_CACHEVAR=`$as_echo "ax_cv_check_cflags__-fsanitize=$enable_sanitizer" | $as_tr_sh` +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -fsanitize=$enable_sanitizer" >&5 +$as_echo_n "checking whether C compiler accepts -fsanitize=$enable_sanitizer... " >&6; } +if eval \${$as_CACHEVAR+:} false; then : + $as_echo_n "(cached) " >&6 +else + + ax_check_save_flags=$CFLAGS + CFLAGS="$CFLAGS -fsanitize=$enable_sanitizer" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$as_CACHEVAR=yes" +else + eval "$as_CACHEVAR=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS=$ax_check_save_flags +fi +eval ac_res=\$$as_CACHEVAR + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +if eval test \"x\$"$as_CACHEVAR"\" = x"yes"; then : + + EXTRA_CFLAGS="$EXTRA_CFLAGS -fsanitize=$enable_sanitizer -fno-omit-frame-pointer" + EXTRA_LDFLAGS="$EXTRA_LDFLAGS -fsanitize=$enable_sanitizer" + +else + as_fn_error $? "sanitizer not supported: $enable_sanitizer" "$LINENO" 5 + +fi + +fi + HAVE_APPARMOR="" # Check whether --enable-apparmor was given. if test "${enable_apparmor+set}" = set; then : -- cgit v1.2.3-54-g00ecf