Skip to content

Commit ff9b45c

Browse files
committed
kbuild: modpost: read modules.order instead of $(MODVERDIR)/*.mod
Towards the goal of removing MODVERDIR, read out modules.order to get the list of modules to be processed. This is simpler than parsing *.mod files in $(MODVERDIR). For external modules, $(KBUILD_EXTMOD)/modules.order should be read. I removed the single target %.ko from the top Makefile. To make sure modpost works correctly, vmlinux and the other modules must be built. You cannot build a particular .ko file alone. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
1 parent c35c87d commit ff9b45c

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1772,8 +1772,6 @@ build-dir = $(patsubst %/,%,$(dir $(build-target)))
17721772
$(Q)$(MAKE) $(build)=$(build-dir) $(build-target)
17731773
%.symtypes: prepare FORCE
17741774
$(Q)$(MAKE) $(build)=$(build-dir) $(build-target)
1775-
%.ko: %.o
1776-
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
17771775

17781776
# Modules
17791777
PHONY += /

scripts/Makefile.modpost

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
# b) A <module>.o file which is the .o files above linked together
99
# c) A <module>.mod file in $(MODVERDIR)/, listing the name of the
1010
# the preliminary <module>.o file, plus all .o files
11+
# d) modules.order, which lists all the modules
1112

1213
# Stage 2 is handled by this file and does the following
13-
# 1) Find all modules from the files listed in $(MODVERDIR)/
14+
# 1) Find all modules listed in modules.order
1415
# 2) modpost is then used to
1516
# 3) create one <module>.mod.c file pr. module
1617
# 4) create one Module.symvers file with CRC for all exported symbols
@@ -60,10 +61,12 @@ include scripts/Makefile.lib
6061
kernelsymfile := $(objtree)/Module.symvers
6162
modulesymfile := $(firstword $(KBUILD_EXTMOD))/Module.symvers
6263

63-
# Step 1), find all modules listed in $(MODVERDIR)/
64-
MODLISTCMD := find $(MODVERDIR) -name '*.mod' | xargs -r grep -h '\.ko$$' | sort -u
65-
__modules := $(shell $(MODLISTCMD))
66-
modules := $(patsubst %.o,%.ko, $(wildcard $(__modules:.ko=.o)))
64+
modorder := $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/)modules.order
65+
66+
# Step 1), find all modules listed in modules.order
67+
ifdef CONFIG_MODULES
68+
modules := $(sort $(shell cat $(modorder)))
69+
endif
6770

6871
# Stop after building .o files if NOFINAL is set. Makes compile tests quicker
6972
_modpost: $(if $(KBUILD_MODPOST_NOFINAL), $(modules:.ko:.o),$(modules))
@@ -84,7 +87,7 @@ MODPOST_OPT=$(subst -i,-n,$(filter -i,$(MAKEFLAGS)))
8487

8588
# We can go over command line length here, so be careful.
8689
quiet_cmd_modpost = MODPOST $(words $(filter-out vmlinux FORCE, $^)) modules
87-
cmd_modpost = $(MODLISTCMD) | sed 's/\.ko$$/.o/' | $(modpost) $(MODPOST_OPT) -s -T -
90+
cmd_modpost = sed 's/ko$$/o/' $(modorder) | $(modpost) $(MODPOST_OPT) -s -T -
8891

8992
PHONY += __modpost
9093
__modpost: $(modules:.ko=.o) FORCE

0 commit comments

Comments
 (0)