Skip to content

Commit

Permalink
Implement --enable-sanitizers[=sanitizers]
Browse files Browse the repository at this point in the history
Similar to debugging with Valgrind, it's very useful to enable
-fsanitize= switches to catch bugs at runtime.

$ ./configure
Result: no sanitizer enabled

$ ./configure --enable-sanitizers
Result: -fsanitize=address,undefined

$ ./configure --enable-sanitizers=address,thread,undefined
Result: -fsanitize=address,thread,undefined

$ ./configure --enable-sanitizers=undefined
Result: -fsanitize=undefined
  • Loading branch information
Tuncer Ayaz committed Jul 12, 2014
1 parent 9a1419a commit cc894a7
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 0 deletions.
6 changes: 6 additions & 0 deletions configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,12 @@ elif test X"$TMPSYS" '=' X"Darwin-i386"; then
export LDFLAGS
fi

m4_define(DEFAULT_SANITIZERS, [address,undefined])
AC_ARG_ENABLE(sanitizers,
AS_HELP_STRING(
[--enable-sanitizers@<:@=comma-separated list of sanitizers@:>@],
[Default=DEFAULT_SANITIZERS]))

AC_ARG_ENABLE([silent-rules], [dnl
AS_HELP_STRING(
[--enable-silent-rules],
Expand Down
20 changes: 20 additions & 0 deletions erts/configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -4820,6 +4820,26 @@ if test "x$GCC" = xyes; then
CFLAGS="$WERRORFLAGS $CFLAGS"
fi

dnl ----------------------------------------------------------------------
dnl Enable -fsanitize= flags.
dnl ----------------------------------------------------------------------

m4_define(DEFAULT_SANITIZERS, [address,undefined])
AC_ARG_ENABLE(
sanitizers,
AS_HELP_STRING(
[--enable-sanitizers@<:@=comma-separated list of sanitizers@:>@],
[Default=DEFAULT_SANITIZERS]),
[
case "$enableval" in
no) sanitizers= ;;
yes) sanitizers="-fsanitize=DEFAULT_SANITIZERS" ;;
*) sanitizers="-fsanitize=$enableval" ;;
esac
CFLAGS="$CFLAGS $sanitizers"
LDFLAGS="$LDFLAGS $sanitizers"
])

dnl ----------------------------------------------------------------------
dnl Output the result.
dnl ----------------------------------------------------------------------
Expand Down
20 changes: 20 additions & 0 deletions lib/erl_interface/configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,26 @@ else
fi
fi

dnl ----------------------------------------------------------------------
dnl Enable -fsanitize= flags.
dnl ----------------------------------------------------------------------

m4_define(DEFAULT_SANITIZERS, [address,undefined])
AC_ARG_ENABLE(
sanitizers,
AS_HELP_STRING(
[--enable-sanitizers@<:@=comma-separated list of sanitizers@:>@],
[Default=DEFAULT_SANITIZERS]),
[
case "$enableval" in
no) sanitizers= ;;
yes) sanitizers="-fsanitize=DEFAULT_SANITIZERS" ;;
*) sanitizers="-fsanitize=$enableval" ;;
esac
CFLAGS="$CFLAGS $sanitizers"
LDFLAGS="$LDFLAGS $sanitizers"
])

# ---------------------------------------------------------------------------
# XXX
# ---------------------------------------------------------------------------
Expand Down
20 changes: 20 additions & 0 deletions lib/megaco/configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,26 @@ if test "x$GCC" = xyes; then
LM_TRY_ENABLE_CFLAG([-Werror=return-type], [CFLAGS])
fi

dnl ----------------------------------------------------------------------
dnl Enable -fsanitize= flags.
dnl ----------------------------------------------------------------------

m4_define(DEFAULT_SANITIZERS, [address,undefined])
AC_ARG_ENABLE(
sanitizers,
AS_HELP_STRING(
[--enable-sanitizers@<:@=comma-separated list of sanitizers@:>@],
[Default=DEFAULT_SANITIZERS]),
[
case "$enableval" in
no) sanitizers= ;;
yes) sanitizers="-fsanitize=DEFAULT_SANITIZERS" ;;
*) sanitizers="-fsanitize=$enableval" ;;
esac
CFLAGS="$CFLAGS $sanitizers"
LDFLAGS="$LDFLAGS $sanitizers"
])

dnl
dnl If ${ERL_TOP}/make/otp_ded.mk.in exists and contains DED_MK_VSN > 0,
dnl every thing releted to compiling Dynamic Erlang Drivers can be found
Expand Down
20 changes: 20 additions & 0 deletions lib/odbc/configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -228,4 +228,24 @@ if test "x$GCC" = xyes; then
LM_TRY_ENABLE_CFLAG([-Werror=return-type], [CFLAGS])
fi

dnl ----------------------------------------------------------------------
dnl Enable -fsanitize= flags.
dnl ----------------------------------------------------------------------

m4_define(DEFAULT_SANITIZERS, [address,undefined])
AC_ARG_ENABLE(
sanitizers,
AS_HELP_STRING(
[--enable-sanitizers@<:@=comma-separated list of sanitizers@:>@],
[Default=DEFAULT_SANITIZERS]),
[
case "$enableval" in
no) sanitizers= ;;
yes) sanitizers="-fsanitize=DEFAULT_SANITIZERS" ;;
*) sanitizers="-fsanitize=$enableval" ;;
esac
CFLAGS="$CFLAGS $sanitizers"
LDFLAGS="$LDFLAGS $sanitizers"
])

AC_OUTPUT(c_src/$host/Makefile:c_src/Makefile.in)
21 changes: 21 additions & 0 deletions lib/wx/configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,27 @@ if test "x$GCC" = xyes; then
LM_TRY_ENABLE_CFLAG([-Werror=return-type], [CXXFLAGS])
fi

dnl ----------------------------------------------------------------------
dnl Enable -fsanitize= flags.
dnl ----------------------------------------------------------------------

m4_define(DEFAULT_SANITIZERS, [address,undefined])
AC_ARG_ENABLE(
sanitizers,
AS_HELP_STRING(
[--enable-sanitizers@<:@=comma-separated list of sanitizers@:>@],
[Default=DEFAULT_SANITIZERS]),
[
case "$enableval" in
no) sanitizers= ;;
yes) sanitizers="-fsanitize=DEFAULT_SANITIZERS" ;;
*) sanitizers="-fsanitize=$enableval" ;;
esac
CFLAGS="$CFLAGS $sanitizers"
CXXFLAGS="$CXXFLAGS $sanitizers"
LDFLAGS="$LDFLAGS $sanitizers"
])

#############################################################################

dnl
Expand Down

0 comments on commit cc894a7

Please sign in to comment.