2015-01-30 16:49:14 +11:00
|
|
|
AC_DEFUN([NC_DEBUGGING],[
|
|
|
|
##-------------------------------------------------------------------------
|
|
|
|
AX_REQUIRE_DEFINED([AS_HELP_STRING])
|
|
|
|
AX_REQUIRE_DEFINED([AX_APPEND_COMPILE_FLAGS])
|
|
|
|
AX_REQUIRE_DEFINED([AX_APPEND_LINK_FLAGS])
|
2015-02-03 00:15:28 +11:00
|
|
|
AX_REQUIRE_DEFINED([NC_APPEND_ONE_COMPILE_FLAG])
|
2015-01-30 16:49:14 +11:00
|
|
|
|
|
|
|
##-------------------------------------------------------------------------
|
|
|
|
AC_ARG_ENABLE([sanitizer], [
|
|
|
|
AS_HELP_STRING([--enable-sanitizer], [enable memory sanitizer])
|
|
|
|
])
|
|
|
|
|
|
|
|
AS_IF([test "x$enable_sanitizer" = "xyes"], [
|
2015-04-29 17:41:54 +10:00
|
|
|
m4_foreach([NAME], [
|
2015-05-01 02:49:59 +10:00
|
|
|
dnl common top-level names. deliberately does not include
|
|
|
|
dnl 'undefined' due to false positives in some core libraries
|
|
|
|
dnl (eg, boost::format).
|
|
|
|
[address],
|
|
|
|
dnl gcc specific names. do not use vptr or boost::format will die
|
|
|
|
[alignment],
|
|
|
|
[bounds],
|
|
|
|
[enum],
|
|
|
|
[float-cast-overflow],
|
|
|
|
[float-divide-by-zero],
|
|
|
|
[integer-divide-by-zero],
|
|
|
|
[leak],
|
|
|
|
[nonnull-attribute],
|
|
|
|
[object-size],
|
|
|
|
[return],
|
|
|
|
[returns-nonnull-attribute],
|
|
|
|
[shift],
|
|
|
|
[signed-integer-overflow],
|
|
|
|
[unreachable],
|
|
|
|
[vla-bound],
|
|
|
|
dnl clang specific names
|
|
|
|
[integer],
|
|
|
|
[thread],
|
|
|
|
[undefined-trap],
|
|
|
|
[cfi]dnl
|
2015-04-29 17:41:54 +10:00
|
|
|
], [
|
|
|
|
AX_APPEND_COMPILE_FLAGS([-fsanitize=[]NAME], [], [-Werror])
|
|
|
|
AX_APPEND_LINK_FLAGS([-fsanitize=[]NAME], [], [-Werror])
|
|
|
|
])
|
|
|
|
|
|
|
|
## We, and the std library, tend to use unsigned overflow legitimately
|
|
|
|
AX_APPEND_COMPILE_FLAGS([-fno-sanitize=unsigned-integer-overflow], [], [-Werror])
|
|
|
|
AX_APPEND_LINK_FLAGS([-fno-sanitize=unsigned-integer-overflow], [], [-Werror])
|
2015-02-09 13:13:17 +11:00
|
|
|
|
|
|
|
AX_APPEND_COMPILE_FLAGS([-ftrapv], [], [-Werror])
|
2015-01-30 16:49:14 +11:00
|
|
|
])
|
|
|
|
|
|
|
|
##-------------------------------------------------------------------------
|
|
|
|
AC_ARG_ENABLE([debugging], [
|
|
|
|
AS_HELP_STRING([--enable-debugging], [enables developer debugging support])
|
|
|
|
])
|
|
|
|
|
|
|
|
AS_IF([test "x${enable_debugging}" = "xyes"], [
|
|
|
|
AC_DEFINE([ENABLE_DEBUGGING], [], [Debugging support enabled])
|
|
|
|
AC_DEFINE([_GLIBCXX_DEBUG], [], [Use glibcxx debugging mode])
|
|
|
|
|
2015-09-10 22:49:12 +10:00
|
|
|
NC_APPEND_ONE_COMPILE_FLAG([-O0])
|
2015-01-30 16:49:14 +11:00
|
|
|
], [
|
|
|
|
AX_APPEND_COMPILE_FLAGS([-O2])
|
|
|
|
])
|
|
|
|
|
|
|
|
##-------------------------------------------------------------------------
|
|
|
|
AX_APPEND_COMPILE_FLAGS([-g], [], [-Werror])
|
|
|
|
AX_APPEND_COMPILE_FLAGS([-ggdb], [], [-Werror])
|
|
|
|
])
|