summaryrefslogtreecommitdiffstats
path: root/configure.ac
diff options
context:
space:
mode:
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac56
1 files changed, 56 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index db0cddf..9480033 100644
--- a/configure.ac
+++ b/configure.ac
@@ -289,6 +289,62 @@ while test -n "$hname"; do
test "$hname_tmp" = "$hname" && break
done
+##
+## Enable/disable sanitizer checks for clang compilers, initially address sanitizer
+##
+AC_MSG_CHECKING([for clang sanitizer checks])
+AC_ARG_ENABLE([sanitize-checks],
+ [AS_HELP_STRING([--enable-sanitize-checks=address],
+ [(clang/clang++ compilers only) Enable sanitize checks.
+ Address is useful for detecting issues dealing with
+ memory. See AddressSanitizer in config/sanitizer/README.md
+ for more information.
+ [default=none]
+ ])],
+ [CLANG_SANITIZE_CHECKS=$enableval])
+
+# Set default
+if test "X-$CLANG_SANITIZE_CHECKS" = X- ; then
+ CLANG_SANITIZE_CHECKS=none
+fi
+
+if test "X$CC_BASENAME" = "Xclang"; then
+ AC_SUBST([CLANG_SANITIZE_CHECKS])
+
+ # There are several sanitizer tools. At present we are testing
+ # and describing only -fsanitizer=address with autotools.
+ case "X-$CLANG_SANITIZE_CHECKS" in
+ X-no|X-none)
+ CLANG_SANITIZE_CHECKS=none
+ CLANG_SANITIZE_LIST=
+ ;;
+ *)
+ CLANG_SANITIZE_LIST=$CLANG_SANITIZE_CHECKS
+ ;;
+ esac
+ AC_MSG_RESULT([$CLANG_SANITIZE_CHECKS])
+
+ # Other tools can be added to the list of checks
+ # The clang compiler doesn't support some of them; they should be
+ # checked before adding them to the list in the help message.
+ # The sanitizers/sanitizers.cmake file lists these options:
+ # address, memory, memoryWithOrigins, undefined, thread, leak,
+ # 'address;undefined'. Which and which combinations of these are
+ # supported varies by compiler version, but unsupported options
+ # or combinations will result in configure errors reported in config.log.
+ # Comma separated lists of sanitize options wil be entered intact in
+ # one -fsanitize=<list> flag. Space separated lists will be entered in
+ # separate -fsanitize=<item> flags.
+ # NOTE: No sanity checking done here!
+ if test -n "$CLANG_SANITIZE_LIST"; then
+ H5_CFLAGS="$H5_CFLAGS -fno-omit-frame-pointer"
+ H5_CXXFLAGS="$H5_CXXFLAGS -fno-omit-frame-pointer"
+ for sanitizer in `echo $CLANG_SANITIZE_LIST`; do
+ H5_CFLAGS="$H5_CFLAGS -fsanitize=${sanitizer}"
+ H5_CXXFLAGS="$H5_CXXFLAGS -fsanitize=${sanitizer}"
+ done
+ fi
+fi
## ----------------------------------------------------------------------
## Determine build mode (debug, production, clean).