summaryrefslogtreecommitdiff
path: root/configure.in
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2015-05-03 15:33:47 +0200
committerHaru <haru@dotalux.com>2015-05-03 15:33:47 +0200
commit5f308d20edf1b6769895aac265314187305ebe1f (patch)
tree958ca4efdad2f3fad567827ebac1545f18209d90 /configure.in
parentf5ed898d4dc394af26fc1f0545861794331bd985 (diff)
downloadhercules-5f308d20edf1b6769895aac265314187305ebe1f.tar.gz
hercules-5f308d20edf1b6769895aac265314187305ebe1f.tar.bz2
hercules-5f308d20edf1b6769895aac265314187305ebe1f.tar.xz
hercules-5f308d20edf1b6769895aac265314187305ebe1f.zip
Split -fsanitize checks into multiple steps
This will allow fine-grained detection of the sanitizer options supported by the current compiler. Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'configure.in')
-rw-r--r--configure.in90
1 files changed, 53 insertions, 37 deletions
diff --git a/configure.in b/configure.in
index 3b5420c8b..f8a3fa639 100644
--- a/configure.in
+++ b/configure.in
@@ -302,7 +302,8 @@ AC_ARG_ENABLE(
AC_HELP_STRING(
[--enable-sanitize@<:@=ARG@:>@],
[
- Sanitize: yes, no, full)
+ Enables sanitizer. (disabled by default)
+ (available options: yes, no, full)
]
),
[
@@ -621,49 +622,64 @@ if test "$enable_lto" != "no" ; then
)
fi
+AC_DEFUN(AC_CHECK_SANITIZER_FLAG,
+ [
+ AC_MSG_CHECKING([whether $CC supports -fsanitize=$1])
+ OLD_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -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"
+ ]
+ )
+ ],
+ [
+ AC_MSG_RESULT([guessing no])
+ CFLAGS="$OLD_CFLAGS"
+ ]
+ )
+ ]
+)
#
# sanitize Support test
#
if test "$enable_sanitize" != "no" ; then
+ AC_CHECK_SANITIZER_FLAG(address)
if test "$enable_sanitize" == "full" ; then
- # skipped because server have multiply issues -fsanitize=alignment
- SAN="-fsanitize=address \
--fsanitize=shift -fsanitize=integer-divide-by-zero -fsanitize=unreachable \
--fsanitize=vla-bound -fsanitize=null -fsanitize=return \
--fsanitize=signed-integer-overflow -fsanitize=bounds \
--fsanitize=object-size -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow \
--fsanitize=nonnull-attribute -fsanitize=returns-nonnull-attribute -fsanitize=bool \
--fsanitize=enum -fsanitize=vptr"
- else
- SAN="-fsanitize=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(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, sanitize-undefined-trap-on-error)
+ AC_CHECK_SANITIZER_FLAG(vptr)
fi
-
- OLD_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS $SAN"
- OLD_LDFLAGS="$LDFLAGS"
- LDFLAGS="$LDFLAGS $SAN"
-
- AC_MSG_CHECKING([whether $CC supports $SAN])
- AC_RUN_IFELSE(
- [AC_LANG_SOURCE([
- int main(int argc, char **argv){
- return 0;
- }
- ])],
- [
- AC_MSG_RESULT([yes])
- ],
- [
- AC_MSG_RESULT([no])
- CFLAGS="$OLD_CFLAGS"
- LDFLAGS="$OLD_LDFLAGS"
- ],
- [
- AC_MSG_RESULT([guessing no])
- ]
- )
-
fi