[PULL,15/52] build-sys: add some sanitizers when --enable-debug if possible

Message ID 1515756676-3860-16-git-send-email-pbonzini@redhat.com
State New
Headers show
  • [PULL,01/52] scsi-generic: Add share-rw option
Related show

Commit Message

Paolo Bonzini Jan. 12, 2018, 11:30 a.m.
From: Marc-André Lureau <marcandre.lureau@redhat.com>

Enable ASAN/UBSan by default if the compiler supports it.

Typical slowdown introduced by AddressSanitizer is 2x.
UBSan shouldn't have much impact on runtime cost.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20180104160523.22995-8-marcandre.lureau@redhat.com>
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
 configure | 7 +++++++
 1 file changed, 7 insertions(+)


diff --git a/configure b/configure
index 6f1b7cd..d033286 100755
--- a/configure
+++ b/configure
@@ -5195,6 +5195,13 @@  if test "$gcov" = "yes" ; then
 elif test "$fortify_source" = "yes" ; then
 elif test "$debug" = "yes"; then
+  write_c_skeleton;
+  if compile_prog "-fsanitize=address" ""; then
+      CFLAGS="-fsanitize=address $CFLAGS"
+  fi
+  if compile_prog "-fsanitize=undefined" ""; then
+      CFLAGS="-fsanitize=undefined $CFLAGS"
+  fi
   if compile_prog "-Og" ""; then
       CFLAGS="-Og $CFLAGS"
   elif compile_prog "-O1" ""; then