Message ID | 875ztlzdw8.fsf_-_@dusky.pond.sub.org |
---|---|
State | New |
Headers | show |
Series | Proper use of unnest-vars (was: [PATCH v5 00/18] qapi: add #if pre-processor conditions to generated code (part 3)) | expand |
On 15/02/19 08:53, Markus Armbruster wrote: > This time, $(obj-y) is very much not blank, and... > > @qapi/ final qapi-introspect.o qapi-types-target.o qapi-types.o qapi-visit-target.o qapi-visit.o qapi-events-target.o qapi-events.o qapi-commands-target.o qapi-commands.o > [Trailing make output elided] > > ... qapi/Makefile.obj-y *does* clobber it. Oww. > > How come this works anyway? It works because at this point obj-y is not used anymore, it is assigned to all-obj-y a couple lines before: all-obj-y := $(obj-y) As an aside, target-obj-y seems unnecessary to me. > Perhaps unnest-vars could be more hygienic. Macro hygiene and Make in the same sentence? (well, not sentence but still...). > But that's not my immediate > concern. All I want to know right now is whether I should refrain from > = and := in Makefile.objs. Paolo, Fam? No, there is no need for that. Really the answer is that we are kind of pushing Makefiles to the limit here. We do get good expressiveness, but at the cost of hiding things behind black magic. In the end I think it's a net benefit, but the cost does exist. Paolo
Paolo Bonzini <pbonzini@redhat.com> writes: > On 15/02/19 08:53, Markus Armbruster wrote: >> This time, $(obj-y) is very much not blank, and... >> >> @qapi/ final qapi-introspect.o qapi-types-target.o qapi-types.o qapi-visit-target.o qapi-visit.o qapi-events-target.o qapi-events.o qapi-commands-target.o qapi-commands.o >> [Trailing make output elided] >> >> ... qapi/Makefile.obj-y *does* clobber it. Oww. >> >> How come this works anyway? > > It works because at this point obj-y is not used anymore, it is assigned > to all-obj-y a couple lines before: > > all-obj-y := $(obj-y) Confirms my findings. > As an aside, target-obj-y seems unnecessary to me. I have no idea :) $ git-grep target-obj-y Makefile.objs:target-obj-y += trace/ Makefile.target:target-obj-y := Makefile.target:dummy := $(call unnest-vars,,target-obj-y) Makefile.target:target-obj-y-save := $(target-obj-y) Makefile.target:target-obj-y := $(target-obj-y-save) Makefile.target:all-obj-y += $(target-obj-y) trace/Makefile.objs:target-obj-y += generated-helpers.o trace/Makefile.objs:target-obj-y += control-target.o >> Perhaps unnest-vars could be more hygienic. > > Macro hygiene and Make in the same sentence? (well, not sentence but > still...). You're right. My "perhaps could" should be read like "Perhaps we could make pigs fly, if we apply enough force, say with a trebuchet". >> But that's not my immediate >> concern. All I want to know right now is whether I should refrain from >> = and := in Makefile.objs. Paolo, Fam? > > No, there is no need for that. Thanks! > Really the answer is that we are kind of pushing Makefiles to the limit > here. We do get good expressiveness, but at the cost of hiding things > behind black magic. In the end I think it's a net benefit, but the cost > does exist. Concur. It's actually not bad most of the time. Once in a great while, I need to do something more fancy, and then I'm prone to waste a few hours on (re-)learning how to work with the magic.
diff --git a/Makefile.target b/Makefile.target index d6ce549388..b2218011ef 100644 --- a/Makefile.target +++ b/Makefile.target @@ -167,7 +167,9 @@ GENERATED_FILES += hmp-commands.h hmp-commands-info.h endif # CONFIG_SOFTMMU +$(info @target/ before $(obj-y)) dummy := $(call unnest-vars,,obj-y) +$(info @target/ after $(obj-y)) all-obj-y := $(obj-y) target-obj-y := diff --git a/qapi/Makefile.objs b/qapi/Makefile.objs index 87e4df1660..1789811769 100644 --- a/qapi/Makefile.objs +++ b/qapi/Makefile.objs @@ -1,3 +1,4 @@ +$(info @qapi/ initial $(obj-y)) util-obj-y = qapi-visit-core.o qapi-dealloc-visitor.o qobject-input-visitor.o util-obj-y += qobject-output-visitor.o qmp-registry.o qmp-dispatch.o util-obj-y += string-input-visitor.o string-output-visitor.o @@ -29,3 +30,4 @@ obj-y += $(QAPI_TARGET_MODULES:%=qapi-events-%.o) obj-y += qapi-events.o obj-y += $(QAPI_TARGET_MODULES:%=qapi-commands-%.o) obj-y += qapi-commands.o +$(info @qapi/ final $(obj-y))