All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] only link current target arch traces to qemu-system
@ 2017-03-22  2:03 Xu, Anthony
  2017-03-22 13:37 ` Paolo Bonzini
  0 siblings, 1 reply; 5+ messages in thread
From: Xu, Anthony @ 2017-03-22  2:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: 'Paolo Bonzini'

When building target x86_64-softmmu, all other architectures' trace.o are linked into 
x86_64-softmmu/qemu-system-x86_64, like hw/arm/trace.o, hw/mips/trace.o etc., 
that is not necessary.
 Same thing happens when building other targets.

Only current target arch traces should be linked into qemu-system.

Signed-off -by: Anthony Xu <anthony.xu@intel.com>




diff --git a/Makefile.target b/Makefile.target
index 7df2b8c..638e044 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -177,6 +177,41 @@ block-obj-y :=
 common-obj-y :=
 chardev-obj-y :=
 include $(SRC_PATH)/Makefile.objs
+
+# remove all arch related trace
+trace-obj-y := $(filter-out hw/alpha/trace.o hw/alpha/trace-dtrace.o,$(trace-obj-y))
+trace-obj-y := $(filter-out target/alpha/trace.o target/alpha/trace-dtrace.o,$(trace-obj-y))
+
+trace-obj-y := $(filter-out hw/arm/trace.o hw/arm/trace-dtrace.o,$(trace-obj-y))
+trace-obj-y := $(filter-out target/arm/trace.o target/arm/trace-dtrace.o,$(trace-obj-y))
+
+trace-obj-y := $(filter-out hw/i386/trace.o hw/i386/trace-dtrace.o,$(trace-obj-y))
+trace-obj-y := $(filter-out target/i386/trace.o target/i386/trace-dtrace.o,$(trace-obj-y))
+
+trace-obj-y := $(filter-out hw/mips/trace.o hw/mips/trace-dtrace.o,$(trace-obj-y))
+trace-obj-y := $(filter-out target/mips/trace.o target/mips/trace-dtrace.o,$(trace-obj-y))
+
+trace-obj-y := $(filter-out hw/sparc/trace.o hw/sparc/trace-dtrace.o,$(trace-obj-y))
+trace-obj-y := $(filter-out target/sparc/trace.o target/sparc/trace-dtrace.o,$(trace-obj-y))
+
+trace-obj-y := $(filter-out hw/s390x/trace.o hw/s390x/trace-dtrace.o,$(trace-obj-y))
+trace-obj-y := $(filter-out target/s390x/trace.o target/s390x/trace-dtrace.o,$(trace-obj-y))
+
+trace-obj-y := $(filter-out hw/ppc/trace.o hw/ppc/trace-dtrace.o,$(trace-obj-y))
+trace-obj-y := $(filter-out target/ppc/trace.o target/ppc/trace-dtrace.o,$(trace-obj-y))
+
+# add current arch related trace
+carch := $(TARGET_BASE_ARCH)
+ifneq ($(wildcard $(SRC_PATH)/hw/$(carch)/trace-events),)
+trace-obj-y += hw/$(carch)/trace.o
+trace-obj-$(CONFIG_TRACE_DTRACE) += hw/$(carch)/trace-dtrace.o
+endif
+
+ifneq ($(wildcard $(SRC_PATH)/target/$(carch)/trace-events),)
+trace-obj-y += target/$(carch)/trace.o
+trace-obj-$(CONFIG_TRACE_DTRACE) += target/$(carch)/trace-dtrace.o
+endif
+
 dummy := $(call unnest-vars,,target-obj-y)
 target-obj-y-save := $(target-obj-y)
 dummy := $(call unnest-vars,.., \

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

* Re: [Qemu-devel] [PATCH] only link current target arch traces to qemu-system
  2017-03-22  2:03 [Qemu-devel] [PATCH] only link current target arch traces to qemu-system Xu, Anthony
@ 2017-03-22 13:37 ` Paolo Bonzini
  2017-03-23  9:05   ` Stefan Hajnoczi
  0 siblings, 1 reply; 5+ messages in thread
From: Paolo Bonzini @ 2017-03-22 13:37 UTC (permalink / raw)
  To: Xu, Anthony, qemu-devel



On 22/03/2017 03:03, Xu, Anthony wrote:
> When building target x86_64-softmmu, all other architectures' trace.o are linked into 
> x86_64-softmmu/qemu-system-x86_64, like hw/arm/trace.o, hw/mips/trace.o etc., 
> that is not necessary.
>  Same thing happens when building other targets.
> 
> Only current target arch traces should be linked into qemu-system.
> 
> Signed-off -by: Anthony Xu <anthony.xu@intel.com>

It's a bit cleaner, but does the benefit outweight the maintenance cost
of the additional code added to the Makefiles?

Paolo

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

* Re: [Qemu-devel] [PATCH] only link current target arch traces to qemu-system
  2017-03-22 13:37 ` Paolo Bonzini
@ 2017-03-23  9:05   ` Stefan Hajnoczi
  2017-03-24  0:29     ` Xu, Anthony
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Hajnoczi @ 2017-03-23  9:05 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: Xu, Anthony, qemu-devel, Daniel Berrange

[-- Attachment #1: Type: text/plain, Size: 1357 bytes --]

On Wed, Mar 22, 2017 at 02:37:21PM +0100, Paolo Bonzini wrote:
> 
> 
> On 22/03/2017 03:03, Xu, Anthony wrote:
> > When building target x86_64-softmmu, all other architectures' trace.o are linked into 
> > x86_64-softmmu/qemu-system-x86_64, like hw/arm/trace.o, hw/mips/trace.o etc., 
> > that is not necessary.
> >  Same thing happens when building other targets.
> > 
> > Only current target arch traces should be linked into qemu-system.
> > 
> > Signed-off -by: Anthony Xu <anthony.xu@intel.com>
> 
> It's a bit cleaner, but does the benefit outweight the maintenance cost
> of the additional code added to the Makefiles?

Perhaps all trace.o files should be put into their own .a instead of
being added directly to the linker line:

COMMON_LDADDS = $(trace-obj-y) libqemuutil.a libqemustub.a

I think the linker would only pull in .o files containing symbols that are
actually referenced by the program.

It would look like this:

######################################################################
# Build libraries

libqemustub.a: $(stub-obj-y)
libqemuutil.a: $(util-obj-y)
libqemutrace.a: $(trace-obj-y)

######################################################################

COMMON_LDADDS = libqemuutil.a libqemustub.a libqemutrace.a

This eliminates the maintenance burden with Anthony's patch.

Stefan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

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

* Re: [Qemu-devel] [PATCH] only link current target arch traces to qemu-system
  2017-03-23  9:05   ` Stefan Hajnoczi
@ 2017-03-24  0:29     ` Xu, Anthony
  2017-03-24 15:29       ` Stefan Hajnoczi
  0 siblings, 1 reply; 5+ messages in thread
From: Xu, Anthony @ 2017-03-24  0:29 UTC (permalink / raw)
  To: Stefan Hajnoczi, Paolo Bonzini; +Cc: qemu-devel, Daniel Berrange

> Perhaps all trace.o files should be put into their own .a instead of
> being added directly to the linker line:
> 
> COMMON_LDADDS = $(trace-obj-y) libqemuutil.a libqemustub.a
> 
> I think the linker would only pull in .o files containing symbols that are
> actually referenced by the program.

Hi Stefan,

That's a good idea!

Below patch creates libqemutrace.a.  ./trace.o, ./qapi/trace.o and 
./util/trace.o are added into libqemuutil.a  to avoid recursive dependencies 
between libqemuutil.a and libqemutrace.a.


Anthony




diff --git a/Makefile b/Makefile
index 6c359b2..565f5c7 100644
--- a/Makefile
+++ b/Makefile
@@ -345,8 +345,8 @@ subdir-dtc:dtc/libfdt dtc/tests
 dtc/%:
        mkdir -p $@

-$(SUBDIR_RULES): libqemuutil.a libqemustub.a $(common-obj-y) $(chardev-obj-y) \
-       $(qom-obj-y) $(crypto-aes-obj-$(CONFIG_USER_ONLY)) $(trace-obj-y)
+$(SUBDIR_RULES): libqemutrace.a libqemuutil.a libqemustub.a $(common-obj-y) $(chardev-obj-y) \
+       $(qom-obj-y) $(crypto-aes-obj-$(CONFIG_USER_ONLY))

 ROMSUBDIR_RULES=$(patsubst %,romsubdir-%, $(ROMS))
 # Only keep -O and -g cflags
@@ -367,10 +367,11 @@ Makefile: $(version-obj-y)

 libqemustub.a: $(stub-obj-y)
 libqemuutil.a: $(util-obj-y)
+libqemutrace.a: $(trace-obj-y)

 ######################################################################

-COMMON_LDADDS = $(trace-obj-y) libqemuutil.a libqemustub.a
+COMMON_LDADDS = libqemutrace.a libqemuutil.a libqemustub.a

 qemu-img.o: qemu-img-cmds.h

diff --git a/Makefile.objs b/Makefile.objs
index 6167e7b..4289ef9 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -3,6 +3,7 @@
 stub-obj-y = stubs/ crypto/
 util-obj-y = util/ qobject/ qapi/
 util-obj-y += qmp-introspect.o qapi-types.o qapi-visit.o qapi-event.o
+util-obj-y += $(trace-root-obj-y)

 chardev-obj-y = chardev/

@@ -167,8 +168,9 @@ trace-events-subdirs += qapi

 trace-events-files = $(SRC_PATH)/trace-events $(trace-events-subdirs:%=$(SRC_PATH)/%/trace-events)

-trace-obj-y = trace-root.o
+trace-root-obj-y = trace-root.o
+trace-root-obj-$(CONFIG_TRACE_DTRACE) += trace-dtrace-root.o
+trace-obj-y = $(trace-root-obj-y)
 trace-obj-y += $(trace-events-subdirs:%=%/trace.o)
 trace-obj-$(CONFIG_TRACE_UST) += trace-ust-all.o
-trace-obj-$(CONFIG_TRACE_DTRACE) += trace-dtrace-root.o
 trace-obj-$(CONFIG_TRACE_DTRACE) += $(trace-events-subdirs:%=%/trace-dtrace.o)
diff --git a/Makefile.target b/Makefile.target
index 7df2b8c..6f508c8 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -201,7 +201,7 @@ all-obj-$(CONFIG_SOFTMMU) += $(io-obj-y)

 $(QEMU_PROG_BUILD): config-devices.mak

-COMMON_LDADDS = $(trace-obj-y) ../libqemuutil.a ../libqemustub.a
+COMMON_LDADDS = ../libqemutrace.a ../libqemuutil.a ../libqemustub.a

 # build either PROG or PROGW
 $(QEMU_PROG_BUILD): $(all-obj-y) $(COMMON_LDADDS)
diff --git a/qapi/Makefile.objs b/qapi/Makefile.objs
index 33906ff..d543d56 100644
--- a/qapi/Makefile.objs
+++ b/qapi/Makefile.objs
@@ -4,3 +4,5 @@ util-obj-y += string-input-visitor.o string-output-visitor.o
 util-obj-y += opts-visitor.o qapi-clone-visitor.o
 util-obj-y += qmp-event.o
 util-obj-y += qapi-util.o
+util-obj-y +=  trace.o
+util-obj-$(CONFIG_TRACE_DTRACE) += trace-dtrace.o
diff --git a/tests/Makefile.include b/tests/Makefile.include
index f3de81f..6cbd602 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -519,7 +519,7 @@ QEMU_CFLAGS += -I$(SRC_PATH)/tests


 # Deps that are common to various different sets of tests below
-test-util-obj-y = $(trace-obj-y) libqemuutil.a libqemustub.a
+test-util-obj-y = libqemutrace.a libqemuutil.a libqemustub.a
 test-qom-obj-y = $(qom-obj-y) $(test-util-obj-y)
 test-qapi-obj-y = tests/test-qapi-visit.o tests/test-qapi-types.o \
        tests/test-qapi-event.o tests/test-qmp-introspect.o \
diff --git a/util/Makefile.objs b/util/Makefile.objs
index c6205eb..e38b91e 100644
--- a/util/Makefile.objs
+++ b/util/Makefile.objs
@@ -43,3 +43,5 @@ util-obj-y += qdist.o
 util-obj-y += qht.o
 util-obj-y += range.o
 util-obj-y += systemd.o
+util-obj-y +=  trace.o
+util-obj-$(CONFIG_TRACE_DTRACE) += trace-dtrace.o
                                                           

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

* Re: [Qemu-devel] [PATCH] only link current target arch traces to qemu-system
  2017-03-24  0:29     ` Xu, Anthony
@ 2017-03-24 15:29       ` Stefan Hajnoczi
  0 siblings, 0 replies; 5+ messages in thread
From: Stefan Hajnoczi @ 2017-03-24 15:29 UTC (permalink / raw)
  To: Xu, Anthony; +Cc: Paolo Bonzini, qemu-devel, Daniel Berrange

[-- Attachment #1: Type: text/plain, Size: 893 bytes --]

On Fri, Mar 24, 2017 at 12:29:39AM +0000, Xu, Anthony wrote:
> > Perhaps all trace.o files should be put into their own .a instead of
> > being added directly to the linker line:
> > 
> > COMMON_LDADDS = $(trace-obj-y) libqemuutil.a libqemustub.a
> > 
> > I think the linker would only pull in .o files containing symbols that are
> > actually referenced by the program.
> 
> Hi Stefan,
> 
> That's a good idea!
> 
> Below patch creates libqemutrace.a.  ./trace.o, ./qapi/trace.o and 
> ./util/trace.o are added into libqemuutil.a  to avoid recursive dependencies 
> between libqemuutil.a and libqemutrace.a.

Please see the guidelines for submitting patches:
http://wiki.qemu-project.org/Contribute/SubmitAPatch

Each patch revision should be sent as a separate email thread.

Each patch series must have your Signed-off-by and a commit
message/description.

Stefan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

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

end of thread, other threads:[~2017-03-24 15:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-22  2:03 [Qemu-devel] [PATCH] only link current target arch traces to qemu-system Xu, Anthony
2017-03-22 13:37 ` Paolo Bonzini
2017-03-23  9:05   ` Stefan Hajnoczi
2017-03-24  0:29     ` Xu, Anthony
2017-03-24 15:29       ` Stefan Hajnoczi

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.