diff mbox

[07/39] do not pass bogus $(SRC_PATH) include paths to cc during configure

Message ID 1286888457-5033-8-git-send-email-pbonzini@redhat.com
State New
Headers show

Commit Message

Paolo Bonzini Oct. 12, 2010, 1 p.m. UTC
Non-existent -I paths are dropped silently by the compiler, but still
it is not polite to pass bogus options.  Configure-time tests do not
need any include files from the source path, so only include -I flags
at make time (when they're properly expanded).

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 configure |   19 +++++++++++--------
 rules.mak |    8 ++++----
 2 files changed, 15 insertions(+), 12 deletions(-)

Comments

Blue Swirl Oct. 12, 2010, 7:09 p.m. UTC | #1
On Tue, Oct 12, 2010 at 1:00 PM, Paolo Bonzini <pbonzini@redhat.com> wrote:
> Non-existent -I paths are dropped silently by the compiler, but still
> it is not polite to pass bogus options.  Configure-time tests do not
> need any include files from the source path, so only include -I flags
> at make time (when they're properly expanded).
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  configure |   19 +++++++++++--------
>  rules.mak |    8 ++++----
>  2 files changed, 15 insertions(+), 12 deletions(-)
>
> diff --git a/configure b/configure
> index a8738db..cb76177 100755
> --- a/configure
> +++ b/configure
> @@ -224,7 +224,7 @@ QEMU_CFLAGS="-Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes $
>  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"

Aren't the above also CPP flags?

> -QEMU_CFLAGS="-I. -I\$(SRC_PATH) $QEMU_CFLAGS"
> +QEMU_CPPFLAGS="-I. -I\$(SRC_PATH)"
>  LDFLAGS="-g $LDFLAGS"
>
>  check_define() {
> @@ -2419,7 +2419,7 @@ if test $profiler = "yes" ; then
>  fi
>  if test "$slirp" = "yes" ; then
>   echo "CONFIG_SLIRP=y" >> $config_host_mak
> -  QEMU_CFLAGS="-I\$(SRC_PATH)/slirp $QEMU_CFLAGS"
> +  QEMU_CPPFLAGS="-I\$(SRC_PATH)/slirp $QEMU_CPPFLAGS"
>  fi
>  if test "$vde" = "yes" ; then
>   echo "CONFIG_VDE=y" >> $config_host_mak
> @@ -2636,6 +2636,7 @@ echo "LD=$ld" >> $config_host_mak
>  echo "WINDRES=$windres" >> $config_host_mak
>  echo "CFLAGS=$CFLAGS" >> $config_host_mak
>  echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
> +echo "QEMU_CPPFLAGS=$QEMU_CPPFLAGS" >> $config_host_mak
>  if test "$sparse" = "yes" ; then
>   echo "CC           := REAL_CC=\"\$(CC)\" cgcc"       >> $config_host_mak
>   echo "HOST_CC      := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
> @@ -2944,19 +2945,20 @@ fi
>  # generate QEMU_CFLAGS/LDFLAGS for targets
>
>  cflags=""
> +cppflags=""
>  ldflags=""
>
>  if test "$ARCH" = "sparc64" ; then
> -  cflags="-I\$(SRC_PATH)/tcg/sparc $cflags"
> +  cppflags="-I\$(SRC_PATH)/tcg/sparc $cppflags"
>  elif test "$ARCH" = "s390x" ; then
> -  cflags="-I\$(SRC_PATH)/tcg/s390 $cflags"
> +  cppflags="-I\$(SRC_PATH)/tcg/s390 $cppflags"
>  elif test "$ARCH" = "x86_64" ; then
> -  cflags="-I\$(SRC_PATH)/tcg/i386 $cflags"
> +  cppflags="-I\$(SRC_PATH)/tcg/i386 $cppflags"
>  else
> -  cflags="-I\$(SRC_PATH)/tcg/\$(ARCH) $cflags"
> +  cppflags="-I\$(SRC_PATH)/tcg/\$(ARCH) $cppflags"
>  fi
> -cflags="-I\$(SRC_PATH)/tcg $cflags"
> -cflags="-I\$(SRC_PATH)/fpu $cflags"
> +cppflags="-I\$(SRC_PATH)/tcg $cppflags"
> +cppflags="-I\$(SRC_PATH)/fpu $cppflags"
>
>  if test "$target_user_only" = "yes" ; then
>     libdis_config_mak=libdis-user/config.mak
> @@ -3081,6 +3083,7 @@ fi
>
>  echo "LDFLAGS+=$ldflags" >> $config_target_mak
>  echo "QEMU_CFLAGS+=$cflags" >> $config_target_mak
> +echo "QEMU_CPPFLAGS+=$cppflags" >> $config_target_mak
>
>  done # for target in $targets
>
> diff --git a/rules.mak b/rules.mak
> index c843a13..007fc49 100644
> --- a/rules.mak
> +++ b/rules.mak
> @@ -15,15 +15,15 @@ MAKEFLAGS += -rR
>  QEMU_DGFLAGS += -MMD -MP -MT $@ -MF $(*D)/$(*F).d
>
>  %.o: %.c
> -       $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  CC    $(TARGET_DIR)$@")
> +       $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_CPPFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  CC    $(TARGET_DIR)$@")
>
>  %.o: %.S
> -       $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  AS    $(TARGET_DIR)$@")
> +       $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_CPPFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  AS    $(TARGET_DIR)$@")
>
>  %.o: %.m
> -       $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  OBJC  $(TARGET_DIR)$@")
> +       $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_CPPFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  OBJC  $(TARGET_DIR)$@")
>
> -LINK = $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $(1) $(LIBS),"  LINK  $(TARGET_DIR)$@")
> +LINK = $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $(1) $(LIBS),"  LINK  $(TARGET_DIR)$@")

I don't think the linker will use any CPP flags.
Paolo Bonzini Oct. 13, 2010, 7:25 a.m. UTC | #2
On 10/12/2010 09:09 PM, Blue Swirl wrote:
>>   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"
>
> Aren't the above also CPP flags?

Yes, the difference is that the QEMU_CPPFLAGS are not used in the 
configure tests.  Instead, you need to use the above -D flags because 
they affect the system headers.  I'll rename QEMU_CPPFLAGS to QEMU_INCLUDES.

>> -LINK = $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $(1) $(LIBS),"  LINK  $(TARGET_DIR)$@")
>> +LINK = $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $(1) $(LIBS),"  LINK  $(TARGET_DIR)$@")
>
> I don't think the linker will use any CPP flags.

Yeah, though it doesn't use most CFLAGS either.  I'll remove the 
CPPFLAGS only, in both patches.

Paolo
diff mbox

Patch

diff --git a/configure b/configure
index a8738db..cb76177 100755
--- a/configure
+++ b/configure
@@ -224,7 +224,7 @@  QEMU_CFLAGS="-Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes $
 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_CFLAGS="-I. -I\$(SRC_PATH) $QEMU_CFLAGS"
+QEMU_CPPFLAGS="-I. -I\$(SRC_PATH)"
 LDFLAGS="-g $LDFLAGS"
 
 check_define() {
@@ -2419,7 +2419,7 @@  if test $profiler = "yes" ; then
 fi
 if test "$slirp" = "yes" ; then
   echo "CONFIG_SLIRP=y" >> $config_host_mak
-  QEMU_CFLAGS="-I\$(SRC_PATH)/slirp $QEMU_CFLAGS"
+  QEMU_CPPFLAGS="-I\$(SRC_PATH)/slirp $QEMU_CPPFLAGS"
 fi
 if test "$vde" = "yes" ; then
   echo "CONFIG_VDE=y" >> $config_host_mak
@@ -2636,6 +2636,7 @@  echo "LD=$ld" >> $config_host_mak
 echo "WINDRES=$windres" >> $config_host_mak
 echo "CFLAGS=$CFLAGS" >> $config_host_mak
 echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
+echo "QEMU_CPPFLAGS=$QEMU_CPPFLAGS" >> $config_host_mak
 if test "$sparse" = "yes" ; then
   echo "CC           := REAL_CC=\"\$(CC)\" cgcc"       >> $config_host_mak
   echo "HOST_CC      := REAL_CC=\"\$(HOST_CC)\" cgcc"  >> $config_host_mak
@@ -2944,19 +2945,20 @@  fi
 # generate QEMU_CFLAGS/LDFLAGS for targets
 
 cflags=""
+cppflags=""
 ldflags=""
 
 if test "$ARCH" = "sparc64" ; then
-  cflags="-I\$(SRC_PATH)/tcg/sparc $cflags"
+  cppflags="-I\$(SRC_PATH)/tcg/sparc $cppflags"
 elif test "$ARCH" = "s390x" ; then
-  cflags="-I\$(SRC_PATH)/tcg/s390 $cflags"
+  cppflags="-I\$(SRC_PATH)/tcg/s390 $cppflags"
 elif test "$ARCH" = "x86_64" ; then
-  cflags="-I\$(SRC_PATH)/tcg/i386 $cflags"
+  cppflags="-I\$(SRC_PATH)/tcg/i386 $cppflags"
 else
-  cflags="-I\$(SRC_PATH)/tcg/\$(ARCH) $cflags"
+  cppflags="-I\$(SRC_PATH)/tcg/\$(ARCH) $cppflags"
 fi
-cflags="-I\$(SRC_PATH)/tcg $cflags"
-cflags="-I\$(SRC_PATH)/fpu $cflags"
+cppflags="-I\$(SRC_PATH)/tcg $cppflags"
+cppflags="-I\$(SRC_PATH)/fpu $cppflags"
 
 if test "$target_user_only" = "yes" ; then
     libdis_config_mak=libdis-user/config.mak
@@ -3081,6 +3083,7 @@  fi
 
 echo "LDFLAGS+=$ldflags" >> $config_target_mak
 echo "QEMU_CFLAGS+=$cflags" >> $config_target_mak
+echo "QEMU_CPPFLAGS+=$cppflags" >> $config_target_mak
 
 done # for target in $targets
 
diff --git a/rules.mak b/rules.mak
index c843a13..007fc49 100644
--- a/rules.mak
+++ b/rules.mak
@@ -15,15 +15,15 @@  MAKEFLAGS += -rR
 QEMU_DGFLAGS += -MMD -MP -MT $@ -MF $(*D)/$(*F).d
 
 %.o: %.c
-	$(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  CC    $(TARGET_DIR)$@")
+	$(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_CPPFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  CC    $(TARGET_DIR)$@")
 
 %.o: %.S
-	$(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  AS    $(TARGET_DIR)$@")
+	$(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_CPPFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  AS    $(TARGET_DIR)$@")
 
 %.o: %.m
-	$(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  OBJC  $(TARGET_DIR)$@")
+	$(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_CPPFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  OBJC  $(TARGET_DIR)$@")
 
-LINK = $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $(1) $(LIBS),"  LINK  $(TARGET_DIR)$@")
+LINK = $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $(1) $(LIBS),"  LINK  $(TARGET_DIR)$@")
 
 %$(EXESUF): %.o
 	$(call LINK,$^)