All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2] rules.mak: Force CFLAGS for all objects in DSO
@ 2015-05-07  6:55 Fam Zheng
  2015-05-11 22:24 ` Andreas Färber
  0 siblings, 1 reply; 3+ messages in thread
From: Fam Zheng @ 2015-05-07  6:55 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Fam Zheng, Stefan Weil, Michael Tokarev, agraf,
	Paolo Bonzini

Because of the trick of process-archive-undefs, all .mo objects, even
with --enable-modules, are dependencies of executables.

This breaks CFLAGS propogation because the compiling of module object
will happen too early before building for DSO.

With GCC 5, the linking would fail because .o doesn't have -fPIC. Also,
BUILD_DSO will be missed. (module-common.o will have it, so the stamp
symbol was still liked in .so).

Fix the problem by forcing the CFLAGS on individual .o-cflags during
unnest-vars.

Reported-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Fam Zheng <famz@redhat.com>

---

v2: Simplify as Paolo suggested, while keeping the CFLAGS of
module-common.o
---
 rules.mak | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/rules.mak b/rules.mak
index 3a05627..aec27f8 100644
--- a/rules.mak
+++ b/rules.mak
@@ -102,7 +102,8 @@ endif
 %.o: %.dtrace
 	$(call quiet-command,dtrace -o $@ -G -s $<, "  GEN   $(TARGET_DIR)$@")
 
-%$(DSOSUF): CFLAGS += -fPIC -DBUILD_DSO
+DSO_OBJ_CFLAGS := -fPIC -DBUILD_DSO
+module-common.o: CFLAGS += $(DSO_OBJ_CFLAGS)
 %$(DSOSUF): LDFLAGS += $(LDFLAGS_SHARED)
 %$(DSOSUF): %.mo
 	$(call LINK,$^)
@@ -351,6 +352,7 @@ define unnest-vars
         # For non-module build, add -m to -y
         $(if $(CONFIG_MODULES),
              $(foreach o,$($v),
+                   $(eval $($o-objs): CFLAGS += $(DSO_OBJ_CFLAGS))
                    $(eval $o: $($o-objs)))
              $(eval $(patsubst %-m,%-y,$v) += $($v))
              $(eval modules: $($v:%.mo=%$(DSOSUF))),
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH v2] rules.mak: Force CFLAGS for all objects in DSO
  2015-05-07  6:55 [Qemu-devel] [PATCH v2] rules.mak: Force CFLAGS for all objects in DSO Fam Zheng
@ 2015-05-11 22:24 ` Andreas Färber
  2015-05-12  1:03   ` Fam Zheng
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Färber @ 2015-05-11 22:24 UTC (permalink / raw)
  To: Fam Zheng, qemu-devel
  Cc: Peter Maydell, Paolo Bonzini, Michael Tokarev, agraf, Stefan Weil

Am 07.05.2015 um 08:55 schrieb Fam Zheng:
> Because of the trick of process-archive-undefs, all .mo objects, even
> with --enable-modules, are dependencies of executables.
> 
> This breaks CFLAGS propogation because the compiling of module object
> will happen too early before building for DSO.
> 
> With GCC 5, the linking would fail because .o doesn't have -fPIC. Also,
> BUILD_DSO will be missed. (module-common.o will have it, so the stamp
> symbol was still liked in .so).

Did you mean "linked"?

Cheers,
Andreas

> 
> Fix the problem by forcing the CFLAGS on individual .o-cflags during
> unnest-vars.
> 
> Reported-by: Alexander Graf <agraf@suse.de>
> Signed-off-by: Fam Zheng <famz@redhat.com>
> 
> ---
> 
> v2: Simplify as Paolo suggested, while keeping the CFLAGS of
> module-common.o
> ---
>  rules.mak | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/rules.mak b/rules.mak
> index 3a05627..aec27f8 100644
> --- a/rules.mak
> +++ b/rules.mak
> @@ -102,7 +102,8 @@ endif
>  %.o: %.dtrace
>  	$(call quiet-command,dtrace -o $@ -G -s $<, "  GEN   $(TARGET_DIR)$@")
>  
> -%$(DSOSUF): CFLAGS += -fPIC -DBUILD_DSO
> +DSO_OBJ_CFLAGS := -fPIC -DBUILD_DSO
> +module-common.o: CFLAGS += $(DSO_OBJ_CFLAGS)
>  %$(DSOSUF): LDFLAGS += $(LDFLAGS_SHARED)
>  %$(DSOSUF): %.mo
>  	$(call LINK,$^)
> @@ -351,6 +352,7 @@ define unnest-vars
>          # For non-module build, add -m to -y
>          $(if $(CONFIG_MODULES),
>               $(foreach o,$($v),
> +                   $(eval $($o-objs): CFLAGS += $(DSO_OBJ_CFLAGS))
>                     $(eval $o: $($o-objs)))
>               $(eval $(patsubst %-m,%-y,$v) += $($v))
>               $(eval modules: $($v:%.mo=%$(DSOSUF))),
> 


-- 
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Dilip Upmanyu, Graham Norton; HRB
21284 (AG Nürnberg)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH v2] rules.mak: Force CFLAGS for all objects in DSO
  2015-05-11 22:24 ` Andreas Färber
@ 2015-05-12  1:03   ` Fam Zheng
  0 siblings, 0 replies; 3+ messages in thread
From: Fam Zheng @ 2015-05-12  1:03 UTC (permalink / raw)
  To: Andreas Färber; +Cc: qemu-devel

On Tue, 05/12 00:24, Andreas Färber wrote:
> Am 07.05.2015 um 08:55 schrieb Fam Zheng:
> > Because of the trick of process-archive-undefs, all .mo objects, even
> > with --enable-modules, are dependencies of executables.
> > 
> > This breaks CFLAGS propogation because the compiling of module object
> > will happen too early before building for DSO.
> > 
> > With GCC 5, the linking would fail because .o doesn't have -fPIC. Also,
> > BUILD_DSO will be missed. (module-common.o will have it, so the stamp
> > symbol was still liked in .so).
> 
> Did you mean "linked"?

Yes but it's too late, the commit is already applied to qemu.git :(

Fam

> 
> Cheers,
> Andreas
> 
> > 
> > Fix the problem by forcing the CFLAGS on individual .o-cflags during
> > unnest-vars.
> > 
> > Reported-by: Alexander Graf <agraf@suse.de>
> > Signed-off-by: Fam Zheng <famz@redhat.com>
> > 
> > ---
> > 
> > v2: Simplify as Paolo suggested, while keeping the CFLAGS of
> > module-common.o
> > ---
> >  rules.mak | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/rules.mak b/rules.mak
> > index 3a05627..aec27f8 100644
> > --- a/rules.mak
> > +++ b/rules.mak
> > @@ -102,7 +102,8 @@ endif
> >  %.o: %.dtrace
> >  	$(call quiet-command,dtrace -o $@ -G -s $<, "  GEN   $(TARGET_DIR)$@")
> >  
> > -%$(DSOSUF): CFLAGS += -fPIC -DBUILD_DSO
> > +DSO_OBJ_CFLAGS := -fPIC -DBUILD_DSO
> > +module-common.o: CFLAGS += $(DSO_OBJ_CFLAGS)
> >  %$(DSOSUF): LDFLAGS += $(LDFLAGS_SHARED)
> >  %$(DSOSUF): %.mo
> >  	$(call LINK,$^)
> > @@ -351,6 +352,7 @@ define unnest-vars
> >          # For non-module build, add -m to -y
> >          $(if $(CONFIG_MODULES),
> >               $(foreach o,$($v),
> > +                   $(eval $($o-objs): CFLAGS += $(DSO_OBJ_CFLAGS))
> >                     $(eval $o: $($o-objs)))
> >               $(eval $(patsubst %-m,%-y,$v) += $($v))
> >               $(eval modules: $($v:%.mo=%$(DSOSUF))),
> > 
> 
> 
> -- 
> SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
> GF: Felix Imendörffer, Jane Smithard, Dilip Upmanyu, Graham Norton; HRB
> 21284 (AG Nürnberg)
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-05-12  1:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-07  6:55 [Qemu-devel] [PATCH v2] rules.mak: Force CFLAGS for all objects in DSO Fam Zheng
2015-05-11 22:24 ` Andreas Färber
2015-05-12  1:03   ` Fam Zheng

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.