Skip to content

Commit

Permalink
Allow selection of sanitizer
Browse files Browse the repository at this point in the history
  • Loading branch information
reinerh committed Oct 11, 2021
1 parent 6388708 commit 351ab1c
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 14 deletions.
54 changes: 46 additions & 8 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ ac_subst_files=''
ac_user_opts='
enable_option_checking
enable_analyzer
enable_asan
enable_sanitizer
enable_apparmor
enable_selinux
enable_dbusproxy
Expand Down Expand Up @@ -1369,7 +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-asan enable address sanitizer
--enable-sanitizer=[address,memory,undefined]
enable address/memory/undefined sanitizer (debug)
--enable-apparmor enable apparmor
--enable-selinux SELinux labeling support
--disable-dbusproxy disable dbus proxy
Expand Down Expand Up @@ -3296,15 +3297,52 @@ if test "x$enable_analyzer" = "xyes"; then :

fi

# Check whether --enable-asan was given.
if test "${enable_asan+set}" = set; then :
enableval=$enable_asan;
# Check whether --enable-sanitizer was given.
if test "${enable_sanitizer+set}" = set; then :
enableval=$enable_sanitizer;
fi

if test "x$enable_asan" = "xyes"; then :
if test "x$enable_sanitizer" = "xaddress" -o "x$enable_sanitizer" = "xmemory" -o "x$enable_sanitizer" = "xundefined"; 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 ()
{
EXTRA_CFLAGS="$EXTRA_CFLAGS -fsanitize=address -fno-omit-frame-pointer"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -fsanitize=address"
;
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 $? "$enable_sanitizer sanitizer not supported" "$LINENO" 5

fi

fi

Expand Down
14 changes: 8 additions & 6 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,14 @@ AS_IF([test "x$enable_analyzer" = "xyes"], [
EXTRA_CFLAGS="$EXTRA_CFLAGS -fanalyzer -Wno-analyzer-malloc-leak"
])

AC_ARG_ENABLE([asan],
AS_HELP_STRING([--enable-asan], [enable address sanitizer]))
AS_IF([test "x$enable_asan" = "xyes"], [
EXTRA_CFLAGS="$EXTRA_CFLAGS -fsanitize=address -fno-omit-frame-pointer"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -fsanitize=address"
])
AC_ARG_ENABLE([sanitizer],
AS_HELP_STRING([--enable-sanitizer=@<:@address,memory,undefined@:>@], [enable address/memory/undefined sanitizer (debug)]))
AS_IF([test "x$enable_sanitizer" = "xaddress" -o "x$enable_sanitizer" = "xmemory" -o "x$enable_sanitizer" = "xundefined"],
[AX_CHECK_COMPILE_FLAG([-fsanitize=$enable_sanitizer],[
EXTRA_CFLAGS="$EXTRA_CFLAGS -fsanitize=$enable_sanitizer -fno-omit-frame-pointer"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -fsanitize=$enable_sanitizer"
],[AC_MSG_ERROR([$enable_sanitizer sanitizer not supported])]
)])

HAVE_APPARMOR=""
AC_ARG_ENABLE([apparmor],
Expand Down

0 comments on commit 351ab1c

Please sign in to comment.