diff options
author | Darrick J. Wong <darrick.wong@oracle.com> | 2018-03-08 12:15:35 -0800 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2018-08-08 11:16:12 -0400 |
commit | 5e666e3d8846e695650ae757d3626547cfd05cbf (patch) | |
tree | 673a2c1972faa19fb78146c7ff2c871c4366e237 /configure.ac | |
parent | 1c2a76aeb0f42e078667cf81412d2dcf6b66b6df (diff) |
enable gcc/clang address sanitizer if the builder wants it
Enable AddressSanitizer to look for memory usage errors if the builder
asks for it and it's available.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'configure.ac')
-rw-r--r-- | configure.ac | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac index 1d23858b..62581f6b 100644 --- a/configure.ac +++ b/configure.ac @@ -1358,6 +1358,34 @@ if test "$enable_ubsan" = "yes" && test "$have_ubsan" != "yes"; then AC_MSG_ERROR([UBSAN not supported by compiler.]) fi dnl +dnl Enable ADDRSAN for all packages +dnl +AC_ARG_ENABLE([addrsan], +[ --enable-addrsan enable address sanitizer],, +enable_addrsan=no) +if test "$enable_addrsan" = "yes" || test "$enable_addrsan" = "probe"; then + AC_MSG_CHECKING([if C compiler supports ADDRSAN]) + OLD_CFLAGS="$CFLAGS" + OLD_LDFLAGS="$LDFLAGS" + ADDRSAN_FLAGS="-fsanitize=address" + CFLAGS="$CFLAGS $ADDRSAN_FLAGS" + LDFLAGS="$LDFLAGS $ADDRSAN_FLAGS" + AC_LINK_IFELSE([AC_LANG_PROGRAM([])], + [AC_MSG_RESULT([yes])] + [addrsan_cflags=$ADDRSAN_FLAGS] + [addrsan_ldflags=$ADDRSAN_FLAGS] + [have_addrsan=yes], + [AC_MSG_RESULT([no])]) + CFLAGS="${OLD_CFLAGS}" + LDFLAGS="${OLD_LDFLAGS}" + AC_SUBST(have_addrsan) + AC_SUBST(addrsan_cflags) + AC_SUBST(addrsan_ldflags) +fi +if test "$enable_addrsan" = "yes" && test "$have_addrsan" != "yes"; then + AC_MSG_ERROR([ADDRSAN not supported by compiler.]) +fi +dnl dnl OS-specific uncomment control dnl LINUX_CMT="#" |