From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: laurent.desnogues@gmail.com,
Steven Noonan <steven@uplinklabs.net>,
Steven Noonan <snoonan@amazon.com>,
Anthony Liguori <aliguori@amazon.com>
Subject: [Qemu-devel] [PATCH for-2.0] configure: add option to disable -fstack-protector flags
Date: Fri, 28 Mar 2014 17:19:02 +0100 [thread overview]
Message-ID: <1396023542-19667-1-git-send-email-pbonzini@redhat.com> (raw)
From: Steven Noonan <steven@uplinklabs.net>
The -fstack-protector flag family is useful for ensuring safety and for
debugging, but has a performance impact. Here are some boot time comparisons of
the various versions of -fstack-protector using qemu-system-arm on an x86_64
host:
# -fstack-protector-all
Startup finished in 1.810s (kernel) + 12.331s (initrd) + 49.016s (userspace) = 1min 3.159s
Startup finished in 1.801s (kernel) + 12.287s (initrd) + 47.925s (userspace) = 1min 2.013s
Startup finished in 1.812s (kernel) + 12.302s (initrd) + 47.995s (userspace) = 1min 2.111s
# -fstack-protector-strong
Startup finished in 1.744s (kernel) + 11.223s (initrd) + 44.688s (userspace) = 57.657s
Startup finished in 1.721s (kernel) + 11.222s (initrd) + 44.194s (userspace) = 57.138s
Startup finished in 1.693s (kernel) + 11.250s (initrd) + 44.426s (userspace) = 57.370s
# -fstack-protector
Startup finished in 1.705s (kernel) + 11.409s (initrd) + 43.563s (userspace) = 56.677s
Startup finished in 1.877s (kernel) + 11.137s (initrd) + 43.719s (userspace) = 56.734s
Startup finished in 1.708s (kernel) + 11.141s (initrd) + 43.628s (userspace) = 56.478s
# no stack protector
Startup finished in 1.743s (kernel) + 11.190s (initrd) + 43.709s (userspace) = 56.643s
Startup finished in 1.763s (kernel) + 11.216s (initrd) + 43.767s (userspace) = 56.747s
Startup finished in 1.711s (kernel) + 11.283s (initrd) + 43.878s (userspace) = 56.873s
This patch introduces a configure option to disable the stack protector
entirely, and conditional stack protector flag selection (in order,
based on availability): -fstack-protector-strong, -fstack-protector-all,
no stack protector.
Signed-off-by: Steven Noonan <snoonan@amazon.com>
Cc: Anthony Liguori <aliguori@amazon.com>
Reviewed-by: Stefan Weil <sw@weilnetz.de>
[Prefer -fstack-protector-all to -fstack-protector, suggested by
Laurent Desnogues. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
configure | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/configure b/configure
index fb3bd05..eb0e7bb 100755
--- a/configure
+++ b/configure
@@ -198,6 +198,7 @@ audio_win_int=""
cc_i386=i386-pc-linux-gnu-gcc
libs_qga=""
debug_info="yes"
+stack_protector=""
# Don't accept a target_list environment variable.
unset target_list
@@ -950,6 +951,10 @@ for opt do
;;
--disable-werror) werror="no"
;;
+ --enable-stack-protector) stack_protector="yes"
+ ;;
+ --disable-stack-protector) stack_protector="no"
+ ;;
--disable-curses) curses="no"
;;
--enable-curses) curses="yes"
@@ -1219,6 +1224,7 @@ Advanced options (experts only):
--disable-sparse disable sparse checker (default)
--disable-strip disable stripping binaries
--disable-werror disable compilation abort on warning
+ --disable-stack-protector disable compiler-provided stack protection
--disable-sdl disable SDL
--enable-sdl enable SDL
--with-sdlabi select preferred SDL ABI 1.2 or 2.0
@@ -1439,9 +1445,15 @@ for flag in $gcc_flags; do
fi
done
-if compile_prog "-Werror -fstack-protector-all" "" ; then
- QEMU_CFLAGS="$QEMU_CFLAGS -fstack-protector-all"
- LIBTOOLFLAGS="$LIBTOOLFLAGS -Wc,-fstack-protector-all"
+if test "$stack_protector" != "no" ; then
+ gcc_flags="-fstack-protector-strong -fstack-protector-all"
+ for flag in $gcc_flags; do
+ if compile_prog "-Werror $flag" "" ; then
+ QEMU_CFLAGS="$QEMU_CFLAGS $flag"
+ LIBTOOLFLAGS="$LIBTOOLFLAGS -Wc,$flag"
+ break
+ fi
+ done
fi
# Workaround for http://gcc.gnu.org/PR55489. Happens with -fPIE/-fPIC and
--
1.8.5.3
next reply other threads:[~2014-03-28 16:19 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-28 16:19 Paolo Bonzini [this message]
2014-03-28 17:41 ` [Qemu-devel] [PATCH for-2.0] configure: add option to disable -fstack-protector flags Laurent Desnogues
2014-03-28 17:51 ` Paolo Bonzini
2014-03-28 18:04 ` Noonan, Steven
2014-03-28 20:53 ` Brad Smith
2014-03-31 20:50 ` Peter Maydell
2014-04-08 20:37 ` Peter Maydell
2014-04-08 20:47 ` Noonan, Steven
2014-04-09 7:40 ` Peter Maydell
2014-04-09 9:29 ` Noonan, Steven
2014-04-09 9:34 ` Peter Maydell
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=1396023542-19667-1-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=aliguori@amazon.com \
--cc=laurent.desnogues@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=snoonan@amazon.com \
--cc=steven@uplinklabs.net \
/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).