summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc-André Lureau2018-01-16 16:11:51 +0100
committerPaolo Bonzini2018-02-07 14:09:20 +0100
commit247724cb302af5d70c8853154b640dfabf2bbb56 (patch)
tree1c84b3617d731d0e5c804b5f925b6c7b202aad9e
parentexynos4210: workaround UBSAN compilation error (diff)
downloadqemu-247724cb302af5d70c8853154b640dfabf2bbb56.tar.gz
qemu-247724cb302af5d70c8853154b640dfabf2bbb56.tar.xz
qemu-247724cb302af5d70c8853154b640dfabf2bbb56.zip
build-sys: add --enable-sanitizers
Typical slowdown introduced by AddressSanitizer is 2x. UBSan shouldn't have much impact on runtime cost. Enable it by default when --enable-debug, unless --disable-sanitizers. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20180116151152.4040-3-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rwxr-xr-xconfigure30
1 files changed, 30 insertions, 0 deletions
diff --git a/configure b/configure
index bdbd097c84..35147adc8e 100755
--- a/configure
+++ b/configure
@@ -342,6 +342,7 @@ rdma=""
gprof="no"
debug_tcg="no"
debug="no"
+sanitizers="no"
fortify_source=""
strip_opt="yes"
tcg_interpreter="no"
@@ -993,6 +994,10 @@ for opt do
strip_opt="no"
fortify_source="no"
;;
+ --enable-sanitizers) sanitizers="yes"
+ ;;
+ --disable-sanitizers) sanitizers="no"
+ ;;
--enable-sparse) sparse="yes"
;;
--disable-sparse) sparse="no"
@@ -1474,6 +1479,7 @@ Advanced options (experts only):
--firmwarepath=PATH search PATH for firmware files
--with-confsuffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir [$confsuffix]
--enable-debug enable common debug build options
+ --enable-sanitizers enable default sanitizers
--disable-strip disable stripping binaries
--disable-werror disable compilation abort on warning
--disable-stack-protector disable compiler-provided stack protection
@@ -5201,6 +5207,23 @@ if compile_prog "" "" ; then
fi
##########################################
+# checks for sanitizers
+
+write_c_skeleton
+
+have_asan=no
+have_ubsan=no
+
+if test "$sanitizers" = "yes" ; then
+ if compile_prog "$CPU_CFLAGS -Werror -fsanitize=address" ""; then
+ have_asan=yes
+ fi
+ if compile_prog "$CPU_CFLAGS -Werror -fsanitize=undefined" ""; then
+ have_ubsan=yes
+ fi
+fi
+
+##########################################
# End of CC checks
# After here, no more $cc or $ld runs
@@ -5224,6 +5247,13 @@ else
CFLAGS="-O2 $CFLAGS"
fi
+if test "$have_asan" = "yes"; then
+ CFLAGS="-fsanitize=address $CFLAGS"
+fi
+if test "$have_ubsan" = "yes"; then
+ CFLAGS="-fsanitize=undefined $CFLAGS"
+fi
+
##########################################
# Do we have libnfs
if test "$libnfs" != "no" ; then