summaryrefslogtreecommitdiffstats
path: root/configure.ac
diff options
context:
space:
mode:
authorMark Wielaard <mjw@redhat.com>2015-05-31 22:37:19 +0200
committerMark Wielaard <mjw@redhat.com>2015-06-05 14:52:29 +0200
commit170f1bb0a8f49cd6c5e7b34aaa505928764866bb (patch)
treedd5fc0594d3b6918f5bb121776c0c50cdab3ed0a /configure.ac
parent616489da5005c63fe572df422f1936529c4743f5 (diff)
Fix sanitize-undefined config check. Don't ALLOW_UNALIGNED when checking.
The -fsanitize=undefined check need to use AC_LINK_IFELSE to make sure libubsan is installed. When doing undefined checking we should disable ALLOW_UNALIGNED memory accesses to catch issues where we do unaligned accesses by accident. Signed-off-by: Mark Wielaard <mjw@redhat.com>
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac12
1 files changed, 9 insertions, 3 deletions
diff --git a/configure.ac b/configure.ac
index 6386e962..58366d54 100644
--- a/configure.ac
+++ b/configure.ac
@@ -202,13 +202,19 @@ if test "$use_undefined" = yes; then
old_CXXFLAGS="$CXXFLAGS"
# We explicitly use unaligned access when possible (see ALLOW_UNALIGNED)
# We want to fail immediately on first error, don't try to recover.
- CFLAGS="$CFLAGS -fsanitize=undefined -fno-sanitize=alignment -fno-sanitize-recover"
- CXXFLAGS="$CXXFLAGS -fsanitize=undefined -fno-sanitize=alignment -fno-sanitize-recover"
- AC_COMPILE_IFELSE([AC_LANG_SOURCE([])], use_undefined=yes, use_undefined=no)
+ CFLAGS="$CFLAGS -fsanitize=undefined -fno-sanitize-recover"
+ CXXFLAGS="$CXXFLAGS -fsanitize=undefined -fno-sanitize-recover"
+ AC_LINK_IFELSE([AC_LANG_SOURCE([int main (int argc, char **argv) { return 0; }])], use_undefined=yes, use_undefined=no)
AS_IF([test "x$use_undefined" != xyes],
AC_MSG_WARN([gcc undefined behaviour sanitizer not available])
CFLAGS="$old_CFLAGS" CXXFLAGS="$old_CXXFLAGS")
fi
+case $use_undefined in
+ yes) check_undefined_val=1 ;;
+ *) check_undefined_val=0 ;;
+esac
+AC_DEFINE_UNQUOTED(CHECK_UNDEFINED, $check_undefined_val,
+ [Building with -fsanitize=undefined or not])
AC_ARG_ENABLE([valgrind],
AS_HELP_STRING([--enable-valgrind],[run all tests under valgrind]),