]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Beef up configury for the undefined behaviour sanitiser.
authorFlorian Krohm <florian@eich-krohm.de>
Tue, 23 Jun 2015 20:31:52 +0000 (20:31 +0000)
committerFlorian Krohm <florian@eich-krohm.de>
Tue, 23 Jun 2015 20:31:52 +0000 (20:31 +0000)
If the compiler supports -fno-sanitize=alignment use it.
Otherwise, there will be complaints about misaligned
memory accesses. This is needed for GCC 5.1.
If that flag is not supported simply pass in -fsantize=undefined
and assume that it won't check for alignment violations (which
is true for GCC 4.9).

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15351

configure.ac

index bac11efda137fc29a892af4dec16ab514502e55c..558adf3313239f2081ec5b8076bee38297bed52e 100644 (file)
@@ -1834,11 +1834,26 @@ CFLAGS=$safe_CFLAGS
 AC_SUBST(FLAG_FNO_IPA_ICF)
 
 
-# Does this compiler support -fsanitize=undefined?
+# Does this compiler support -fsanitize=undefined. This is true for
+# GCC 4.9 and newer. However, the undefined behaviour sanitiser in GCC 5.1
+# also checks for alignment violations on memory accesses which the valgrind
+# code base is sprinkled (if not littered) with. As those alignment issues
+# don't pose a problem we want to suppress warnings about them.
+# In GCC 5.1 this can be done by passing -fno-sanitize=alignment. Earlier
+# GCCs do not support that.
+#
 # Only checked for if --enable-ubsan was given.
 if test "x${vg_cv_ubsan}" = "xyes"; then
-AC_MSG_CHECKING([if gcc accepts -fsanitize=undefined])
+AC_MSG_CHECKING([if gcc accepts -fsanitize=undefined -fno-sanitize=alignment])
 safe_CFLAGS=$CFLAGS
+CFLAGS="-fsanitize=undefined -fno-sanitize=alignment -Werror"
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
+  return 0;
+]])], [
+FLAG_FSANITIZE="-fsanitize=undefined -fno-sanitize=alignment"
+LIB_UBSAN="-static-libubsan"
+AC_MSG_RESULT([yes])
+], [
 CFLAGS="-fsanitize=undefined -Werror"
 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
   return 0;
@@ -1851,6 +1866,7 @@ FLAG_FSANITIZE=""
 LIB_UBSAN=""
 AC_MSG_RESULT([no])
 ])
+])
 CFLAGS=$safe_CFLAGS
 AC_SUBST(FLAG_FSANITIZE)
 AC_SUBST(LIB_UBSAN)