qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Brad <brad@comstyle.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] Only build with -g CFLAGS/LDFLAGS if using --enable-debug and add --optflags.
Date: Tue, 6 Sep 2011 04:02:48 -0400	[thread overview]
Message-ID: <20110906080245.GA26732@rox.home.comstyle.com> (raw)

Only build with -g CFLAGS/LDFLAGS if using --enable-debug.
Add --optflags to allow overriding the default optimization
level added to CFLAGS.

This is a first draft of coming up with a patch I could potentially
push upstream based on much cruder local patches to do something
similar. I'm trying to eliminate having to patch the configure
script.

Comments?

---
 configure |   19 +++++++++++++++----
 1 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/configure b/configure
index c3044c7..23a85a7 100755
--- a/configure
+++ b/configure
@@ -77,6 +77,7 @@ path_of() {
 # default parameters
 source_path=`dirname "$0"`
 cpu=""
+optflags=""
 interp_prefix="/usr/gnemul/qemu-%M"
 static="no"
 sparc_cpu=""
@@ -195,6 +196,8 @@ for opt do
   ;;
   --cpu=*) cpu="$optarg"
   ;;
+  --optflags=*) optflags="$optarg"
+  ;;
   --extra-cflags=*) QEMU_CFLAGS="$optarg $QEMU_CFLAGS"
   ;;
   --extra-ldflags=*) LDFLAGS="$optarg $LDFLAGS"
@@ -232,13 +235,11 @@ sdl_config="${SDL_CONFIG-${cross_prefix}sdl-config}"
 
 # default flags for all hosts
 QEMU_CFLAGS="-fno-strict-aliasing $QEMU_CFLAGS"
-CFLAGS="-g $CFLAGS"
 QEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
 QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
 QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
 QEMU_CFLAGS="-D_FORTIFY_SOURCE=2 $QEMU_CFLAGS"
 QEMU_INCLUDES="-I. -I\$(SRC_PATH) -I\$(SRC_PATH)/fpu"
-LDFLAGS="-g $LDFLAGS"
 
 # make source path absolute
 source_path=`cd "$source_path"; pwd`
@@ -518,6 +519,8 @@ for opt do
   ;;
   --cc=*)
   ;;
+  --optflags=*)
+  ;;
   --host-cc=*) host_cc="$optarg"
   ;;
   --make=*) make="$optarg"
@@ -937,6 +940,7 @@ echo "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
 echo "  --cc=CC                  use C compiler CC [$cc]"
 echo "  --host-cc=CC             use C compiler CC [$host_cc] for code run at"
 echo "                           build time"
+echo "  --optflags=FLAGS         override optimization compiler flags"
 echo "  --extra-cflags=CFLAGS    append extra C compiler flags QEMU_CFLAGS"
 echo "  --extra-ldflags=LDFLAGS  append extra linker flags LDFLAGS"
 echo "  --make=MAKE              use specified make [$make]"
@@ -2569,8 +2573,15 @@ fi
 # End of CC checks
 # After here, no more $cc or $ld runs
 
-if test "$debug" = "no" ; then
-  CFLAGS="-O2 $CFLAGS"
+if test "$debug" = "yes" ; then
+  CFLAGS="-g $CFLAGS"
+  LDFLAGS="-g $LDFLAGS"
+else
+  if test -n "$optflags" ; then
+      CFLAGS="$optflags $CFLAGS"
+  else
+      CFLAGS="-O2 $CFLAGS"
+  fi
 fi
 
 # Consult white-list to determine whether to enable werror
-- 
1.7.6

             reply	other threads:[~2011-09-06  8:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-06  8:02 Brad [this message]
2011-09-06  9:26 ` [Qemu-devel] [PATCH] Only build with -g CFLAGS/LDFLAGS if using --enable-debug and add --optflags Peter Maydell
2011-09-06 10:19 ` Gerd Hoffmann
2011-09-06 16:30   ` Brad
2011-09-07 10:54     ` Juan Quintela
2011-09-07 19:42       ` Blue Swirl
2011-09-07 21:31     ` Stefan Weil
2011-09-06 10:35 ` 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=20110906080245.GA26732@rox.home.comstyle.com \
    --to=brad@comstyle.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).