Commit d84e208a authored by Kai Germaschewski's avatar Kai Germaschewski

kbuild: Generate modversions only for selected objects

Up to now, we generated module versions for all objects which
were listed in $(export-objs).

This had one advantage: A changed .config will not affect which
.ver files are built, thus saving recompiles.

However, it is fundamentally broken. To build .ver files, we preprocess
the exporting sources - and the result can obviously depend on
the current .config. Even worse, some files generate errors when
preprocessed with the wrong .config - it doesn't matter a lot that
drivers/sbus/* will generate errors on x86, since it won't be used anyway,
but e.g. kernel/suspend.c cannot be preprocessed unless 
CONFIG_SOFTWARE_SUSPEND is set. - Up to now, we just silently ignore
these errors.

Actually, the whole point behind CONFIG_MODVERSIONS is to make sure
we don't insert modules into a kernel which was configured differently,
and as such the generation of symbols can only work when .config is
known.

So we now only generate symbols for objects which will actually be
compiled - which means less work, and enforce the kernel to be configured
before "make dep".
parent badaa98e
......@@ -243,14 +243,14 @@ $(sort $(vmlinux-objs)): $(SUBDIRS) ;
# Handle descending into subdirectories listed in $(SUBDIRS)
.PHONY: $(SUBDIRS)
$(SUBDIRS): .hdepend prepare include/config/MARKER
$(SUBDIRS): .hdepend prepare
@$(MAKE) -C $@
# Things we need done before we descend to build or make
# module versions are listed in "prepare"
.PHONY: prepare
prepare: include/linux/version.h include/asm
prepare: include/linux/version.h include/asm include/config/MARKER
# Single targets
# ---------------------------------------------------------------------------
......
......@@ -48,12 +48,9 @@ subdir- += $(__subdir-)
obj-y := $(patsubst %/, %/built-in.o, $(obj-y))
obj-m := $(filter-out %/, $(obj-m))
# If a dir is selected in $(subdir-y) and also mentioned in $(mod-subdirs),
# add it to $(subdir-m)
# Subdirectories we need to descend into
both-m := $(filter $(mod-subdirs), $(subdir-y))
subdir-ym := $(sort $(subdir-y) $(subdir-m))
subdir-ymn := $(sort $(subdir-ym) $(subdir-n) $(subdir-))
# export.o is never a composite object, since $(export-objs) has a
# fixed meaning (== objects which EXPORT_SYMBOL())
......@@ -85,6 +82,8 @@ subdir-obj-y := $(foreach o,$(obj-y),$(if $(filter-out $(o),$(notdir $(o))),$(o)
real-objs-y := $(foreach m, $(filter-out $(subdir-obj-y), $(obj-y)), $(if $($(m:.o=-objs)),$($(m:.o=-objs)),$(m))) $(EXTRA_TARGETS)
real-objs-m := $(foreach m, $(obj-m), $(if $($(m:.o=-objs)),$($(m:.o=-objs)),$(m)))
# Only build module versions for files which are selected to be built
export-objs := $(filter $(export-objs),$(real-objs-y) $(real-objs-m))
# We're called for one of three purposes:
# o fastdep: build module version files (.ver) for $(export-objs) in
......@@ -102,7 +101,18 @@ ifeq ($(MAKECMDGOALS),fastdep)
# Module versions
# ===========================================================================
ifneq "$(strip $(export-objs))" ""
ifeq ($(strip $(export-objs)),)
# If we don't export any symbols in this dir, just descend
# ---------------------------------------------------------------------------
fastdep: sub_dirs
@echo -n
else
# This sets version suffixes on exported symbols
# ---------------------------------------------------------------------------
MODVERDIR := $(TOPDIR)/include/linux/modules/$(RELDIR)
......@@ -136,24 +146,9 @@ $(MODVERDIR)/%.ver: %.c FORCE
targets := $(addprefix $(MODVERDIR)/,$(export-objs:.o=.ver))
fastdep: $(targets)
ifneq ($(export-objs),)
fastdep: $(targets) sub_dirs
@mkdir -p $(TOPDIR)/.tmp_export-objs/modules/$(RELDIR)
@touch $(addprefix $(TOPDIR)/.tmp_export-objs/modules/$(RELDIR)/,$(export-objs:.o=.ver))
endif
# Descending when making module versions
# ---------------------------------------------------------------------------
fastdep-list := $(addprefix _sfdep_,$(subdir-ymn))
.PHONY: fastdep $(fastdep-list)
fastdep: $(fastdep-list)
$(fastdep-list):
@$(MAKE) -C $(patsubst _sfdep_%,%,$@) fastdep
endif # export-objs
......@@ -164,11 +159,9 @@ ifeq ($(MAKECMDGOALS),modules_install)
# Installing modules
# ==========================================================================
modinst-list := $(addprefix _modinst_,$(subdir-ym))
.PHONY: modules_install _modinst_ $(modinst-list)
.PHONY: modules_install
modules_install: $(modinst-list)
modules_install: sub_dirs
ifneq ($(obj-m),)
@echo Installing modules in $(MODLIB)/kernel/$(RELDIR)
@mkdir -p $(MODLIB)/kernel/$(RELDIR)
......@@ -177,10 +170,6 @@ else
@echo -n
endif
$(modinst-list):
@$(MAKE) -C $(patsubst _modinst_%,%,$@) modules_install
else # ! modules_install
# ==========================================================================
......@@ -357,18 +346,6 @@ $(host-progs-multi): %: $(host-progs-multi-objs) FORCE
targets += $(host-progs-single) $(host-progs-multi-objs) $(host-progs-multi)
# Descending when building
# ---------------------------------------------------------------------------
subdir-list := $(addprefix _subdir_,$(subdir-ym))
.PHONY: sub_dirs $(subdir-list)
sub_dirs: $(subdir-list)
$(subdir-list):
@$(MAKE) -C $(patsubst _subdir_%,%,$@)
endif # ! modules_install
endif # ! fastdep
......@@ -376,6 +353,16 @@ endif # ! fastdep
# Generic stuff
# ===========================================================================
# Descending
# ---------------------------------------------------------------------------
.PHONY: sub_dirs $(subdir-ym)
sub_dirs: $(subdir-ym)
$(subdir-ym):
@$(MAKE) -C $@ $(MAKECMDGOALS)
# Add FORCE to the prequisites of a target to force it to be always rebuilt.
# ---------------------------------------------------------------------------
......
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