qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] Thoughts around dtrace linking...


From: Lee Essen
Subject: Re: [Qemu-devel] Thoughts around dtrace linking...
Date: Fri, 23 Mar 2012 14:11:28 +0000

On 23 Mar 2012, at 08:08, Stefan Hajnoczi wrote:

> On Thu, Mar 22, 2012 at 05:00:53PM +0000, Lee Essen wrote:
>> On 22/03/2012 16:28, Stefan Hajnoczi wrote:
>>> On Wed, Mar 21, 2012 at 1:01 PM, Andreas Färber<address@hidden>  wrote:
>>>> Hi,
>>>> 
>>>> Am 21.03.2012 11:45, schrieb Lee Essen:
>>>>> I've been trying to find a sensible way to solve the Solaris/Illumos
>>>>> dtrace requirement to pass all the objs to the dtrace command so that
>>>>> the resultant object file contains all the symbols needed to properly
>>>>> link the relevant binary.
>>>>> 
> 
> If you're able to try out the dependency-based approach that would be a
> good starting point.  You may hit a point where it turns out to be too
> ugly or complicated - in that case, please post your progress and maybe
> someone can help find a way to structure it.  I'm not a make guru but I
> can try to give feedback on your patches.
> 
> Stefan
> 

Ok, here's an attempt … it works for me, but I'm not sure how it would work on 
a different dtrace platform so it will probably need some different guarding … 
but it shows what it will look like.

Lee.


diff --git a/Makefile b/Makefile
index 1bc3cb0..b300364 100644
--- a/Makefile
+++ b/Makefile
@@ -157,9 +157,28 @@ tools-obj-y = $(oslib-obj-y) $(trace-obj-y) qemu-tool.o 
qemu-timer.o \
        qemu-timer-common.o main-loop.o notify.o iohandler.o cutils.o async.o
 tools-obj-$(CONFIG_POSIX) += compatfd.o
 
-qemu-img$(EXESUF): qemu-img.o $(tools-obj-y) $(block-obj-y)
-qemu-nbd$(EXESUF): qemu-nbd.o $(tools-obj-y) $(block-obj-y)
-qemu-io$(EXESUF): qemu-io.o cmd.o $(tools-obj-y) $(block-obj-y)
+qemu-img-trace-objs=qemu-img.o $(tools-obj-y) $(block-obj-y)
+qemu-nbd-trace-objs=qemu-nbd.o $(tools-obj-y) $(block-obj-y)
+qemu-io-trace-objs=qemu-io.o cmd.o $(tools-obj-y) $(block-obj-y)
+qemu-img-all-objs=$(qemu-img-trace-objs)
+qemu-nbd-all-objs=$(qemu-nbd-trace-objs)
+qemu-io-all-objs=$(qemu-io-trace-objs)
+ifdef CONFIG_TRACE_DTRACE
+qemu-img-all-objs+=qemu-img.dtrace.o
+qemu-nbd-all-objs+=qemu-nbd.dtrace.o
+qemu-io-trace-objs+=qemu-img.dtrace.o
+endif
+
+qemu-img.dtrace.o: trace-dtrace.dtrace $(qemu-img-trace-objs)
+       $(call DTRACE,$@,trace-dtrace.dtrace,$(qemu-img-trace-objs))
+qemu-nbd.dtrace.o: trace-dtrace.dtrace $(qemu-nbd-trace-objs)
+       $(call DTRACE,$@,trace-dtrace.dtrace,$(qemu-nbd-trace-objs))
+qemu-io.dtrace.o: trace-dtrace.dtrace $(qemu-io-trace-objs)
+       $(call DTRACE,$@,trace-dtrace.dtrace,$(qemu-io-trace-objs))
+
+qemu-img$(EXESUF): $(qemu-img-all-objs)
+qemu-nbd$(EXESUF): $(qemu-nbd-all-objs)
+qemu-io$(EXESUF): $(qemu-io-all-objs)
 
 qemu-bridge-helper$(EXESUF): qemu-bridge-helper.o
 qemu-bridge-helper.o: $(GENERATED_HEADERS)
@@ -205,7 +224,17 @@ QGALIB_GEN=$(addprefix $(qapi-dir)/, qga-qapi-types.h 
qga-qapi-visit.h qga-qmp-c
 $(QGALIB_OBJ): $(QGALIB_GEN) $(GENERATED_HEADERS)
 $(qga-obj-y) qemu-ga.o: $(QGALIB_GEN) $(GENERATED_HEADERS)
 
-qemu-ga$(EXESUF): qemu-ga.o $(qga-obj-y) $(tools-obj-y) $(qapi-obj-y) 
$(qobject-obj-y) $(version-obj-y) $(QGALIB_OBJ)
+qemu-ga-trace-objs=qemu-ga.o $(qga-obj-y) $(tools-obj-y) $(qapi-obj-y) 
$(qobject-obj-y) $(version-obj-y) $(QGALIB_OBJ)
+qemu-ga-all-objs=$(qemu-ga-trace-objs)
+ifdef CONFIG_TRACE_DTRACE
+qemu-ga-all-objs+=qemu-ga.dtrace.o
+endif
+
+qemu-ga.dtrace.o: trace-dtrace.dtrace $(qemu-ga-trace-objs)
+       $(call DTRACE,$@,trace-dtrace.dtrace,$(qemu-ga-trace-objs))
+
+qemu-ga$(EXESUF): $(qemu-ga-all-objs)
+
 
 QEMULIBS=libhw32 libhw64 libuser libdis libdis-user
 
diff --git a/Makefile.target b/Makefile.target
index 63cf769..ed0d824 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -441,7 +441,17 @@ $(QEMU_PROGW): $(obj-y) $(obj-$(TARGET_BASE_ARCH)-y)
 $(QEMU_PROG): $(QEMU_PROGW)
        $(call quiet-command,$(OBJCOPY) --subsystem console $(QEMU_PROGW) 
$(QEMU_PROG),"  GEN   $(TARGET_DIR)$(QEMU_PROG)")
 else
-$(QEMU_PROG): $(obj-y) $(obj-$(TARGET_BASE_ARCH)-y)
+
+target-trace-objs=$(obj-y) $(obj-$(TARGET_BASE_ARCH)-y)
+target-all-objs=$(target-trace-objs)
+ifdef CONFIG_TRACE_DTRACE
+target-all-objs+=$(QEMU_PROG).dtrace.o
+endif
+
+$(QEMU_PROG).dtrace.o: ../trace-dtrace.dtrace $(target-trace-objs)
+       $(call DTRACE,$@,../trace-dtrace.dtrace,$(target-trace-objs))
+
+$(QEMU_PROG): $(target-all-objs)
        $(call LINK,$^)
 endif
 
diff --git a/rules.mak b/rules.mak
index 04a9198..31ad59c 100644
--- a/rules.mak
+++ b/rules.mak
@@ -33,6 +33,8 @@ endif
 
 LINK = $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ 
$(sort $(1)) $(LIBS),"  LINK  $(TARGET_DIR)$@")
 
+DTRACE = $(call quiet-command,dtrace $(CONFIG_DTRACE_FLAGS) -o $(1) -G -s $(2) 
$(3), "  GEN   $(TARGET_DIR)$(1)")
+
 %$(EXESUF): %.o
        $(call LINK,$^)
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]