From: "Noonan, Steven" <snoonan@amazon.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: Laurent Desnogues <laurent.desnogues@gmail.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Steven Noonan <steven@uplinklabs.net>,
QEMU Developers <qemu-devel@nongnu.org>,
Anthony Liguori <aliguori@amazon.com>
Subject: Re: [Qemu-devel] [PATCH for-2.0] configure: add option to disable -fstack-protector flags
Date: Tue, 8 Apr 2014 13:47:16 -0700 [thread overview]
Message-ID: <20140408204714.GA3225@amazon.com> (raw)
In-Reply-To: <CAFEAcA-H_CF277a=+6brx+2=aofdajkPxcNRLoTVmaxiwf+HqQ@mail.gmail.com>
On Tue, Apr 08, 2014 at 09:37:27PM +0100, Peter Maydell wrote:
> On 28 March 2014 16:19, Paolo Bonzini <pbonzini@redhat.com> wrote:
> > 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.
>
> I've just noticed that this test doesn't correctly handle MacOSX clang.
> For some reason that has this behaviour:
>
> manooth$ clang -o /tmp/zz9 -Werror -fstack-protector /tmp/zz9.c
> # OK, plain -fstack-protector works
> manooth$ clang -o /tmp/zz9 -Werror -fstack-protector-strong /tmp/zz9.c
> clang: error: argument unused during compilation: '-fstack-protector-strong'
> # The strong variant isn't implemented
> manooth$ clang -o /tmp/zz9 -Werror -fstack-protector-strong
> /tmp/zz9.c -framework CoreFoundation
> # ...but for some reason adding the -framework CoreFoundation argument
> # suppresses the error!
Oh good grief. This is no doubt Apple's Xcode-provided Clang with all
their Apple patches applied. Stock Clang would break if you added
-framework, I believe.
> This is bad because we have that framework argument as part of our
> linker flags. Effectively this means that clang won't warn about the
> argument at link time but will warn for every .c->.o compile (as well
> as ending up with no stack protection).
So -framework is designed to transparently add the appropriate -I and
-L/-l flags, pointing to the insides of a .framework bundle.
To me, the -framework arguments belong in CFLAGS and LIBS, but not
LDFLAGS. In the context of QEMU's configure script, I think it'd be
QEMU_INCLUDES and LIBS.
> Changing the test from doing a compile-and-link to just
> compiling a single object seems to fix this:
>
> manooth$ git diff
> diff --git a/configure b/configure
> index eb0e7bb..c85475f 100755
> --- a/configure
> +++ b/configure
> @@ -1448,7 +1448,7 @@ done
> 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
> + if do_cc $QEMU_CFLAGS -Werror $flag -c -o $TMPO $TMPC ; then
> QEMU_CFLAGS="$QEMU_CFLAGS $flag"
> LIBTOOLFLAGS="$LIBTOOLFLAGS -Wc,$flag"
> break
>
> However perhaps the correct fix is to make MacOSX put
> the -framework options in CFLAGS, not LDFLAGS -- they
> seem (from what I can gather from google, which is not much)
> to be a sort of combination of include files and libraries so should
> probably be consistently specified everywhere.
>
> thanks
> -- PMM
next prev parent reply other threads:[~2014-04-08 20:47 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-28 16:19 [Qemu-devel] [PATCH for-2.0] configure: add option to disable -fstack-protector flags Paolo Bonzini
2014-03-28 17:41 ` 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 [this message]
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=20140408204714.GA3225@amazon.com \
--to=snoonan@amazon.com \
--cc=aliguori@amazon.com \
--cc=laurent.desnogues@gmail.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.