Received: from eggs.gnu.org ([208.118.235.92]:43775) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TingX-0003hX-9z for qemu-devel@nongnu.org; Wed, 12 Dec 2012 09:53:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TingQ-0004bH-Dz for qemu-devel@nongnu.org; Wed, 12 Dec 2012 09:53:21 -0500 Received: from roura.ac.upc.edu ([147.83.33.10]:36786 helo=roura.ac.upc.es) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TingP-0004b4-Up for qemu-devel@nongnu.org; Wed, 12 Dec 2012 09:53:14 -0500 From: =?utf-8?Q?Llu=C3=ADs_Vilanova?= References: <20121211214412.32738.80113.stgit@fimbulvetr.bsc.es> <50C843A9.9020608@redhat.com> Date: Wed, 12 Dec 2012 15:53:11 +0100 In-Reply-To: <50C843A9.9020608@redhat.com> (Paolo Bonzini's message of "Wed, 12 Dec 2012 09:43:21 +0100") Message-ID: <87a9tj8gq0.fsf@fimbulvetr.bsc.es> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] build: Use separate makefile for "trace/" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel@nongnu.org Paolo Bonzini writes: > Il 11/12/2012 22:44, Llu=C3=ADs Vilanova ha scritto: >> Signed-off-by: Llu=C3=ADs Vilanova >> --- >> .gitignore | 6 +-- >> Makefile | 8 ++- >> Makefile.objs | 64 +--------------------------- >> scripts/tracetool/backend/dtrace.py | 2 - >> trace/Makefile.objs | 81 +++++++++++++++++++++++++++++= ++++++ >> 5 files changed, 92 insertions(+), 69 deletions(-) >> create mode 100644 trace/Makefile.objs >>=20 >> diff --git a/.gitignore b/.gitignore >> index bd6ba1c..b67a37e 100644 >> --- a/.gitignore >> +++ b/.gitignore >> @@ -3,9 +3,9 @@ config-all-devices.* >> config-host.* >> config-target.* >> trace.h >> -trace.c >> -trace-dtrace.h >> -trace-dtrace.dtrace >> +trace/generated.c >> +trace/generated-dtrace.h >> +trace/generated-dtrace.dtrace >> *-timestamp >> *-softmmu >> *-darwin-user >> diff --git a/Makefile b/Makefile >> index e9d6848..9dbcca3 100644 >> --- a/Makefile >> +++ b/Makefile >> @@ -33,10 +33,10 @@ endif >>=20 >> GENERATED_HEADERS =3D config-host.h trace.h qemu-options.def >> ifeq ($(TRACE_BACKEND),dtrace) >> -GENERATED_HEADERS +=3D trace-dtrace.h >> +GENERATED_HEADERS +=3D trace/generated-dtrace.h >> endif >> GENERATED_HEADERS +=3D qmp-commands.h qapi-types.h qapi-visit.h >> -GENERATED_SOURCES +=3D qmp-marshal.c qapi-types.c qapi-visit.c trace.c >> +GENERATED_SOURCES +=3D qmp-marshal.c qapi-types.c qapi-visit.c trace/ge= nerated.c >>=20 >> # Don't try to regenerate Makefile or configure >> # We don't generate any of them >> @@ -252,9 +252,9 @@ clean: >> rm -f *.a *.lo $(TOOLS) $(HELPERS-y) qemu-ga TAGS cscope.* *.pod *~ */*~ >> rm -Rf .libs >> rm -f qemu-img-cmds.h >> - rm -f trace-dtrace.dtrace trace-dtrace.dtrace-timestamp >> @# May not be present in GENERATED_HEADERS >> - rm -f trace-dtrace.h trace-dtrace.h-timestamp >> + rm -f trace/generated-dtrace.dtrace trace/generated-dtrace.dtrace-time= stamp >> + rm -f trace/generated-dtrace.h trace/generated-dtrace.h-timestamp >> rm -f $(foreach f,$(GENERATED_HEADERS),$(f) $(f)-timestamp) >> rm -f $(foreach f,$(GENERATED_SOURCES),$(f) $(f)-timestamp) >> rm -rf qapi-generated >> diff --git a/Makefile.objs b/Makefile.objs >> index 3c7abca..24832a2 100644 >> --- a/Makefile.objs >> +++ b/Makefile.objs >> @@ -147,66 +147,7 @@ libdis-$(CONFIG_LM32_DIS) +=3D lm32-dis.o >> ###################################################################### >> # trace >>=20 >> -ifeq ($(TRACE_BACKEND),dtrace) >> -TRACE_H_EXTRA_DEPS=3Dtrace-dtrace.h >> -endif >> -trace.h: trace.h-timestamp $(TRACE_H_EXTRA_DEPS) >> -trace.h-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/config-host.mak >> - $(call quiet-command,$(TRACETOOL) \ >> - --format=3Dh \ >> - --backend=3D$(TRACE_BACKEND) \ >> - < $< > $@," GEN trace.h") >> - @cmp -s $@ trace.h || cp $@ trace.h >> - >> -trace.c: trace.c-timestamp >> -trace.c-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/config-host.mak >> - $(call quiet-command,$(TRACETOOL) \ >> - --format=3Dc \ >> - --backend=3D$(TRACE_BACKEND) \ >> - < $< > $@," GEN trace.c") >> - @cmp -s $@ trace.c || cp $@ trace.c >> - >> -trace.o: trace.c $(GENERATED_HEADERS) >> - >> -trace-dtrace.h: trace-dtrace.dtrace >> - $(call quiet-command,dtrace -o $@ -h -s $<, " GEN trace-dtrace.h") >> - >> -# Normal practice is to name DTrace probe file with a '.d' extension >> -# but that gets picked up by QEMU's Makefile as an external dependency >> -# rule file. So we use '.dtrace' instead >> -trace-dtrace.dtrace: trace-dtrace.dtrace-timestamp >> -trace-dtrace.dtrace-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/co= nfig-host.mak >> - $(call quiet-command,$(TRACETOOL) \ >> - --format=3Dd \ >> - --backend=3D$(TRACE_BACKEND) \ >> - < $< > $@," GEN trace-dtrace.dtrace") >> - @cmp -s $@ trace-dtrace.dtrace || cp $@ trace-dtrace.dtrace >> - >> -trace-dtrace.o: trace-dtrace.dtrace $(GENERATED_HEADERS) >> - $(call quiet-command,dtrace -o $@ -G -s $<, " GEN trace-dtrace.o") >> - >> -ifeq ($(LIBTOOL),) >> -trace-dtrace.lo: trace-dtrace.dtrace >> - @echo "missing libtool. please install and rerun configure."; exit 1 >> -else >> -trace-dtrace.lo: trace-dtrace.dtrace >> - $(call quiet-command,$(LIBTOOL) --mode=3Dcompile --tag=3DCC dtrace -o = $@ -G -s $<, " lt GEN trace-dtrace.o") >> -endif >> - >> -trace/simple.o: trace/simple.c $(GENERATED_HEADERS) >> - >> -trace-obj-$(CONFIG_TRACE_DTRACE) +=3D trace-dtrace.o >> -ifneq ($(TRACE_BACKEND),dtrace) >> -trace-obj-y =3D trace.o >> -endif >> - >> -trace-obj-$(CONFIG_TRACE_DEFAULT) +=3D trace/default.o >> -trace-obj-$(CONFIG_TRACE_SIMPLE) +=3D trace/simple.o >> -trace-obj-$(CONFIG_TRACE_SIMPLE) +=3D qemu-timer-common.o >> -trace-obj-$(CONFIG_TRACE_STDERR) +=3D trace/stderr.o >> -trace-obj-y +=3D trace/control.o >> - >> -$(trace-obj-y): $(GENERATED_HEADERS) >> +trace-obj-y +=3D trace/ > Please just put it into oslib-obj-y. You mean line "trace-obj-y +=3D trace/"? >> ###################################################################### >> # smartcard >> @@ -250,5 +191,6 @@ nested-vars +=3D \ >> block-obj-y \ >> user-obj-y \ >> common-obj-y \ >> - extra-obj-y >> + extra-obj-y \ >> + trace-obj-y >> dummy :=3D $(call unnest-vars) >> diff --git a/scripts/tracetool/backend/dtrace.py b/scripts/tracetool/bac= kend/dtrace.py >> index 23c43e2..0cbc68a 100644 >> --- a/scripts/tracetool/backend/dtrace.py >> +++ b/scripts/tracetool/backend/dtrace.py >> @@ -37,7 +37,7 @@ def c(events): >>=20 >>=20 >> def h(events): >> - out('#include "trace-dtrace.h"', >> + out('#include "trace/generated-dtrace.h"', >> '') >>=20 >> for e in events: >> diff --git a/trace/Makefile.objs b/trace/Makefile.objs >> new file mode 100644 >> index 0000000..d7e8cdf >> --- /dev/null >> +++ b/trace/Makefile.objs >> @@ -0,0 +1,81 @@ >> +# -*- mode: makefile -*- >> + >> +trace/simple.o: trace/simple.c $(GENERATED_HEADERS) >> + >> +trace-obj-$(CONFIG_TRACE_DEFAULT) +=3D default.o >> +trace-obj-$(CONFIG_TRACE_SIMPLE) +=3D simple.o >> +trace-obj-$(CONFIG_TRACE_SIMPLE) +=3D ../qemu-timer-common.o > Is this line needed? (Actually, it is obviously unneeded if you use > oslib-obj-y). I am also worried that it causes duplicate symbols when > you link in both qemu-timer-common.o and trace/../qemu-timer-common.o. > The $(sort) invocation in the LINK macro of rules.mak will not treat > these two paths as duplicate. "trace-obj-y" is required by some binaries other than QEMU itself, as they = use routines that require the tracing infrastructure (e.g., qemu-img, which only includes "qemu-timer-common.o" as a dependency through "tools-obj-y"). I'm not sure how the subdir magic treats paths, but mapping all paths in fi= nal vars into their respective absolute path should simplify things. In any case, compiling with backends none, stderr, and stdout turns up no linking problems. >> +trace-obj-$(CONFIG_TRACE_STDERR) +=3D stderr.o >> +trace-obj-y +=3D control.o >> + >> + >> +###################################################################### >> +# Auto-generated tracing routines >> + >> +# NOTE: "trace.h" is kept in the top-level dir to shorten common includ= e path > Ok, I'll take care of moving it to trace/ later when I do the same for > all other includes. I'll send a new version generating "trace/generated.h" and having "trace.h"= just include it for now. >> +ifeq ($(TRACE_BACKEND),dtrace) >> +TRACE_H_EXTRA_DEPS=3Dtrace/generated-dtrace.h >> +endif >> +trace.h: trace.h-timestamp $(TRACE_H_EXTRA_DEPS) >> +trace.h-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/config-host.mak >> + $(call quiet-command,$(TRACETOOL) \ >> + --format=3Dh \ >> + --backend=3D$(TRACE_BACKEND) \ >> + < $< > $@," GEN trace.h") >> + @cmp -s $@ trace.h || cp $@ trace.h >> + >> + >> +trace/generated.c: trace/generated.c-timestamp > Please use $(obj)/generated.c, and similarly for everything else. Tried it, but "obj" is set to ".", although looking at "rules.mak" that sho= uld not be the case... Inserting "$(error obj=3D$(obj))" in "trace/Makefile.objs" shows "./trace",= but echoing "obj" in any of the rules shows ".". >> +trace/generated.c-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/conf= ig-host.mak >> + $(call quiet-command,$(TRACETOOL) \ >> + --format=3Dc \ >> + --backend=3D$(TRACE_BACKEND) \ >> + < $< > $@," GEN trace/generated.c") >> + @cmp -s $@ trace/generated.c || cp $@ trace/generated.c >> + >> +trace/generated.o: trace/generated.c trace.h >> + >> + >> +ifneq ($(TRACE_BACKEND),dtrace) >> +trace-obj-y +=3D generated.o >> +endif >> + >> + >> +###################################################################### >> +# Auto-generated DTrace code >> + >> +# Normal practice is to name DTrace probe file with a '.d' extension >> +# but that gets picked up by QEMU's Makefile as an external dependency >> +# rule file. So we use '.dtrace' instead >> +trace/generated-dtrace.dtrace: trace/generated-dtrace.dtrace-timestamp >> +trace/generated-dtrace.dtrace-timestamp: $(SRC_PATH)/trace-events $(BUI= LD_DIR)/config-host.mak >> + $(call quiet-command,$(TRACETOOL) \ >> + --format=3Dd \ >> + --backend=3D$(TRACE_BACKEND) \ >> + < $< > $@," GEN trace/generated-dtrace.dtrace") >> + @cmp -s $@ trace/generated-dtrace.dtrace || cp $@ trace/generated-dtra= ce.dtrace >> + >> + >> +trace/generated-dtrace.h: trace/generated-dtrace.dtrace >> + $(call quiet-command,dtrace -o $@ -h -s $<, " GEN trace/generated-d= trace.h") >> + >> +trace/generated-dtrace.o: trace/generated-dtrace.dtrace $(GENERATED_HEA= DERS) >> + $(call quiet-command,dtrace -o $@ -G -s $<, " GEN trace/generated-d= trace.o") >> + >> + >> +ifeq ($(LIBTOOL),) >> +trace/generated-dtrace.lo: trace/generated-dtrace.dtrace >> + @echo "missing libtool. please install and rerun configure."; exit 1 >> +else >> +trace/generated-dtrace.lo: trace/generated-dtrace.dtrace >> + $(call quiet-command,$(LIBTOOL) --mode=3Dcompile --tag=3DCC dtrace -o = $@ -G -s $<, " lt GEN trace/generated-dtrace.lo") >> +endif >> + >> + >> +trace-obj-$(CONFIG_TRACE_DTRACE) +=3D generated-dtrace.o >> + >> + >> +###################################################################### >> +# Keep at bottom >> + >> +$(trace-obj-y): $(GENERATED_HEADERS) > This does not do what you think, because trace-obj-y includes a relative > path. It can be simply > trace/%.o: $(GENERATED_HEADERS) > but it is actually unnecessary because of this in the toplevel: > # Add a dependency on the generated files, so that they are always > # rebuilt before other object files > ifneq ($(filter-out %clean,$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail)) > Makefile: $(GENERATED_HEADERS) > endif Nice, I wasn't aware of this addition. Then I suppose none of the rules nee= d to depend on GENERATED_HEADERS. BTW, can I extend the GENERATED_HEADERS variable contents right from "trace/Makefile.objs" even though it's not explicitly included from the top-level makefile? I'm sure this has already been previously discussed to the point of extenua= tion, but what are the reasons for not using autotools? Thanks, Lluis --=20 "And it's much the same thing with knowledge, for whenever you learn something new, the whole world becomes that much richer." -- The Princess of Pure Reason, as told by Norton Juster in The Phantom Tollbooth