Il 24/01/2013 16:50, Stefan Hajnoczi ha scritto:
> Generated trace event code is written to trace/generated-tracers.c.  The
> 'dtrace' backend does not generate C code, instead the dtrace(1) utility
> takes a .dtrace file as input and produces a .o file as output.
> 
> Therefore, with 'dtrace' we have:
> generated-tracers.o <- generated-tracers.dtrace
> 
> Without 'dtrace' we have:
> generated-tracers.o <- generated-tracers.c
> 
> When QEMU is built with ./configure --enable-trace-backend=simple
> followed by ./configure --enable-trace-backend=dtrace, the
> generated-tracers.c file remains although the 'dtrace' backend does not
> use it.
> 
> Because the %.o: %.c target is defined before the %.o: %.dtrace target
> in rules.mak, we'll actually pull in the stale .c file instead of using
> the .dtrace file!  The resulting build is a mix of 'dtrace' and 'simple'
> trace backends - and it fails loudly.
> 
> Commit 0e848f482bce75f4d9cbac9f495fa45e51d08c9a (build: some
> simplifications for "trace/Makefile.objs") changed trace/Makefile.objs
> so that 'dtrace' and non-'dtrace' builds use generated-tracers.o.
> Previously we used generated-tracers-dtrace.o for 'dtrace' builds only
> and generated-tracers.o for non-'dtrace' builds only.
> 
> This patch is somewhat ugly.  It undoes the change from
> 0e848f482bce75f4d9cbac9f495fa45e51d08c9a so that the 'dtrace' and
> non-'dtrace' builds do not conflict with each other.
> 
> The result is that 'dtrace' builds no longer fail if stale
> generated-tracers.c files are present.
> 
> Signed-off-by: Stefan Hajnoczi <stefa...@redhat.com>
> ---
> Can someone think of a better way to fix this?

Doesn't really look ugly.  Thanks for fixing this.

Paolo

> Perhaps we've really outgrown in-tree builds and need to switch to a ./build/
> directory that can be blown away each time ./configure runs (fingers crossed
> you have ccache installed or the build may take some time).
> 
>  rules.mak           | 2 +-
>  trace/Makefile.objs | 5 +++--
>  2 files changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/rules.mak b/rules.mak
> index 6d82c0d..d8b0672 100644
> --- a/rules.mak
> +++ b/rules.mak
> @@ -29,7 +29,7 @@ else
>  LIBTOOL += $(if $(V),,--quiet)
>  %.lo: %.c
>       $(call quiet-command,$(LIBTOOL) --mode=compile --tag=CC $(CC) 
> $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  lt 
> CC $@")
> -%.lo: %.dtrace
> +%-dtrace.lo: %.dtrace
>       $(call quiet-command,$(LIBTOOL) --mode=compile --tag=CC dtrace -o $@ -G 
> -s $<, " lt GEN $(TARGET_DIR)$@")
>  
>  LINK = $(call quiet-command,\
> diff --git a/trace/Makefile.objs b/trace/Makefile.objs
> index 27fe26b..97e280d 100644
> --- a/trace/Makefile.objs
> +++ b/trace/Makefile.objs
> @@ -24,6 +24,7 @@ $(obj)/generated-tracers.c-timestamp: 
> $(SRC_PATH)/trace-events $(BUILD_DIR)/conf
>       @cmp -s $@ $(patsubst %-timestamp,%,$@) || cp $@ $(patsubst 
> %-timestamp,%,$@)
>  
>  $(obj)/generated-tracers.o: $(obj)/generated-tracers.c 
> $(obj)/generated-tracers.h
> +util-obj-y += generated-tracers.o
>  endif
>  
>  
> @@ -45,7 +46,8 @@ $(obj)/generated-tracers.dtrace-timestamp: 
> $(SRC_PATH)/trace-events $(BUILD_DIR)
>  $(obj)/generated-tracers-dtrace.h: $(obj)/generated-tracers.dtrace
>       $(call quiet-command,dtrace -o $@ -h -s $<, "  GEN   $@")
>  
> -$(obj)/generated-tracers.o: $(obj)/generated-tracers.dtrace
> +$(obj)/generated-tracers-dtrace.o: $(obj)/generated-tracers.dtrace
> +util-obj-y += generated-tracers-dtrace.o
>  endif
>  
>  ######################################################################
> @@ -55,4 +57,3 @@ util-obj-$(CONFIG_TRACE_DEFAULT) += default.o
>  util-obj-$(CONFIG_TRACE_SIMPLE) += simple.o
>  util-obj-$(CONFIG_TRACE_STDERR) += stderr.o
>  util-obj-y += control.o
> -util-obj-y += generated-tracers.o
> 


Reply via email to