History

kbuild: split out *.mod out of {single,multi}-used-m rules

Currently, *.mod is created as a side-effect of obj-m. Split out *.mod as a dedicated build rule, which allows to unify the %.c -> %.o rule, and remove the single-used-m rule. This also makes the incremental build of allmodconfig faster because it saves $(NM) invocation when there is no change in the module.

Masahiro Yamada committed 7 years ago

Commit 9f69a491 parent 30527ce1 file · +13 −9Browse files

Showing the changes to scripts (1 of 1 file). Show all

Unified · Split

scripts/Makefile.build+13−9
@@ -67,8 +67,10 @@ ifeq ($(CONFIG_MODULES)$(need-modorder),y1) · 66 unmodified lines
67modorder-target := $(obj)/modules.order67modorder-target := $(obj)/modules.order
68endif68endif
69 69
70mod-targets := $(patsubst %.o, %.mod, $(obj-m))
71
70__build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(extra-y)) \72__build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(extra-y)) \
71 $(if $(KBUILD_MODULES),$(obj-m) $(modorder-target)) \73 $(if $(KBUILD_MODULES),$(obj-m) $(mod-targets) $(modorder-target)) \
72 $(subdir-ym) $(always)74 $(subdir-ym) $(always)
73 @:75 @:
74 76
@@ -261,7 +263,7 @@ endef · 186 unmodified lines
261 263
262# List module undefined symbols (or empty line if not enabled)264# List module undefined symbols (or empty line if not enabled)
263ifdef CONFIG_TRIM_UNUSED_KSYMS265ifdef CONFIG_TRIM_UNUSED_KSYMS
264cmd_undef_syms = $(NM) $@ | sed -n 's/^ *U //p' | xargs echo266cmd_undef_syms = $(NM) $< | sed -n 's/^ *U //p' | xargs echo
265else267else
266cmd_undef_syms = echo268cmd_undef_syms = echo
267endif269endif
@@ -271,11 +273,15 @@ $(obj)/%.o: $(src)/%.c $(recordmcount_source) $(objtool_dep) FORCE · 3 unmodified lines
271 $(call cmd,force_checksrc)273 $(call cmd,force_checksrc)
272 $(call if_changed_rule,cc_o_c)274 $(call if_changed_rule,cc_o_c)
273 275
274$(single-used-m): $(obj)/%.o: $(src)/%.c $(recordmcount_source) $(objtool_dep) FORCE276cmd_mod = { \
275 $(call cmd,force_checksrc)277 echo $(if $($*-objs)$($*-y)$($*-m), $(addprefix $(obj)/, $($*-objs) $($*-y) $($*-m)), $(@:.mod=.o)); \
276 $(call if_changed_rule,cc_o_c)278 $(cmd_undef_syms); \
277 @{ echo $@; \279 } > $@
278 $(cmd_undef_syms); } > $(patsubst %.o,%.mod,$@)280
281$(obj)/%.mod: $(obj)/%.o FORCE
282 $(call if_changed,mod)
283
284targets += $(mod-targets)
279 285
280quiet_cmd_cc_lst_c = MKLST $@286quiet_cmd_cc_lst_c = MKLST $@
281 cmd_cc_lst_c = $(CC) $(c_flags) -g -c -o $*.o $< && \287 cmd_cc_lst_c = $(CC) $(c_flags) -g -c -o $*.o $< && \
@@ -456,8 +462,6 @@ quiet_cmd_link_multi-m = LD [M] $@ · 174 unmodified lines
456 462
457$(multi-used-m): FORCE463$(multi-used-m): FORCE
458 $(call if_changed,link_multi-m)464 $(call if_changed,link_multi-m)
459 @{ echo $(filter %.o,$^); \
460 $(cmd_undef_syms); } > $(patsubst %.o,%.mod,$@)
461$(call multi_depend, $(multi-used-m), .o, -objs -y -m)465$(call multi_depend, $(multi-used-m), .o, -objs -y -m)
462 466
463targets += $(multi-used-m)467targets += $(multi-used-m)