diff mbox

[STABLE] build: Move QEMU_INCLUDES before QEMU_CFLAGS

Message ID 7d7114c0f2ebea6cf24689d9e58e6494d1b8a463.1312970654.git.jdenemar@redhat.com
State New
Headers show

Commit Message

Jiri Denemark Aug. 10, 2011, 10:04 a.m. UTC
This patch fixes build when any of the include paths from QEMU_CFLAGS
contains a header file with similar name to a header file in qemu
sources. I hit it with error.h included by qapi/qapi-types-core.h. GCC
decided to use /usr/include/alsa/error.h instead of qemu's error.h.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 rules.mak |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

Comments

Michael Roth Aug. 10, 2011, 12:46 p.m. UTC | #1
On 08/10/2011 05:04 AM, Jiri Denemark wrote:
> This patch fixes build when any of the include paths from QEMU_CFLAGS
> contains a header file with similar name to a header file in qemu
> sources. I hit it with error.h included by qapi/qapi-types-core.h. GCC
> decided to use /usr/include/alsa/error.h instead of qemu's error.h.
>
> Signed-off-by: Jiri Denemark<jdenemar@redhat.com>
> ---
>   rules.mak |    8 ++++----
>   1 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/rules.mak b/rules.mak
> index 612ae37..1a2622c 100644
> --- a/rules.mak
> +++ b/rules.mak
> @@ -15,21 +15,21 @@ MAKEFLAGS += -rR
>   QEMU_DGFLAGS += -MMD -MP -MT $@ -MF $(*D)/$(*F).d
>
>   %.o: %.c
> -	$(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_INCLUDES) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  CC    $(TARGET_DIR)$@")
> +	$(call quiet-command,$(CC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  CC    $(TARGET_DIR)$@")
>
>   ifeq ($(LIBTOOL),)
>   %.lo: %.c
>   	@echo "missing libtool. please install and rerun configure"; exit 1
>   else
>   %.lo: %.c
> -	$(call quiet-command,libtool --mode=compile --quiet --tag=CC $(CC) $(QEMU_CFLAGS) $(QEMU_INCLUDES) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  lt CC $@")
> +	$(call quiet-command,libtool --mode=compile --quiet --tag=CC $(CC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  lt CC $@")
>   endif
>
>   %.o: %.S
> -	$(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_INCLUDES) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  AS    $(TARGET_DIR)$@")
> +	$(call quiet-command,$(CC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  AS    $(TARGET_DIR)$@")
>
>   %.o: %.m
> -	$(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_INCLUDES) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  OBJC  $(TARGET_DIR)$@")
> +	$(call quiet-command,$(CC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  OBJC  $(TARGET_DIR)$@")
>
>   LINK = $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $(1) $(LIBS),"  LINK  $(TARGET_DIR)$@")
>

Nice, didn't realize the fix was that straightforward.

Tested-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Avi Kivity Aug. 10, 2011, 1:04 p.m. UTC | #2
On 08/10/2011 01:04 PM, Jiri Denemark wrote:
> This patch fixes build when any of the include paths from QEMU_CFLAGS
> contains a header file with similar name to a header file in qemu
> sources. I hit it with error.h included by qapi/qapi-types-core.h. GCC
> decided to use /usr/include/alsa/error.h instead of qemu's error.h.
>
> Signed-off-by: Jiri Denemark<jdenemar@redhat.com>
> ---
>   rules.mak |    8 ++++----
>   1 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/rules.mak b/rules.mak
> index 612ae37..1a2622c 100644
> --- a/rules.mak
> +++ b/rules.mak
> @@ -15,21 +15,21 @@ MAKEFLAGS += -rR
>   QEMU_DGFLAGS += -MMD -MP -MT $@ -MF $(*D)/$(*F).d
>
>   %.o: %.c
> -	$(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_INCLUDES) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  CC    $(TARGET_DIR)$@")
> +	$(call quiet-command,$(CC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  CC    $(TARGET_DIR)$@")
>
>

Shouldn't we use -isystem instead of -I for system headers?
Jiri Denemark Aug. 10, 2011, 2:02 p.m. UTC | #3
On Wed, Aug 10, 2011 at 16:04:15 +0300, Avi Kivity wrote:
> On 08/10/2011 01:04 PM, Jiri Denemark wrote:
> > This patch fixes build when any of the include paths from QEMU_CFLAGS
> > contains a header file with similar name to a header file in qemu
> > sources. I hit it with error.h included by qapi/qapi-types-core.h. GCC
> > decided to use /usr/include/alsa/error.h instead of qemu's error.h.
> >
> > Signed-off-by: Jiri Denemark<jdenemar@redhat.com>
> > ---
> >   rules.mak |    8 ++++----
> >   1 files changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/rules.mak b/rules.mak
> > index 612ae37..1a2622c 100644
> > --- a/rules.mak
> > +++ b/rules.mak
> > @@ -15,21 +15,21 @@ MAKEFLAGS += -rR
> >   QEMU_DGFLAGS += -MMD -MP -MT $@ -MF $(*D)/$(*F).d
> >
> >   %.o: %.c
> > -	$(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_INCLUDES) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  CC    $(TARGET_DIR)$@")
> > +	$(call quiet-command,$(CC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  CC    $(TARGET_DIR)$@")
> >
> >
> 
> Shouldn't we use -isystem instead of -I for system headers?

That would be ideal but unfortunately QEMU_CFLAGS also contains output of
pkg-config --cflags which uses -I for header paths. We would need to convert
them to -isystem. And is -isystem even portable to other compilers (in case we
care about that)?

IMHO just moving paths to qemu sources first is easier and the result is the
same.

Jirka
Avi Kivity Aug. 10, 2011, 2:08 p.m. UTC | #4
On 08/10/2011 05:02 PM, Jiri Denemark wrote:
> >
> >  Shouldn't we use -isystem instead of -I for system headers?
>
> That would be ideal but unfortunately QEMU_CFLAGS also contains output of
> pkg-config --cflags which uses -I for header paths. We would need to convert
> them to -isystem. And is -isystem even portable to other compilers (in case we
> care about that)?

Well, it's really a pkg-config bug.  It should check whether -isystem is 
supported and use it if so.

> IMHO just moving paths to qemu sources first is easier and the result is the
> same.
>

Agree.
Anthony Liguori Aug. 12, 2011, 1:46 p.m. UTC | #5
On 08/10/2011 05:04 AM, Jiri Denemark wrote:
> This patch fixes build when any of the include paths from QEMU_CFLAGS
> contains a header file with similar name to a header file in qemu
> sources. I hit it with error.h included by qapi/qapi-types-core.h. GCC
> decided to use /usr/include/alsa/error.h instead of qemu's error.h.

Applied to master.  Thanks.

Regards,

Anthony Liguori

>
> Signed-off-by: Jiri Denemark<jdenemar@redhat.com>
> ---
>   rules.mak |    8 ++++----
>   1 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/rules.mak b/rules.mak
> index 612ae37..1a2622c 100644
> --- a/rules.mak
> +++ b/rules.mak
> @@ -15,21 +15,21 @@ MAKEFLAGS += -rR
>   QEMU_DGFLAGS += -MMD -MP -MT $@ -MF $(*D)/$(*F).d
>
>   %.o: %.c
> -	$(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_INCLUDES) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  CC    $(TARGET_DIR)$@")
> +	$(call quiet-command,$(CC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  CC    $(TARGET_DIR)$@")
>
>   ifeq ($(LIBTOOL),)
>   %.lo: %.c
>   	@echo "missing libtool. please install and rerun configure"; exit 1
>   else
>   %.lo: %.c
> -	$(call quiet-command,libtool --mode=compile --quiet --tag=CC $(CC) $(QEMU_CFLAGS) $(QEMU_INCLUDES) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  lt CC $@")
> +	$(call quiet-command,libtool --mode=compile --quiet --tag=CC $(CC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  lt CC $@")
>   endif
>
>   %.o: %.S
> -	$(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_INCLUDES) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  AS    $(TARGET_DIR)$@")
> +	$(call quiet-command,$(CC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  AS    $(TARGET_DIR)$@")
>
>   %.o: %.m
> -	$(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_INCLUDES) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  OBJC  $(TARGET_DIR)$@")
> +	$(call quiet-command,$(CC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  OBJC  $(TARGET_DIR)$@")
>
>   LINK = $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $(1) $(LIBS),"  LINK  $(TARGET_DIR)$@")
>
diff mbox

Patch

diff --git a/rules.mak b/rules.mak
index 612ae37..1a2622c 100644
--- a/rules.mak
+++ b/rules.mak
@@ -15,21 +15,21 @@  MAKEFLAGS += -rR
 QEMU_DGFLAGS += -MMD -MP -MT $@ -MF $(*D)/$(*F).d
 
 %.o: %.c
-	$(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_INCLUDES) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  CC    $(TARGET_DIR)$@")
+	$(call quiet-command,$(CC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  CC    $(TARGET_DIR)$@")
 
 ifeq ($(LIBTOOL),)
 %.lo: %.c
 	@echo "missing libtool. please install and rerun configure"; exit 1
 else
 %.lo: %.c
-	$(call quiet-command,libtool --mode=compile --quiet --tag=CC $(CC) $(QEMU_CFLAGS) $(QEMU_INCLUDES) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  lt CC $@")
+	$(call quiet-command,libtool --mode=compile --quiet --tag=CC $(CC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  lt CC $@")
 endif
 
 %.o: %.S
-	$(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_INCLUDES) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  AS    $(TARGET_DIR)$@")
+	$(call quiet-command,$(CC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  AS    $(TARGET_DIR)$@")
 
 %.o: %.m
-	$(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_INCLUDES) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  OBJC  $(TARGET_DIR)$@")
+	$(call quiet-command,$(CC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  OBJC  $(TARGET_DIR)$@")
 
 LINK = $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $(1) $(LIBS),"  LINK  $(TARGET_DIR)$@")