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 ...@@ -405,16 +405,14 @@ $(SUBDIRS): prepare
.PHONY: prepare .PHONY: prepare
prepare: include/linux/version.h include/asm include/config/MARKER prepare: include/linux/version.h include/asm include/config/MARKER
ifdef CONFIG_MODVERSIONS
ifdef KBUILD_MODULES ifdef KBUILD_MODULES
ifeq ($(origin SUBDIRS),file) ifeq ($(origin SUBDIRS),file)
$(Q)rm -rf $(MODVERDIR) $(Q)rm -rf $(MODVERDIR)
$(Q)mkdir $(MODVERDIR)
else else
@echo '*** Warning: Overriding SUBDIRS on the command line can cause' @echo '*** Warning: Overriding SUBDIRS on the command line can cause'
@echo '*** inconsistencies with module symbol versions' @echo '*** inconsistencies'
endif
endif endif
$(Q)mkdir -p $(MODVERDIR)
endif endif
@echo ' Starting the build. KBUILD_BUILTIN=$(KBUILD_BUILTIN) KBUILD_MODULES=$(KBUILD_MODULES)' @echo ' Starting the build. KBUILD_BUILTIN=$(KBUILD_BUILTIN) KBUILD_MODULES=$(KBUILD_MODULES)'
...@@ -518,17 +516,11 @@ all: modules ...@@ -518,17 +516,11 @@ all: modules
# Build modules # Build modules
.PHONY: modules __modversions .PHONY: modules
modules: $(SUBDIRS) __modversions modules: $(SUBDIRS) $(if $(CONFIG_MODVERSIONS),vmlinux)
@echo ' Building modules, stage 2.';
ifdef CONFIG_MODVERSIONS
__modversions: vmlinux $(SUBDIRS)
@echo ' Recording module symbol versions.';
$(Q)$(MAKE) -rR -f scripts/Makefile.modver $(Q)$(MAKE) -rR -f scripts/Makefile.modver
endif
# Install modules # Install modules
.PHONY: modules_install .PHONY: modules_install
......
...@@ -49,15 +49,12 @@ O_TARGET := $(obj)/built-in.o ...@@ -49,15 +49,12 @@ O_TARGET := $(obj)/built-in.o
endif endif
endif endif
ifdef CONFIG_MODVERSIONS # We keep a list of all modules in $(MODVERDIR)
modules := $(obj-m)
touch-module = @echo $(@:.o=.ko) > .tmp_versions/$(@F:.o=.mod) touch-module = @echo $(@:.o=.ko) > $(MODVERDIR)/$(@F:.o=.mod)
else
modules := $(obj-m:.o=.ko)
endif
__build: $(if $(KBUILD_BUILTIN),$(O_TARGET) $(L_TARGET) $(EXTRA_TARGETS)) \ __build: $(if $(KBUILD_BUILTIN),$(O_TARGET) $(L_TARGET) $(EXTRA_TARGETS)) \
$(if $(KBUILD_MODULES),$(modules)) \ $(if $(KBUILD_MODULES),$(obj-m)) \
$(subdir-ym) $(build-targets) $(subdir-ym) $(build-targets)
@: @:
...@@ -155,6 +152,8 @@ cmd_cc_i_c = $(CPP) $(c_flags) -o $@ $< ...@@ -155,6 +152,8 @@ cmd_cc_i_c = $(CPP) $(c_flags) -o $@ $<
quiet_cmd_cc_o_c = CC $(quiet_modtag) $@ quiet_cmd_cc_o_c = CC $(quiet_modtag) $@
cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
# Built-in and composite module parts
%.o: %.c FORCE %.o: %.c FORCE
ifdef CONFIG_MODVERSIONS ifdef CONFIG_MODVERSIONS
$(call if_changed_rule,vcc_o_c) $(call if_changed_rule,vcc_o_c)
...@@ -162,13 +161,14 @@ else ...@@ -162,13 +161,14 @@ else
$(call if_changed_dep,cc_o_c) $(call if_changed_dep,cc_o_c)
endif endif
# For modversioning, we need to special case single-part modules # Single-part modules are special since we need to mark them in $(MODVERDIR)
# to mark them in $(MODVERDIR)
ifdef CONFIG_MODVERSIONS
$(single-used-m): %.o: %.c FORCE $(single-used-m): %.o: %.c FORCE
$(touch-module) $(touch-module)
ifdef CONFIG_MODVERSIONS
$(call if_changed_rule,vcc_o_c) $(call if_changed_rule,vcc_o_c)
else
$(call if_changed_dep,cc_o_c)
endif endif
quiet_cmd_cc_lst_c = MKLST $@ quiet_cmd_cc_lst_c = MKLST $@
...@@ -267,29 +267,6 @@ $(multi-used-m) : %.o: $(multi-objs-m) FORCE ...@@ -267,29 +267,6 @@ $(multi-used-m) : %.o: $(multi-objs-m) FORCE
targets += $(multi-used-y) $(multi-used-m) 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 # Compile programs on the host
# =========================================================================== # ===========================================================================
# host-progs := bin2hex # host-progs := bin2hex
......
...@@ -28,7 +28,7 @@ quiet_cmd_ld_ko_o = LD [M] $@ ...@@ -28,7 +28,7 @@ quiet_cmd_ld_ko_o = LD [M] $@
init/vermagic.o: ; 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) $(call if_changed,ld_ko_o)
targets += $(modules) 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