From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Subject: [Qemu-devel] [PULL 19/47] build-sys: add --enable-sanitizers
Date: Wed, 7 Feb 2018 16:25:15 +0100 [thread overview]
Message-ID: <1518017115-43611-2-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1518017115-43611-1-git-send-email-pbonzini@redhat.com>
From: Marc-André Lureau <marcandre.lureau@redhat.com>
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>
---
configure | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/configure b/configure
index bdbd097..35147ad 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
--
1.8.3.1
next prev parent reply other threads:[~2018-02-07 15:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-07 15:25 [Qemu-devel] [PULL v2 00/47] Misc patches for 2018-02-05 Paolo Bonzini
2018-02-07 15:25 ` Paolo Bonzini [this message]
2018-02-07 23:02 ` Peter Maydell
-- strict thread matches above, loose matches on Subject: below --
2018-02-05 19:28 [Qemu-devel] [PULL " Paolo Bonzini
2018-02-05 19:28 ` [Qemu-devel] [PULL 19/47] build-sys: add --enable-sanitizers Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1518017115-43611-2-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).