Commit 0e7d983b authored by Kai Germaschewski's avatar Kai Germaschewski

kbuild: Always postprocess modules

Currently, we are doing the final module link (.ko) at different places
(Makefile.build vs Makefile.modver) depending on CONFIG_MODVERSIONS.
Apart from being confusing, that also means we have this code path
duplicated, and the modversions path most likely gets little testing.
    
It's actually cleaner to just do the final link from Makefile.modver always,
performance-wise it's not a noticable difference, since we don't descend
in that step, but just use the list of modules generated during the build.
    
This step is also preliminary for doing additional postprocessing, e.g.
generating module alias information from PCI / USB device tables.
parent 15f1049d
......@@ -405,16 +405,14 @@ $(SUBDIRS): prepare
.PHONY: prepare
prepare: include/linux/version.h include/asm include/config/MARKER
ifdef CONFIG_MODVERSIONS
ifdef KBUILD_MODULES
ifeq ($(origin SUBDIRS),file)
$(Q)rm -rf $(MODVERDIR)
$(Q)mkdir $(MODVERDIR)
else
@echo '*** Warning: Overriding SUBDIRS on the command line can cause'
@echo '*** inconsistencies with module symbol versions'
endif
@echo '*** inconsistencies'
endif
$(Q)mkdir -p $(MODVERDIR)
endif
@echo ' Starting the build. KBUILD_BUILTIN=$(KBUILD_BUILTIN) KBUILD_MODULES=$(KBUILD_MODULES)'
......@@ -518,17 +516,11 @@ all: modules
# Build modules
.PHONY: modules __modversions
modules: $(SUBDIRS) __modversions
ifdef CONFIG_MODVERSIONS
__modversions: vmlinux $(SUBDIRS)
@echo ' Recording module symbol versions.';
.PHONY: modules
modules: $(SUBDIRS) $(if $(CONFIG_MODVERSIONS),vmlinux)
@echo ' Building modules, stage 2.';
$(Q)$(MAKE) -rR -f scripts/Makefile.modver
endif
# Install modules
.PHONY: modules_install
......
......@@ -49,15 +49,12 @@ O_TARGET := $(obj)/built-in.o
endif
endif
ifdef CONFIG_MODVERSIONS
modules := $(obj-m)
touch-module = @echo $(@:.o=.ko) > .tmp_versions/$(@F:.o=.mod)
else
modules := $(obj-m:.o=.ko)
endif
# We keep a list of all modules in $(MODVERDIR)
touch-module = @echo $(@:.o=.ko) > $(MODVERDIR)/$(@F:.o=.mod)
__build: $(if $(KBUILD_BUILTIN),$(O_TARGET) $(L_TARGET) $(EXTRA_TARGETS)) \
$(if $(KBUILD_MODULES),$(modules)) \
$(if $(KBUILD_MODULES),$(obj-m)) \
$(subdir-ym) $(build-targets)
@:
......@@ -155,6 +152,8 @@ cmd_cc_i_c = $(CPP) $(c_flags) -o $@ $<
quiet_cmd_cc_o_c = CC $(quiet_modtag) $@
cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
# Built-in and composite module parts
%.o: %.c FORCE
ifdef CONFIG_MODVERSIONS
$(call if_changed_rule,vcc_o_c)
......@@ -162,13 +161,14 @@ else
$(call if_changed_dep,cc_o_c)
endif
# For modversioning, we need to special case single-part modules
# to mark them in $(MODVERDIR)
# Single-part modules are special since we need to mark them in $(MODVERDIR)
ifdef CONFIG_MODVERSIONS
$(single-used-m): %.o: %.c FORCE
$(touch-module)
ifdef CONFIG_MODVERSIONS
$(call if_changed_rule,vcc_o_c)
else
$(call if_changed_dep,cc_o_c)
endif
quiet_cmd_cc_lst_c = MKLST $@
......@@ -267,29 +267,6 @@ $(multi-used-m) : %.o: $(multi-objs-m) FORCE
targets += $(multi-used-y) $(multi-used-m)
#
# Rule to link modules ( .o -> .ko )
#
# With CONFIG_MODVERSIONS, generation of the final .ko is handled
# by scripts/Makefile.modver
ifndef CONFIG_MODVERSIONS
quiet_cmd_link_module = LD [M] $@
cmd_link_module = $(LD) $(ld_flags) $(LDFLAGS_MODULE) -o $@ $< init/vermagic.o
# Don't rebuilt vermagic.o unless we actually are in the init/ dir
ifneq ($(obj),init)
init/vermagic.o: ;
endif
$(single-used-m:.o=.ko) $(multi-used-m:.o=.ko): %.ko: %.o init/vermagic.o FORCE
$(call if_changed,link_module)
targets += $(single-used-m:.o=.ko) $(multi-used-m:.o=.ko)
endif
# Compile programs on the host
# ===========================================================================
# host-progs := bin2hex
......
......@@ -28,7 +28,7 @@ quiet_cmd_ld_ko_o = LD [M] $@
init/vermagic.o: ;
$(modules): %.ko :%.o %.ver.o init/vermagic.o FORCE
$(modules): %.ko :%.o $(if $(CONFIG_MODVERSIONS),%.ver.o) init/vermagic.o FORCE
$(call if_changed,ld_ko_o)
targets += $(modules)
......
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