Message ID | 20200226113355.2532224-20-anthony.perard@citrix.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | xen: Build system improvements | expand |
On 26.02.2020 12:33, Anthony PERARD wrote: > Use $(dot-target) to have the target name prefix with a dot. > > Now, when the CC command has run, it is recorded in .*.cmd > file, then if_changed_rules will compare it on subsequent runs. > > Signed-off-by: Anthony PERARD <anthony.perard@citrix.com> Reviewed-by: Jan Beulich <jbeulich@suse.com> with one question: > --- a/xen/Rules.mk > +++ b/xen/Rules.mk > @@ -167,19 +167,27 @@ FORCE: > > SRCPATH := $(patsubst $(BASEDIR)/%,%,$(CURDIR)) > > -%.o: %.c Makefile > +quiet_cmd_cc_o_c = CC $@ > ifeq ($(CONFIG_ENFORCE_UNIQUE_SYMBOLS),y) > - $(CC) $(c_flags) -c $< -o $(@D)/.$(@F).tmp -MQ $@ > -ifeq ($(CONFIG_CC_IS_CLANG),y) > - $(OBJCOPY) --redefine-sym $<=$(SRCPATH)/$< $(@D)/.$(@F).tmp $@ > -else > - $(OBJCOPY) --redefine-sym $(<F)=$(SRCPATH)/$< $(@D)/.$(@F).tmp $@ > -endif > - rm -f $(@D)/.$(@F).tmp > + cmd_cc_o_c = $(CC) $(c_flags) -c $< -o $(dot-target).tmp -MQ $@ > + ifeq ($(CONFIG_CC_IS_CLANG),y) > + cmd_objcopy_fix_sym = $(OBJCOPY) --redefine-sym $<=$(SRCPATH)/$< $(dot-target).tmp $@ > + else > + cmd_objcopy_fix_sym = $(OBJCOPY) --redefine-sym $(<F)=$(SRCPATH)/$< $(dot-target).tmp $@ > + endif > + cmd_objcopy_fix_sym += && rm -f $(dot-target).tmp > else > - $(CC) $(c_flags) -c $< -o $@ > + cmd_cc_o_c = $(CC) $(c_flags) -c $< -o $@ > endif > > +define rule_cc_o_c > + $(call cmd_and_record,cc_o_c) > + $(call cmd,objcopy_fix_sym) The machinery is resilient to a command (here: cmd_objcopy_fix_sym) not being defined, and will neither produce any undue output nor else incur any unnecessary overhead? Jan
On Wed, Mar 04, 2020 at 05:09:19PM +0100, Jan Beulich wrote: > On 26.02.2020 12:33, Anthony PERARD wrote: > > +define rule_cc_o_c > > + $(call cmd_and_record,cc_o_c) > > + $(call cmd,objcopy_fix_sym) > > The machinery is resilient to a command (here: cmd_objcopy_fix_sym) > not being defined, and will neither produce any undue output nor > else incur any unnecessary overhead? Yes, it's fine when cmd_objcopy_fix_sym isn't defined, nothing gets printed on the console, and there is no error. As for unnecessary overhead, I don't know. The macro still expand to "@set -e;". But Linux uses that a lot (having undefined cmd_*), so I guess it's not too bad.
diff --git a/xen/Rules.mk b/xen/Rules.mk index cbf4feba0e0f..8c7dba9211d1 100644 --- a/xen/Rules.mk +++ b/xen/Rules.mk @@ -167,19 +167,27 @@ FORCE: SRCPATH := $(patsubst $(BASEDIR)/%,%,$(CURDIR)) -%.o: %.c Makefile +quiet_cmd_cc_o_c = CC $@ ifeq ($(CONFIG_ENFORCE_UNIQUE_SYMBOLS),y) - $(CC) $(c_flags) -c $< -o $(@D)/.$(@F).tmp -MQ $@ -ifeq ($(CONFIG_CC_IS_CLANG),y) - $(OBJCOPY) --redefine-sym $<=$(SRCPATH)/$< $(@D)/.$(@F).tmp $@ -else - $(OBJCOPY) --redefine-sym $(<F)=$(SRCPATH)/$< $(@D)/.$(@F).tmp $@ -endif - rm -f $(@D)/.$(@F).tmp + cmd_cc_o_c = $(CC) $(c_flags) -c $< -o $(dot-target).tmp -MQ $@ + ifeq ($(CONFIG_CC_IS_CLANG),y) + cmd_objcopy_fix_sym = $(OBJCOPY) --redefine-sym $<=$(SRCPATH)/$< $(dot-target).tmp $@ + else + cmd_objcopy_fix_sym = $(OBJCOPY) --redefine-sym $(<F)=$(SRCPATH)/$< $(dot-target).tmp $@ + endif + cmd_objcopy_fix_sym += && rm -f $(dot-target).tmp else - $(CC) $(c_flags) -c $< -o $@ + cmd_cc_o_c = $(CC) $(c_flags) -c $< -o $@ endif +define rule_cc_o_c + $(call cmd_and_record,cc_o_c) + $(call cmd,objcopy_fix_sym) +endef + +%.o: %.c FORCE + $(call if_changed_rule,cc_o_c) + quiet_cmd_cc_o_S = CC $@ cmd_cc_o_S = $(CC) $(a_flags) -c $< -o $@
Use $(dot-target) to have the target name prefix with a dot. Now, when the CC command has run, it is recorded in .*.cmd file, then if_changed_rules will compare it on subsequent runs. Signed-off-by: Anthony PERARD <anthony.perard@citrix.com> --- xen/Rules.mk | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-)