Skip to content

Commit

Permalink
kbuild: de-duplicate fixdep usage
Browse files Browse the repository at this point in the history
The generation and postprocessing of automatic dependency rules is
duplicated in rule_cc_o_c, rule_as_o_S and if_changed_dep. Since
this is not a trivial one-liner action, it is now abstracted under
cmd_and_fixdep to simplify things and make future changes in this area
easier.

In the rule_cc_o_c and rule_as_o_S cases that means the order of some
commands has been altered, namely fixdep and related file manipulations
are executed earlier, but they didn't depend on those commands that now
execute later.

Signed-off-by: Nicolas Pitre <[email protected]>
  • Loading branch information
Nicolas Pitre committed Mar 29, 2016
1 parent d8329e3 commit e4aca45
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
5 changes: 4 additions & 1 deletion scripts/Kbuild.include
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,13 @@ if_changed = $(if $(strip $(any-prereq) $(arg-check)), \
# Execute the command and also postprocess generated .d dependencies file.
if_changed_dep = $(if $(strip $(any-prereq) $(arg-check) ), \
@set -e; \
$(cmd_and_fixdep), @:)

cmd_and_fixdep = \
$(echo-cmd) $(cmd_$(1)); \
scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).tmp;\
rm -f $(depfile); \
mv -f $(dot-target).tmp $(dot-target).cmd, @:)
mv -f $(dot-target).tmp $(dot-target).cmd;

# Usage: $(call if_changed_rule,foo)
# Will check if $(cmd_foo) or any of the prerequisites changed,
Expand Down
19 changes: 5 additions & 14 deletions scripts/Makefile.build
Original file line number Diff line number Diff line change
Expand Up @@ -266,24 +266,15 @@ endif # CONFIG_STACK_VALIDATION

define rule_cc_o_c
$(call echo-cmd,checksrc) $(cmd_checksrc) \
$(call echo-cmd,cc_o_c) $(cmd_cc_o_c); \
$(call cmd_and_fixdep,cc_o_c) \
$(cmd_modversions) \
$(cmd_objtool) \
$(call echo-cmd,record_mcount) \
$(cmd_record_mcount) \
scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,cc_o_c)' > \
$(dot-target).tmp; \
rm -f $(depfile); \
mv -f $(dot-target).tmp $(dot-target).cmd
$(cmd_objtool) \
$(call echo-cmd,record_mcount) $(cmd_record_mcount)
endef

define rule_as_o_S
$(call echo-cmd,as_o_S) $(cmd_as_o_S); \
$(cmd_objtool) \
scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,as_o_S)' > \
$(dot-target).tmp; \
rm -f $(depfile); \
mv -f $(dot-target).tmp $(dot-target).cmd
$(call cmd_and_fixdep,as_o_S) \
$(cmd_objtool)
endef

# List module undefined symbols (or empty line if not enabled)
Expand Down

0 comments on commit e4aca45

Please sign in to comment.