Skip to content

Commit ea4054a

Browse files
committed
modpost: handle huge numbers of modules.
strace shows: 72102 execve("/bin/sh", ["/bin/sh", "-c", "echo ' scripts/mod/modpost -m -a -o /cc/wfg/sound-compiletest/Module.symvers -s'; scripts/ mod/modpost -m -a -o /cc/wfg/sound-compiletest/Module.symvers -s vmlinux arch/x86/crypto/ablk_helper.o arch/x86/crypto/aes-i586.o arch /x86/crypto/aesni-intel.o arch/x86/crypto/crc32-pclmul.o ... drivers/ata/sata_promise.o "...], [/* 119 vars */] <unfinished ...> 71827 wait4(-1, <unfinished ...> 72102 <... execve resumed> ) = -1 E2BIG (Argument list too long) So we re-run the shell command which produces the list and feed it into modpost -T -. Reported-by: Fengguang Wu <fengguang.wu@intel.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
1 parent 712f9b4 commit ea4054a

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

‎scripts/Makefile.modpost‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ kernelsymfile := $(objtree)/Module.symvers
6060
modulesymfile := $(firstword $(KBUILD_EXTMOD))/Module.symvers
6161

6262
# Step 1), find all modules listed in $(MODVERDIR)/
63-
__modules := $(sort $(shell grep -h '\.ko$$' /dev/null $(wildcard $(MODVERDIR)/*.mod)))
63+
MODLISTCMD := find $(MODVERDIR) -name '*.mod' | xargs -r grep -h '\.ko$$' | sort -u
64+
__modules := $(shell $(MODLISTCMD))
6465
modules := $(patsubst %.o,%.ko, $(wildcard $(__modules:.ko=.o)))
6566

6667
# Stop after building .o files if NOFINAL is set. Makes compile tests quicker
@@ -78,12 +79,13 @@ modpost = scripts/mod/modpost \
7879
$(if $(CONFIG_DEBUG_SECTION_MISMATCH),,-S) \
7980
$(if $(KBUILD_EXTMOD)$(KBUILD_MODPOST_WARN),-w)
8081

82+
# We can go over command line length here, so be careful.
8183
quiet_cmd_modpost = MODPOST $(words $(filter-out vmlinux FORCE, $^)) modules
82-
cmd_modpost = $(modpost) -s
84+
cmd_modpost = $(MODLISTCMD) | sed 's/\.ko$$/.o/' | $(modpost) -s -T -
8385

8486
PHONY += __modpost
8587
__modpost: $(modules:.ko=.o) FORCE
86-
$(call cmd,modpost) $(wildcard vmlinux) $(filter-out FORCE,$^)
88+
$(call cmd,modpost) $(wildcard vmlinux)
8789

8890
quiet_cmd_kernel-mod = MODPOST $@
8991
cmd_kernel-mod = $(modpost) $@

0 commit comments

Comments
 (0)