From patchwork Tue Mar 17 23:18:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Matthias_M=C3=A4nnich?= X-Patchwork-Id: 39041 From: maennich@google.com (Matthias Maennich) Date: Wed, 18 Mar 2020 00:18:37 +0100 Subject: [PATCH] configure: add support for memory sanitizer (--enable-msan) Message-ID: <20200317231837.39648-1-maennich@google.com> Similarly to asan, tsan and ubsan, add support for msan conditionally at configure time. This allows us to track down issues caused by using uninitialized values. * configure.ac: Add configure options for -fsanitize=memory Signed-off-by: Matthias Maennich --- configure.ac | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/configure.ac b/configure.ac index 50a50c6c8932..9f30ea38cf86 100644 --- a/configure.ac +++ b/configure.ac @@ -120,6 +120,12 @@ AC_ARG_ENABLE(asan, ENABLE_ASAN=$enableval, ENABLE_ASAN=no) +AC_ARG_ENABLE(msan, + AS_HELP_STRING([--enable-msan=yes|no], + [enable the support of building with -fsanitize=memory)]), + ENABLE_MSAN=$enableval, + ENABLE_MSAN=no) + AC_ARG_ENABLE(tsan, AS_HELP_STRING([--enable-tsan=yes|no], [enable the support of building with -fsanitize=thread)]), @@ -620,6 +626,11 @@ if test x$ENABLE_ASAN = xyes; then CXXFLAGS="$CXXFLAGS -fsanitize=address" fi +if test x$ENABLE_MSAN = xyes; then + CFLAGS="$CFLAGS -fsanitize=memory -fsanitize-memory-track-origins" + CXXFLAGS="$CXXFLAGS -fsanitize=memory -fsanitize-memory-track-origins" +fi + if test x$ENABLE_TSAN = xyes; then CFLAGS="$CFLAGS -fsanitize=thread" CXXFLAGS="$CXXFLAGS -fsanitize=thread" @@ -918,6 +929,7 @@ AC_MSG_NOTICE([ Enable python 3 : ${ENABLE_PYTHON3} Enable running tests under Valgrind : ${enable_valgrind} Enable build with -fsanitize=address : ${ENABLE_ASAN} + Enable build with -fsanitize=memory : ${ENABLE_MSAN} Enable build with -fsanitize=thread : ${ENABLE_TSAN} Enable build with -fsanitize=undefined : ${ENABLE_UBSAN} Generate html apidoc : ${ENABLE_APIDOC}