Commit e4ccd604 authored by Kai Germaschewski's avatar Kai Germaschewski

kbuild: Don't build final .ko yet when descending with CONFIG_MODVERSIONING

With CONFIG_MODVERSIONING, we need to record the versions of the unresolved
symbols in the final <module>.ko, which we only know after we finished
the descending build. So we only build <module>.o in that case.
  
Also, keep track of the modules we built, the post-processing step needs
a list of all modules. Keeping track is done by touching
.tmp_versions/path/to/module.ko
parent caa9e0e0
...@@ -260,6 +260,20 @@ ifndef CONFIG_FRAME_POINTER ...@@ -260,6 +260,20 @@ ifndef CONFIG_FRAME_POINTER
CFLAGS += -fomit-frame-pointer CFLAGS += -fomit-frame-pointer
endif endif
# When we're building modules with modversions, we need to consider
# the built-in objects during the descend as well, in order to
# make sure the checksums are uptodate before we use them.
ifdef CONFIG_MODVERSIONING
ifeq ($(KBUILD_MODULES),1)
ifneq ($(KBUILD_BUILTIN),1)
KBUILD_BUILTIN := 1
endif
endif
endif
export MODVERDIR := .tmp_versions
# #
# INSTALL_PATH specifies where to place the updated kernel and system map # INSTALL_PATH specifies where to place the updated kernel and system map
# images. Uncomment if you want to place them anywhere other than root. # images. Uncomment if you want to place them anywhere other than root.
...@@ -388,6 +402,16 @@ $(SUBDIRS): prepare ...@@ -388,6 +402,16 @@ $(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_MODVERSIONING
ifdef KBUILD_MODULES
ifeq ($(origin SUBDIRS),file)
$(Q)rm -rf $(MODVERDIR)
else
@echo '*** Warning: Overriding SUBDIRS on the command line can cause'
@echo '*** inconsistencies with module symbol versions'
endif
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)'
# We need to build init/vermagic.o before descending since all modules # We need to build init/vermagic.o before descending since all modules
......
...@@ -45,8 +45,15 @@ O_TARGET := $(obj)/built-in.o ...@@ -45,8 +45,15 @@ O_TARGET := $(obj)/built-in.o
endif endif
endif endif
ifdef CONFIG_MODVERSIONING
modules := $(obj-m)
touch-module = @mkdir -p $(MODVERDIR)/$(@D); touch $(MODVERDIR)/$(@:.o=.ko)
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),$(obj-m:.o=.ko)) \ $(if $(KBUILD_MODULES),$(modules)) \
$(subdir-ym) $(build-targets) $(subdir-ym) $(build-targets)
@: @:
...@@ -152,6 +159,15 @@ else ...@@ -152,6 +159,15 @@ 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
# to mark them in $(MODVERDIR)
ifdef CONFIG_MODVERSIONING
$(single-used-m): %.o: %.c FORCE
$(touch-module)
$(call if_changed_rule,vcc_o_c)
endif
quiet_cmd_cc_lst_c = MKLST $@ quiet_cmd_cc_lst_c = MKLST $@
cmd_cc_lst_c = $(CC) $(c_flags) -g -c -o $*.o $< && \ cmd_cc_lst_c = $(CC) $(c_flags) -g -c -o $*.o $< && \
$(CONFIG_SHELL) $(srctree)/scripts/makelst $*.o \ $(CONFIG_SHELL) $(srctree)/scripts/makelst $*.o \
...@@ -242,6 +258,11 @@ targets += $(multi-used-y) $(multi-used-m) ...@@ -242,6 +258,11 @@ targets += $(multi-used-y) $(multi-used-m)
# #
# Rule to link modules ( .o -> .ko ) # Rule to link modules ( .o -> .ko )
# #
# With CONFIG_MODVERSIONING, generation of the final .ko is handled
# by scripts/Makefile.modver
ifndef CONFIG_MODVERSIONING
quiet_cmd_link_module = LD [M] $@ quiet_cmd_link_module = LD [M] $@
cmd_link_module = $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LDFLAGS_MODULE) -o $@ $< init/vermagic.o cmd_link_module = $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LDFLAGS_MODULE) -o $@ $< init/vermagic.o
...@@ -255,6 +276,8 @@ $(single-used-m:.o=.ko) $(multi-used-m:.o=.ko): %.ko: %.o init/vermagic.o FORCE ...@@ -255,6 +276,8 @@ $(single-used-m:.o=.ko) $(multi-used-m:.o=.ko): %.ko: %.o init/vermagic.o FORCE
targets += $(single-used-m:.o=.ko) $(multi-used-m:.o=.ko) 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
......
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