summaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-05-02 00:51:15 +0300
committerAndrei Karas <akaras@inbox.ru>2016-05-02 00:51:15 +0300
commit0b2a9a6937a223ecc6356836da51ed41afc2d00b (patch)
tree121fbe7e92a078d0f1afb5e6c6f185f7787cba62 /configure.ac
parent8335b9a7459e1b3a0c4424b9f2a991ed7624f99d (diff)
downloadevol-hercules-0b2a9a6937a223ecc6356836da51ed41afc2d00b.tar.gz
evol-hercules-0b2a9a6937a223ecc6356836da51ed41afc2d00b.tar.bz2
evol-hercules-0b2a9a6937a223ecc6356836da51ed41afc2d00b.tar.xz
evol-hercules-0b2a9a6937a223ecc6356836da51ed41afc2d00b.zip
Enable sanity flags only if they supported.
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac60
1 files changed, 60 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 11d8ca1..095716f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -151,6 +151,66 @@ AC_DEFUN([AC_CHECK_COMPILER_WFLAG],
]
)
+AC_DEFUN([AC_CHECK_SANITIZER_FLAG],
+ [
+ AC_MSG_CHECKING([whether $CC supports -fsanitize=$1])
+ OLD_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -fsanitize=$1"
+ OLD_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS -fsanitize=$1"
+ AC_COMPILE_IFELSE(
+ [AC_LANG_SOURCE([int foo;])],
+ [
+ AC_MSG_RESULT([yes])
+ ],
+ [
+ AC_MSG_RESULT([no])
+
+ AC_MSG_CHECKING([whether $CC requires -fsanitize-undefined-trap-on-error for -fsanitize=$1])
+ CFLAGS="$CFLAGS -fsanitize-undefined-trap-on-error"
+ AC_COMPILE_IFELSE(
+ [AC_LANG_SOURCE([int foo;])],
+ [
+ AC_MSG_RESULT([yes])
+ ],
+ [
+ AC_MSG_RESULT([no])
+ CFLAGS="$OLD_CFLAGS"
+ LDFLAGS="$OLD_LDFLAGS"
+ ]
+ )
+ ],
+ [
+ AC_MSG_RESULT([guessing no])
+ CFLAGS="$OLD_CFLAGS"
+ LDFLAGS="$OLD_LDFLAGS"
+ ]
+ )
+ ]
+)
+
+if test "$enable_sanitize" != "no" ; then
+ AC_CHECK_SANITIZER_FLAG(address)
+ # skipped because server have multiple issues: -fsanitize=alignment
+ AC_CHECK_SANITIZER_FLAG(shift)
+ AC_CHECK_SANITIZER_FLAG(integer-divide-by-zero)
+ AC_CHECK_SANITIZER_FLAG(unreachable)
+ AC_CHECK_SANITIZER_FLAG(vla-bound)
+ AC_CHECK_SANITIZER_FLAG(null)
+ AC_CHECK_SANITIZER_FLAG(return)
+ AC_CHECK_SANITIZER_FLAG(signed-integer-overflow)
+ AC_CHECK_SANITIZER_FLAG(bounds)
+ AC_CHECK_SANITIZER_FLAG(bounds-strict)
+ AC_CHECK_SANITIZER_FLAG(object-size)
+ AC_CHECK_SANITIZER_FLAG(float-divide-by-zero)
+ AC_CHECK_SANITIZER_FLAG(float-cast-overflow)
+ AC_CHECK_SANITIZER_FLAG(nonnull-attribute)
+ AC_CHECK_SANITIZER_FLAG(returns-nonnull-attribute)
+ AC_CHECK_SANITIZER_FLAG(bool)
+ AC_CHECK_SANITIZER_FLAG(enum)
+ AC_CHECK_SANITIZER_FLAG(vptr)
+fi
+
AC_CHECK_COMPILER_WFLAG(empty-body)
AC_CHECK_COMPILER_WFLAG(newline-eof)
AC_CHECK_COMPILER_WFLAG(int-conversion)