From patchwork Wed Mar 14 16:44:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 131663 Delivered-To: patch@linaro.org Received: by 10.80.210.197 with SMTP id q5csp395605edg; Wed, 14 Mar 2018 09:45:33 -0700 (PDT) X-Google-Smtp-Source: AG47ELs9Hm9lV/8n24KgXgGfWknowCA0eWM0nzrEGL1LSCP8tjMwuf99hogtLLcUlZ2rMIstK27S X-Received: by 10.101.98.17 with SMTP id d17mr4295930pgv.221.1521045933312; Wed, 14 Mar 2018 09:45:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521045933; cv=none; d=google.com; s=arc-20160816; b=VD8cNZw8ggCjp4vn8iznAFpSoZtLt1LuSwLPg1xgZ/hbLoEgLg2d+voPSEg3f5w7EI mKfLYnyKynsGd+973iWFpPIkMxcHuYqKYNHwVcqpaVv/3cdD/kWZt0lgmiQhC6fySYLt 5+A3I3Dw5EiOV2sxLappllQdH/xf3I8Iva6hvZaB7sLhx6QcvbpHt60sUqQ+4Qr8S9vF xFPtIyA9CpoDqhd4IehV7ICPIrmbx3ckw44jckpTFuMAcDsby0yl4EwBAA80ZG8P5bkN kFrGcfMOR00XEwJrpMjpueTncvBA5cWTMSlEum1KnLdhx7Z52mPsYvvu4CXqukN0SuX3 rrsw== 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 :arc-authentication-results; bh=uGo9GFfQJW1c2MIT/TgCFg5KX36rVzYNdYKZzcBa5os=; b=LG8QmDZj5CdVqjfZ8eQeLwXxEfqe3Z9utInWwYVzSAMIJcYlENFqyY+OmqI6JJXVUX iVYykqPhBQ0DRFKA7mH44mMfM/RiW1n274KkiBQD3KVAJa91FHDsqRuWCI2NIGSsmmlu kQjMS2dsKMiVR2OCe4rV7aBupt1UJibA5JqV1IZm/6WmexZ3XcHW1ueKr2gcrpdqqudM wF6wAg+iYY+XvlVRGyrj5Rgc5k9go3g6zDSg6Ihs4BRfUHc6ZHVS9x8ZU+w2vhyeoG7Y R95KDcYstpoitHW0ZcY++k5tnR3zCLm6XND2+pf40ziNe0cLhS1OMf0i6zZJOoM7+JxO z60w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=sHt2H3mu; 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 u23si2043271pgv.706.2018.03.14.09.45.32; Wed, 14 Mar 2018 09:45:33 -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=sHt2H3mu; 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 S1752405AbeCNQpS (ORCPT + 28 others); Wed, 14 Mar 2018 12:45:18 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:38080 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752150AbeCNQou (ORCPT ); Wed, 14 Mar 2018 12:44:50 -0400 Received: from grover.sesame (FL1-125-199-20-195.osk.mesh.ad.jp [125.199.20.195]) (authenticated) by conuserg-07.nifty.com with ESMTP id w2EGiSdW001049; Thu, 15 Mar 2018 01:44:33 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com w2EGiSdW001049 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1521045873; bh=uGo9GFfQJW1c2MIT/TgCFg5KX36rVzYNdYKZzcBa5os=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sHt2H3muOw4OZ0wBFnZfHcrhS2ziv9D1Y5typ4ehDW1ZjR2W9IaKSl8Ol8TU/l/k3 BXkYgWA2++KXrdKwY8RUQSwi1jBH4l5TiTvnHxErcThZqywaeHbPMAaNwckWsDo1L6 MqIJ9zZhLWmUIPqCf2+rlpUBSmnnf+6CBXHYqo5ePLfhOePsyoP8SiK+AnRbuRPPnK SnLwhZrIYdor24Ga6mBA8vk5Bl7UT/X8UDmTqWskBQjAp0B1LdFg4gu8SPpzUmsQ1y kUdzJWi8P+feuup+okm3xytHoIAYhvK2KiMSSrXCVsvGEvZ/ZNTsTjmZrbaSfR9IBN wZImyaTtWtEXw== X-Nifty-SrcIP: [125.199.20.195] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Nicolas Pitre , Jarod Wilson , Prarit Bhargava , Masahiro Yamada , Michal Marek , linux-kernel@vger.kernel.org Subject: [PATCH 7/7] kbuild: link vmlinux just once for CONFIG_TRIM_UNUSED_KSYMS Date: Thu, 15 Mar 2018 01:44:21 +0900 Message-Id: <1521045861-22418-8-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521045861-22418-1-git-send-email-yamada.masahiro@socionext.com> References: <1521045861-22418-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If CONFIG_TRIM_UNUSED_KSYMS is enabled and the kernel is built from a pristine state, the vmlinux is linked twice. [1] A user runs "make" [2] First build with empty autoksyms.h [3] adjust_autoksyms.sh updates autoksyms.h and recurses "make vmlinux" --------(begin sub-make)-------- [4] Second build with new autoksyms.h [5] link-vmlinux.sh is invoked because "vmlinux" is missing ---------(end sub-make)--------- [6] link-vmlinux.sh is invoked again despite "vmlinux" is up-to-date. The reason of [6] is probably because Make already decided to update "vmlinux" at the time of [2] because "vmlinux" was missing when Make generated the dependency list. link-vmlinus.sh is costly, so it is better to not run it when unneeded. Split CONFIG_TRIM_UNUSED_KSYMS handling to a dedicated target. The reason of commit 2441e78b1919 ("kbuild: better abstract vmlinux sequential prerequisites") was to cater to CONFIG_BUILD_DOCSRC, but it was later removed by commit 184892925118 ("samples: move blackfin gptimers-example from Documentation"). I also changed adjust_autoksyms.sh to simply exit with 1 or 0 to make it look straightforward. Signed-off-by: Masahiro Yamada --- Makefile | 28 ++++++++++++---------------- scripts/adjust_autoksyms.sh | 3 +-- 2 files changed, 13 insertions(+), 18 deletions(-) -- 2.7.4 diff --git a/Makefile b/Makefile index 1dab647..0a7bab6 100644 --- a/Makefile +++ b/Makefile @@ -987,21 +987,11 @@ export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) arch Doc vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_INIT) $(KBUILD_VMLINUX_MAIN) $(KBUILD_VMLINUX_LIBS) -# Include targets which we want to execute sequentially if the rest of the -# kernel build went well. If CONFIG_TRIM_UNUSED_KSYMS is set, this might be -# evaluated more than once. -PHONY += vmlinux_prereq -vmlinux_prereq: $(vmlinux-deps) FORCE -ifdef CONFIG_HEADERS_CHECK - $(Q)$(MAKE) -f $(srctree)/Makefile headers_check -endif -ifdef CONFIG_GDB_SCRIPTS - $(Q)ln -fsn $(abspath $(srctree)/scripts/gdb/vmlinux-gdb.py) -endif -ifdef CONFIG_TRIM_UNUSED_KSYMS - $(Q)$(CONFIG_SHELL) $(srctree)/scripts/adjust_autoksyms.sh \ - "$(MAKE) -f $(srctree)/Makefile vmlinux" -endif +# Recurse until adjust_autoksyms.sh is satisfied +PHONY += autoksyms_recursive +autoksyms_recursive: $(vmlinux-deps) + $(Q)$(CONFIG_SHELL) $(srctree)/scripts/adjust_autoksyms.sh || \ + $(MAKE) -f $(srctree)/Makefile autoksyms_recursive # For the kernel to actually contain only the needed exported symbols, # we have to build modules as well to determine what those symbols are. @@ -1023,7 +1013,13 @@ cmd_link-vmlinux = \ $(CONFIG_SHELL) $< $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux) ; \ $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) -vmlinux: scripts/link-vmlinux.sh vmlinux_prereq $(vmlinux-deps) FORCE +vmlinux: scripts/link-vmlinux.sh autoksyms_recursive $(vmlinux-deps) FORCE +ifdef CONFIG_HEADERS_CHECK + $(Q)$(MAKE) -f $(srctree)/Makefile headers_check +endif +ifdef CONFIG_GDB_SCRIPTS + $(Q)ln -fsn $(abspath $(srctree)/scripts/gdb/vmlinux-gdb.py) +endif +$(call if_changed,link-vmlinux) # Build samples along the rest of the kernel diff --git a/scripts/adjust_autoksyms.sh b/scripts/adjust_autoksyms.sh index 7bb3618..1377cf8 100755 --- a/scripts/adjust_autoksyms.sh +++ b/scripts/adjust_autoksyms.sh @@ -95,8 +95,7 @@ if [ $changed -gt 0 ]; then info "KSYMS" "symbols: before=$old, after=$new, changed=$changed" info "UPD" "$cur_ksyms_file" mv -f "$new_ksyms_file" "$cur_ksyms_file" - # Then trigger a rebuild of affected source files - exec $@ + exit 1 else rm -f "$new_ksyms_file" fi