From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45646) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WXcvb-0001qb-Mt for qemu-devel@nongnu.org; Tue, 08 Apr 2014 16:47:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WXcvU-0008Pi-Iu for qemu-devel@nongnu.org; Tue, 08 Apr 2014 16:47:31 -0400 Received: from smtp-fw-31001.amazon.com ([207.171.178.25]:9580) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WXcvU-0008Pd-CY for qemu-devel@nongnu.org; Tue, 08 Apr 2014 16:47:24 -0400 Date: Tue, 8 Apr 2014 13:47:16 -0700 From: "Noonan, Steven" Message-ID: <20140408204714.GA3225@amazon.com> References: <1396023542-19667-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline In-Reply-To: Subject: Re: [Qemu-devel] [PATCH for-2.0] configure: add option to disable -fstack-protector flags List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: Laurent Desnogues , Paolo Bonzini , Steven Noonan , QEMU Developers , Anthony Liguori On Tue, Apr 08, 2014 at 09:37:27PM +0100, Peter Maydell wrote: > On 28 March 2014 16:19, Paolo Bonzini 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