Since commit ff9b45c55b26 ("kbuild: modpost: read modules.order instead of $(MODVERDIR)/*.mod"), 'make vmlinux' emits a warning, like this: $ make defconfig vmlinux [ snip ] LD vmlinux.o cat: modules.order: No such file or directory MODPOST vmlinux.o MODINFO modules.builtin.modinfo KSYM .tmp_kallsyms1.o KSYM .tmp_kallsyms2.o LD vmlinux SORTEX vmlinux SYSMAP System.map When building only vmlinux, KBUILD_MODULES is not set. Hence, the modules.order is not generated. For the vmlinux modpost, it is not necessary at all. Separate scripts/Makefile.modpost for the vmlinux/modules stages. This works more efficiently because the vmlinux modpost does not need to include .*.cmd files.
Showing the changes to scripts (2 of 2 files). Show all
Unified · Split
| @@ -38,12 +38,39 @@ · 37 unmodified lines | ||
| 38 | 38 | # symbols in the final module linking stage |
| 39 | 39 | # KBUILD_MODPOST_NOFINAL can be set to skip the final link of modules. |
| 40 | 40 | # This is solely useful to speed up test compiles |
| 41 | −PHONY := _modpost | |
| 42 | −_modpost: __modpost | |
| 41 | + | |
| 42 | +PHONY := __modpost | |
| 43 | +__modpost: | |
| 43 | 44 | |
| 44 | 45 | include include/config/auto.conf |
| 45 | 46 | include scripts/Kbuild.include |
| 46 | 47 | |
| 48 | +kernelsymfile := $(objtree)/Module.symvers | |
| 49 | +modulesymfile := $(firstword $(KBUILD_EXTMOD))/Module.symvers | |
| 50 | + | |
| 51 | +MODPOST = scripts/mod/modpost \ | |
| 52 | + $(if $(CONFIG_MODVERSIONS),-m) \ | |
| 53 | + $(if $(CONFIG_MODULE_SRCVERSION_ALL),-a) \ | |
| 54 | + $(if $(KBUILD_EXTMOD),-i,-o) $(kernelsymfile) \ | |
| 55 | + $(if $(KBUILD_EXTMOD),-I $(modulesymfile)) \ | |
| 56 | + $(if $(KBUILD_EXTMOD),$(addprefix -e ,$(KBUILD_EXTRA_SYMBOLS))) \ | |
| 57 | + $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \ | |
| 58 | + $(if $(CONFIG_SECTION_MISMATCH_WARN_ONLY),,-E) \ | |
| 59 | + $(if $(KBUILD_MODPOST_WARN),-w) | |
| 60 | + | |
| 61 | +ifdef MODPOST_VMLINUX | |
| 62 | + | |
| 63 | +__modpost: vmlinux.o | |
| 64 | + | |
| 65 | +quiet_cmd_modpost = MODPOST $@ | |
| 66 | + cmd_modpost = $(MODPOST) $@ | |
| 67 | + | |
| 68 | +PHONY += vmlinux.o | |
| 69 | +vmlinux.o: | |
| 70 | + $(call cmd,modpost) | |
| 71 | + | |
| 72 | +else | |
| 73 | + | |
| 47 | 74 | # When building external modules load the Kbuild file to retrieve EXTRA_SYMBOLS info |
| 48 | 75 | ifneq ($(KBUILD_EXTMOD),) |
| 49 | 76 | |
| @@ -58,50 +85,27 @@ endif · 8 unmodified lines | ||
| 58 | 85 | |
| 59 | 86 | include scripts/Makefile.lib |
| 60 | 87 | |
| 61 | −kernelsymfile := $(objtree)/Module.symvers | |
| 62 | −modulesymfile := $(firstword $(KBUILD_EXTMOD))/Module.symvers | |
| 63 | − | |
| 64 | 88 | modorder := $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/)modules.order |
| 65 | 89 | |
| 66 | −# Step 1), find all modules listed in modules.order | |
| 67 | −ifdef CONFIG_MODULES | |
| 90 | +# find all modules listed in modules.order | |
| 68 | 91 | modules := $(sort $(shell cat $(modorder))) |
| 69 | −endif | |
| 70 | 92 | |
| 71 | 93 | # Stop after building .o files if NOFINAL is set. Makes compile tests quicker |
| 72 | −_modpost: $(if $(KBUILD_MODPOST_NOFINAL), $(modules:.ko:.o),$(modules)) | |
| 73 | − | |
| 74 | −# Step 2), invoke modpost | |
| 75 | −# Includes step 3,4 | |
| 76 | −modpost = scripts/mod/modpost \ | |
| 77 | − $(if $(CONFIG_MODVERSIONS),-m) \ | |
| 78 | − $(if $(CONFIG_MODULE_SRCVERSION_ALL),-a,) \ | |
| 79 | − $(if $(KBUILD_EXTMOD),-i,-o) $(kernelsymfile) \ | |
| 80 | − $(if $(KBUILD_EXTMOD),-I $(modulesymfile)) \ | |
| 81 | − $(if $(KBUILD_EXTMOD),$(addprefix -e ,$(KBUILD_EXTRA_SYMBOLS))) \ | |
| 82 | − $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \ | |
| 83 | − $(if $(CONFIG_SECTION_MISMATCH_WARN_ONLY),,-E) \ | |
| 84 | − $(if $(KBUILD_MODPOST_WARN),-w) | |
| 85 | − | |
| 86 | −MODPOST_OPT=$(subst -i,-n,$(filter -i,$(MAKEFLAGS))) | |
| 94 | +__modpost: $(if $(KBUILD_MODPOST_NOFINAL), $(modules:.ko:.o),$(modules)) | |
| 95 | + @: | |
| 96 | + | |
| 97 | +MODPOST += $(subst -i,-n,$(filter -i,$(MAKEFLAGS))) -s -T - $(wildcard vmlinux) | |
| 87 | 98 | |
| 88 | 99 | # We can go over command line length here, so be careful. |
| 89 | 100 | quiet_cmd_modpost = MODPOST $(words $(modules)) modules |
| 90 | − cmd_modpost = sed 's/ko$$/o/' $(modorder) | $(modpost) $(MODPOST_OPT) -s -T - | |
| 101 | + cmd_modpost = sed 's/ko$$/o/' $(modorder) | $(MODPOST) | |
| 91 | 102 | |
| 92 | −PHONY += __modpost | |
| 93 | −__modpost: | |
| 94 | − $(call cmd,modpost) $(wildcard vmlinux) | |
| 95 | − | |
| 96 | −quiet_cmd_kernel-mod = MODPOST $@ | |
| 97 | − cmd_kernel-mod = $(modpost) $@ | |
| 98 | − | |
| 99 | −vmlinux.o: FORCE | |
| 100 | − $(call cmd,kernel-mod) | |
| 103 | +PHONY += modules-modpost | |
| 104 | +modules-modpost: | |
| 105 | + $(call cmd,modpost) | |
| 101 | 106 | |
| 102 | 107 | # Declare generated files as targets for modpost |
| 103 | −$(modules:.ko=.mod.c): __modpost ; | |
| 104 | − | |
| 108 | +$(modules:.ko=.mod.c): modules-modpost | |
| 105 | 109 | |
| 106 | 110 | # Step 5), compile all *.mod.c files |
| 107 | 111 | |
| @@ -149,4 +153,6 @@ existing-targets := $(wildcard $(sort $(targets))) · 41 unmodified lines | ||
| 149 | 153 | |
| 150 | 154 | -include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd) |
| 151 | 155 | |
| 156 | +endif | |
| 157 | + | |
| 152 | 158 | .PHONY: $(PHONY) |
| @@ -210,7 +210,7 @@ info LD vmlinux.o · 209 unmodified lines | ||
| 210 | 210 | modpost_link vmlinux.o |
| 211 | 211 | |
| 212 | 212 | # modpost vmlinux.o to check for section mismatches |
| 213 | −${MAKE} -f "${srctree}/scripts/Makefile.modpost" vmlinux.o | |
| 213 | +${MAKE} -f "${srctree}/scripts/Makefile.modpost" MODPOST_VMLINUX=1 | |
| 214 | 214 | |
| 215 | 215 | info MODINFO modules.builtin.modinfo |
| 216 | 216 | ${OBJCOPY} -j .modinfo -O binary vmlinux.o modules.builtin.modinfo |