Commit 436b2ac6 authored by Masahiro Yamada's avatar Masahiro Yamada

modpost: invoke modpost only when input files are updated

Currently, the second pass of modpost is always invoked when you run
'make' or 'make modules' even if none of modules is changed.

Use if_changed to invoke it only when it is necessary.
Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
parent 269a535c
...@@ -90,7 +90,7 @@ endif ...@@ -90,7 +90,7 @@ endif
# modpost options for modules (both in-kernel and external) # modpost options for modules (both in-kernel and external)
MODPOST += \ MODPOST += \
$(addprefix -i ,$(input-symdump)) \ $(addprefix -i ,$(wildcard $(input-symdump))) \
$(if $(CONFIG_MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS)$(KBUILD_NSDEPS),-N) $(if $(CONFIG_MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS)$(KBUILD_NSDEPS),-N)
# 'make -i -k' ignores compile errors, and builds as many modules as possible. # 'make -i -k' ignores compile errors, and builds as many modules as possible.
...@@ -98,13 +98,18 @@ ifneq ($(findstring i,$(filter-out --%,$(MAKEFLAGS))),) ...@@ -98,13 +98,18 @@ ifneq ($(findstring i,$(filter-out --%,$(MAKEFLAGS))),)
MODPOST += -n MODPOST += -n
endif endif
$(input-symdump):
@:
# Read out modules.order to pass in modpost. # Read out modules.order to pass in modpost.
# Otherwise, allmodconfig would fail with "Argument list too long". # Otherwise, allmodconfig would fail with "Argument list too long".
quiet_cmd_modpost = MODPOST $@ quiet_cmd_modpost = MODPOST $@
cmd_modpost = sed 's/ko$$/o/' $(MODORDER) | $(MODPOST) -T - cmd_modpost = sed 's/ko$$/o/' $< | $(MODPOST) -T -
$(output-symdump): FORCE $(output-symdump): $(MODORDER) $(input-symdump) FORCE
$(call cmd,modpost) $(call if_changed,modpost)
targets += $(output-symdump)
__modpost: $(output-symdump) __modpost: $(output-symdump)
ifneq ($(KBUILD_MODPOST_NOFINAL),1) ifneq ($(KBUILD_MODPOST_NOFINAL),1)
...@@ -114,6 +119,13 @@ endif ...@@ -114,6 +119,13 @@ endif
PHONY += FORCE PHONY += FORCE
FORCE: FORCE:
existing-targets := $(wildcard $(sort $(targets)))
-include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
PHONY += FORCE
FORCE:
endif endif
.PHONY: $(PHONY) .PHONY: $(PHONY)
...@@ -2375,6 +2375,25 @@ static void add_srcversion(struct buffer *b, struct module *mod) ...@@ -2375,6 +2375,25 @@ static void add_srcversion(struct buffer *b, struct module *mod)
} }
} }
static void write_buf(struct buffer *b, const char *fname)
{
FILE *file;
file = fopen(fname, "w");
if (!file) {
perror(fname);
exit(1);
}
if (fwrite(b->p, 1, b->pos, file) != b->pos) {
perror(fname);
exit(1);
}
if (fclose(file) != 0) {
perror(fname);
exit(1);
}
}
static void write_if_changed(struct buffer *b, const char *fname) static void write_if_changed(struct buffer *b, const char *fname)
{ {
char *tmp; char *tmp;
...@@ -2407,16 +2426,7 @@ static void write_if_changed(struct buffer *b, const char *fname) ...@@ -2407,16 +2426,7 @@ static void write_if_changed(struct buffer *b, const char *fname)
close_write: close_write:
fclose(file); fclose(file);
write: write:
file = fopen(fname, "w"); write_buf(b, fname);
if (!file) {
perror(fname);
exit(1);
}
if (fwrite(b->p, 1, b->pos, file) != b->pos) {
perror(fname);
exit(1);
}
fclose(file);
} }
/* parse Module.symvers file. line format: /* parse Module.symvers file. line format:
...@@ -2508,7 +2518,7 @@ static void write_dump(const char *fname) ...@@ -2508,7 +2518,7 @@ static void write_dump(const char *fname)
symbol = symbol->next; symbol = symbol->next;
} }
} }
write_if_changed(&buf, fname); write_buf(&buf, fname);
free(buf.p); free(buf.p);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment