Commit 67b95633 authored by Kai Germaschewski's avatar Kai Germaschewski

kbuild: modversions improvements

If an object was changed to not export symbols anymore, the
corresponding stale .ver file would have been left lying around
and been picked up when generating modversions.h. 

The obvious solution to remove include/linux/modules/* at the
beginning of "make dep" is not really good, since that means
that .ver files would be regenerated unconditionally, thus causing
a lot of possibly unnecessary rebuilds.

So, instead, we build a temporary shadow tree of all export-objs
(as empty files) during the recursive "make fastdep" phase, and use 
that to generate modversions.h.

Ensure that we touch include/linux/modversions.h if any of the
.ver files changes, that's our marker to rebuild all modversions
affected files.
parent 9d0ac54b
...@@ -245,15 +245,14 @@ $(sort $(vmlinux-objs)): $(SUBDIRS) ; ...@@ -245,15 +245,14 @@ $(sort $(vmlinux-objs)): $(SUBDIRS) ;
# Handle descending into subdirectories listed in $(SUBDIRS) # Handle descending into subdirectories listed in $(SUBDIRS)
.PHONY: $(SUBDIRS) .PHONY: $(SUBDIRS)
$(SUBDIRS): prepare $(SUBDIRS): .hdepend prepare include/config/MARKER
@$(MAKE) -C $@ @$(MAKE) -C $@
# Things we need done before we even start the actual build. # Things we need done before we descend to build or make
# The dependency on .hdepend will in turn take care of # module versions are listed in "prepare"
# include/asm, include/linux/version etc.
.PHONY: prepare .PHONY: prepare
prepare: .hdepend include/config/MARKER prepare: include/linux/version.h include/asm
# Single targets # Single targets
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
...@@ -326,39 +325,29 @@ scripts: ...@@ -326,39 +325,29 @@ scripts:
depend dep: .hdepend depend dep: .hdepend
ifdef CONFIG_MODVERSIONS # .hdepend is our (misnomed) marker for whether we've run
# generated module versions and made archdep
# Before descending for the actual build, we need module
# versions done. - Still using the old, illogical name
# .hdepend
# .hdepend only indicates if we have generated module
# version checksums before now. For now, if they've
# been generated once, no rechecking will be done unless
# explicitly asked for using "make dep".
.hdepend: scripts/fixdep include/linux/version.h include/asm \ .hdepend: $(if $(filter dep depend,$(MAKECMDGOALS)),FORCE)
$(if $(filter dep depend,$(MAKECMDGOALS)),FORCE) @$(MAKE) archdep include/linux/modversions.h
touch $@ @touch $@
@$(MAKE) $(patsubst %,_sfdep_%,$(SUBDIRS))
@$(MAKE) include/linux/modversions.h
@$(MAKE) archdep
$(patsubst %,_sfdep_%,$(SUBDIRS)): FORCE ifdef CONFIG_MODVERSIONS
@$(MAKE) -C $(patsubst _sfdep_%, %, $@) fastdep
# Update modversions.h, but only if it would change. # Update modversions.h, but only if it would change.
include/linux/modversions.h: FORCE include/linux/modversions.h: scripts/fixdep prepare FORCE
@(echo "#ifndef _LINUX_MODVERSIONS_H";\ @rm -rf .tmp_export-objs
echo "#define _LINUX_MODVERSIONS_H"; \ @$(MAKE) $(patsubst %,_sfdep_%,$(SUBDIRS))
echo "#include <linux/modsetver.h>"; \ @( echo "#ifndef _LINUX_MODVERSIONS_H";\
cd $(TOPDIR)/include/linux; \ echo "#define _LINUX_MODVERSIONS_H"; \
for f in `find modules -name \*.ver`; do \ echo "#include <linux/modsetver.h>"; \
echo "#include <linux/$${f}>"; \ for f in `cd .tmp_export-objs; find modules -name \*.ver -print`; do \
done; \ echo "#include <linux/$${f}>"; \
echo "#endif"; \ done; \
echo "#endif"; \
) > $@.tmp ) > $@.tmp
@rm -rf .tmp_export-objs
@if [ -r $@ ] && cmp -s $@ $@.tmp; then \ @if [ -r $@ ] && cmp -s $@ $@.tmp; then \
echo $@ was not updated; \ echo $@ was not updated; \
rm -f $@.tmp; \ rm -f $@.tmp; \
...@@ -367,12 +356,14 @@ include/linux/modversions.h: FORCE ...@@ -367,12 +356,14 @@ include/linux/modversions.h: FORCE
mv -f $@.tmp $@; \ mv -f $@.tmp $@; \
fi fi
$(patsubst %,_sfdep_%,$(SUBDIRS)): FORCE
@$(MAKE) -C $(patsubst _sfdep_%, %, $@) fastdep
else # !CONFIG_MODVERSIONS else # !CONFIG_MODVERSIONS
.hdepend: include/linux/version.h include/asm \ .PHONY: include/linux/modversions.h
$(if $(filter dep depend,$(MAKECMDGOALS)),FORCE)
touch $@ include/linux/modversions.h:
@$(MAKE) archdep
endif # CONFIG_MODVERSIONS endif # CONFIG_MODVERSIONS
......
...@@ -315,11 +315,17 @@ $(MODVERDIR)/%.ver: %.c FORCE ...@@ -315,11 +315,17 @@ $(MODVERDIR)/%.ver: %.c FORCE
@if [ -r $@ ] && cmp -s $@ $@.tmp; then \ @if [ -r $@ ] && cmp -s $@ $@.tmp; then \
rm -f $@.tmp; \ rm -f $@.tmp; \
else \ else \
touch $(TOPDIR)/include/linux/modversions.h; \
mv -f $@.tmp $@; \ mv -f $@.tmp $@; \
fi fi
# updates .ver files but not modversions.h # updates .ver files but not modversions.h
fastdep: $(addprefix $(MODVERDIR)/,$(export-objs:.o=.ver)) fastdep: $(addprefix $(MODVERDIR)/,$(export-objs:.o=.ver))
ifneq ($(export-objs),)
@mkdir -p $(TOPDIR)/.tmp_export-objs/modules/$(RELDIR)
@touch $(addprefix $(TOPDIR)/.tmp_export-objs/modules/$(RELDIR)/,$(export-objs:.o=.ver))
endif
endif # export-objs endif # export-objs
......
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