Skip to contentSkip to conversation

configure: fix -enable-debug with newer toolchains

PATCH Applied Avi Kivity 4 participants 4 messages Jun 6, 2012 – Jun 20, 2012

lore
Share & tools
lore

Avi Kivity

author
#0 lore raw

PATCH 1/1 configure: fix -enable-debug with newer toolchains

Fedora 17's toolchain wants optimization enabled for _FORTIFY_SOURCE; so disable _FORTIFY_SOURCE when debugging.

---
 configure |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
configure +1 -2
index 1f338f8..88d9c5b 100755
@@ -255,7 +255,6 @@ QEMU_CFLAGS="-fno-strict-aliasing $QEMU_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"
 if test "$debug_info" = "yes"; then
     CFLAGS="-g $CFLAGS"
@@ -2851,7 +2850,7 @@ fi
 # After here, no more $cc or $ld runs
 
 if test "$debug" = "no" ; then
-  CFLAGS="-O2 $CFLAGS"
+  CFLAGS="-O2 -D_FORTIFY_SOURCE=2 $CFLAGS"
 fi
 
 # Consult white-list to determine whether to enable werror
Signature · 1 line
1.7.10.1
#1 lore raw
Quoted 2 lines · Avi Kivity

Fedora 17's toolchain wants optimization enabled for _FORTIFY_SOURCE; so disable _FORTIFY_SOURCE when debugging.

Well, that sucks, but it seems to be a deliberate change in upstream glibc to make it warn now :-( I guess everybody in the world will have to fix their makefiles...

Quoted 20 lines

---
 configure |    3 +--

 1 file changed, 1 insertion(+), 2 deletions(-)
configure +0 -0
index 1f338f8..88d9c5b 100755
@@ -255,7 +255,6 @@ QEMU_CFLAGS="-fno-strict-aliasing $QEMU_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"
 if test "$debug_info" = "yes"; then
    CFLAGS="-g $CFLAGS"

configure +0 -0
@@ -2851,7 +2850,7 @@ fi
  # After here, no more $cc or $ld runs
 
Quoted 4 lines

 if test "$debug" = "no" ; then
-  CFLAGS="-O2 $CFLAGS"
+  CFLAGS="-O2 -D_FORTIFY_SOURCE=2 $CFLAGS"
 fi

It feels a bit odd to have the FORTIFY_SOURCE define in CFLAGS rather than QEMU_CFLAGS, but I think it should behave correctly so I think it's right.

-- PMM

Tested-by Reviewed-by on v1 1/1
#2 lore raw
In reply to Avi Kivity
Quoted 4 lines · Avi Kivity

Fedora 17's toolchain wants optimization enabled for _FORTIFY_SOURCE; so disable _FORTIFY_SOURCE when debugging.

I was bitten by this problem too. The patch fixes it for me.

The patch changes behavior a bit, by moving -D_FORTIFY_SOURCE to CFLAGS instead of QEMU_CFLAGS, but it sounds like a good idea to keep the -O option and -D_FORTIFY_SOURCE close together (anybody overriding/removing -O on CFLAGS on the make command-line would need to take care of -D_FORTIFY_SOURCE as well).

Quoted 28 lines
---
 configure |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
configure +1 -2
index 1f338f8..88d9c5b 100755
@@ -255,7 +255,6 @@ QEMU_CFLAGS="-fno-strict-aliasing $QEMU_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"
 if test "$debug_info" = "yes"; then
     CFLAGS="-g $CFLAGS"
@@ -2851,7 +2850,7 @@ fi
 # After here, no more $cc or $ld runs
 
 if test "$debug" = "no" ; then
-  CFLAGS="-O2 $CFLAGS"
+  CFLAGS="-O2 -D_FORTIFY_SOURCE=2 $CFLAGS"
 fi
 
 # Consult white-list to determine whether to enable werror
Signature · 1 line
1.7.10.1
Signature · 1 line
Eduardo
#3 lore raw
In reply to Avi Kivity
Quoted 4 lines · Avi Kivity

Fedora 17's toolchain wants optimization enabled for _FORTIFY_SOURCE; so disable _FORTIFY_SOURCE when debugging.

Applied. Thanks.

Regards,

Anthony Liguori

Quoted 25 lines
---
  configure |    3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
configure +1 -2
index 1f338f8..88d9c5b 100755
@@ -255,7 +255,6 @@ QEMU_CFLAGS="-fno-strict-aliasing $QEMU_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"
  if test "$debug_info" = "yes"; then
      CFLAGS="-g $CFLAGS"
@@ -2851,7 +2850,7 @@ fi
  # After here, no more $cc or $ld runs
 
  if test "$debug" = "no" ; then
-  CFLAGS="-O2 $CFLAGS"
+  CFLAGS="-O2 -D_FORTIFY_SOURCE=2 $CFLAGS"
  fi
 
  # Consult white-list to determine whether to enable werror