From patchwork Tue Jul 30 15:59:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 170079 Delivered-To: patch@linaro.org Received: by 2002:ac9:2daa:0:0:0:0:0 with SMTP id g42csp4847393oce; Tue, 30 Jul 2019 08:59:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqyEBl2miJu3Mw16WL8YwV8STYmmpkfokY0DczNuJ8aEWLU+omsfv4BQ8EbNchVwS+SfOmEz X-Received: by 2002:a62:ab18:: with SMTP id p24mr42739989pff.113.1564502365948; Tue, 30 Jul 2019 08:59:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564502365; cv=none; d=google.com; s=arc-20160816; b=Qmglz9ntoK/0eymeEZFsE8tPhR901ccL3Tyi87C+IeG+05fvxR64V+Dl7C2o1xpYaU LftFI50zgq1aNAoP18yYTvlC/o+FSh/KJjwv+rcfOUOijbmA3/zOryVPW9YVrOzSFQ7A 31XAoD5F/aCU1SrLL4FSRxuqNmeuK1h3KtOj9iTrFw7LT/Lp+sIKL4b2x/zYxxUKTsUL Jc1Ze1qoO9bwHxHfOQNMBFl9z5wyWRxbsr5H/T3HsdTILdRRPZUegyGqkyGmp2NZREca bJZw8SKePJ3szGguwFYD+KjoWri7hJeZDCmwSQEuhnqyH//d93EFckglYHdlwg+WttKY FT6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=r9RuO6e70udYzmxw92TTE0QdUowGbnfuU8zyqiBmS+c=; b=Cn/B0W52hFbtZXAkaQ1KqlPn6p4ZGLHwiuo9asl6ZoKrGo0TlbZlw7fVT0aBTbD9n4 6U5PoVkOmTxFnSCUfA3eQTxw7LMwZSFKzM3ybDiJ0EU4XKpktLfrEtN90OrWB43DbW1a vNHboG22/iDQIEmIVvle+mnxeVfuqZpZ/1WIst6l4631wHlw4BkpXd4szxtEDrQEJZKQ TZN2xQ+qdE5gCgggvLW/ubTP0xgUdNGSJ52FQbywGk8nndDogM4EtiGv+dswPKq4USYb hH0CTs6A16y0JfLMB37HwvCKwg1ajcyjxsD1ICh6+jZ5Yo1Bx4t9cRexuMPUwDxP6gSB xPCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=mXQDXhmD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k189si30355427pgd.408.2019.07.30.08.59.25; Tue, 30 Jul 2019 08:59:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=mXQDXhmD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732738AbfG3P7Y (ORCPT + 29 others); Tue, 30 Jul 2019 11:59:24 -0400 Received: from conuserg-11.nifty.com ([210.131.2.78]:60067 "EHLO conuserg-11.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729621AbfG3P7O (ORCPT ); Tue, 30 Jul 2019 11:59:14 -0400 Received: from grover.flets-west.jp (softbank126026094249.bbtec.net [126.26.94.249]) (authenticated) by conuserg-11.nifty.com with ESMTP id x6UFx3Rb014915; Wed, 31 Jul 2019 00:59:05 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com x6UFx3Rb014915 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1564502345; bh=r9RuO6e70udYzmxw92TTE0QdUowGbnfuU8zyqiBmS+c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mXQDXhmDrwJPFT4OqN0FKclTVqd6B/6tGUjdSFHdk+HgHOKJOFxDiz0XgBJS3kHg/ AGli8U/93qn4gwNUUwe4IgW4KZACVqHZ3CiKSWEpZG55eu4anoG8aQWvfEHyGKhMfs dc3U7qMPCkcAsnJ0mWwSHVCmOBz3y3hlILRfS0srqs0cTVqXYkuo85NRx2HobOhPhF pIswhEf3XHqhOzHbhh4Jk5zqZqk8Bi+VEhiXyJkeIEO8CiG6PH4nXdD/4410DneP2q 3eh0JHKGsSq6utUWVzxqh7VjUCb4p2SDpyAiUyIGoB14KbAZJAsFFaWBAU65RZ4Sai jq4Sfpbv1467g== X-Nifty-SrcIP: [126.26.94.249] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada , Michal Marek Subject: [PATCH 4/4] kbuild: modpost: do not parse unnecessary rules for vmlinux modpost Date: Wed, 31 Jul 2019 00:59:02 +0900 Message-Id: <20190730155902.5557-4-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190730155902.5557-1-yamada.masahiro@socionext.com> References: <20190730155902.5557-1-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Fixes: ff9b45c55b26 ("kbuild: modpost: read modules.order instead of $(MODVERDIR)/*.mod") Signed-off-by: Masahiro Yamada --- scripts/Makefile.modpost | 76 ++++++++++++++++++++++------------------ scripts/link-vmlinux.sh | 2 +- 2 files changed, 42 insertions(+), 36 deletions(-) -- 2.17.1 diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index fdab32d6f552..92ed02d7cd5e 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -38,12 +38,39 @@ # symbols in the final module linking stage # KBUILD_MODPOST_NOFINAL can be set to skip the final link of modules. # This is solely useful to speed up test compiles -PHONY := _modpost -_modpost: __modpost + +PHONY := __modpost +__modpost: include include/config/auto.conf include scripts/Kbuild.include +kernelsymfile := $(objtree)/Module.symvers +modulesymfile := $(firstword $(KBUILD_EXTMOD))/Module.symvers + +MODPOST = scripts/mod/modpost \ + $(if $(CONFIG_MODVERSIONS),-m) \ + $(if $(CONFIG_MODULE_SRCVERSION_ALL),-a) \ + $(if $(KBUILD_EXTMOD),-i,-o) $(kernelsymfile) \ + $(if $(KBUILD_EXTMOD),-I $(modulesymfile)) \ + $(if $(KBUILD_EXTMOD),$(addprefix -e ,$(KBUILD_EXTRA_SYMBOLS))) \ + $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \ + $(if $(CONFIG_SECTION_MISMATCH_WARN_ONLY),,-E) \ + $(if $(KBUILD_MODPOST_WARN),-w) + +ifdef MODPOST_VMLINUX + +__modpost: vmlinux.o + +quiet_cmd_modpost = MODPOST $@ + cmd_modpost = $(MODPOST) $@ + +PHONY += vmlinux.o +vmlinux.o: + $(call cmd,modpost) + +else + # When building external modules load the Kbuild file to retrieve EXTRA_SYMBOLS info ifneq ($(KBUILD_EXTMOD),) @@ -58,50 +85,27 @@ endif include scripts/Makefile.lib -kernelsymfile := $(objtree)/Module.symvers -modulesymfile := $(firstword $(KBUILD_EXTMOD))/Module.symvers - modorder := $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/)modules.order -# Step 1), find all modules listed in modules.order -ifdef CONFIG_MODULES +# find all modules listed in modules.order modules := $(sort $(shell cat $(modorder))) -endif # Stop after building .o files if NOFINAL is set. Makes compile tests quicker -_modpost: $(if $(KBUILD_MODPOST_NOFINAL), $(modules:.ko:.o),$(modules)) - -# Step 2), invoke modpost -# Includes step 3,4 -modpost = scripts/mod/modpost \ - $(if $(CONFIG_MODVERSIONS),-m) \ - $(if $(CONFIG_MODULE_SRCVERSION_ALL),-a,) \ - $(if $(KBUILD_EXTMOD),-i,-o) $(kernelsymfile) \ - $(if $(KBUILD_EXTMOD),-I $(modulesymfile)) \ - $(if $(KBUILD_EXTMOD),$(addprefix -e ,$(KBUILD_EXTRA_SYMBOLS))) \ - $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \ - $(if $(CONFIG_SECTION_MISMATCH_WARN_ONLY),,-E) \ - $(if $(KBUILD_MODPOST_WARN),-w) - -MODPOST_OPT=$(subst -i,-n,$(filter -i,$(MAKEFLAGS))) +__modpost: $(if $(KBUILD_MODPOST_NOFINAL), $(modules:.ko:.o),$(modules)) + @: + +MODPOST += $(subst -i,-n,$(filter -i,$(MAKEFLAGS))) -s -T - $(wildcard vmlinux) # We can go over command line length here, so be careful. quiet_cmd_modpost = MODPOST $(words $(modules)) modules - cmd_modpost = sed 's/ko$$/o/' $(modorder) | $(modpost) $(MODPOST_OPT) -s -T - + cmd_modpost = sed 's/ko$$/o/' $(modorder) | $(MODPOST) -PHONY += __modpost -__modpost: - $(call cmd,modpost) $(wildcard vmlinux) - -quiet_cmd_kernel-mod = MODPOST $@ - cmd_kernel-mod = $(modpost) $@ - -vmlinux.o: FORCE - $(call cmd,kernel-mod) +PHONY += modules-modpost +modules-modpost: + $(call cmd,modpost) # Declare generated files as targets for modpost -$(modules:.ko=.mod.c): __modpost ; - +$(modules:.ko=.mod.c): modules-modpost # Step 5), compile all *.mod.c files @@ -149,4 +153,6 @@ existing-targets := $(wildcard $(sort $(targets))) -include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd) +endif + .PHONY: $(PHONY) diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh index a7124f895b24..915775eb2921 100755 --- a/scripts/link-vmlinux.sh +++ b/scripts/link-vmlinux.sh @@ -210,7 +210,7 @@ info LD vmlinux.o modpost_link vmlinux.o # modpost vmlinux.o to check for section mismatches -${MAKE} -f "${srctree}/scripts/Makefile.modpost" vmlinux.o +${MAKE} -f "${srctree}/scripts/Makefile.modpost" MODPOST_VMLINUX=1 info MODINFO modules.builtin.modinfo ${OBJCOPY} -j .modinfo -O binary vmlinux.o modules.builtin.modinfo