From patchwork Thu Nov 9 15:41:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 118455 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp6746920qgn; Thu, 9 Nov 2017 07:43:00 -0800 (PST) X-Google-Smtp-Source: ABhQp+SLQDdwgv065MmQ0WHcxU3sTSWGm6ojj3uNSvMchFSrZVF4u8MYGuUs/bATHmV5/sGY+hoG X-Received: by 10.98.236.220 with SMTP id e89mr873349pfm.219.1510242180764; Thu, 09 Nov 2017 07:43:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510242180; cv=none; d=google.com; s=arc-20160816; b=SGI3OLst9ARGA/ZCuRvuYKEe7FMK+TzAxp1Lfnq0HgI+WKMF1L+BnC8ksFipuQVyLk t6OFyP7FnlYTdKc5BwDDEQq96TvFIf4GB8RYTTl4T5AZ9vZe//lzJxWInk3rXVd1N+G0 l/vmGbdrBE9YgR6hQbxWBKxMnLfyWBX9rhqHyfXEYOS6f85A78Y9/W1U4puMqSRBA0zJ D5Ms4VP4g+pRHZFgLp3FHRpYuGv6HOllF2uLpx99KdZGb5u+WFltkePInk0i+swkLYY3 AlBBg73fKfVHQh0oR9TmvfS+G5jicx+pqXIJV/Xc7VJVSTfRnrTEPH0soNWV26GRBETX HNxw== 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=PizTzENAZGokA8zYcC/aulwUXbUws9MjOFKj31l0zi0=; b=PSwhPZs1kryzFlBo1j3YVuyZE6aM5cI9tgIAVGIzs7UL5yEn89pyki5yAo3+qHTiuC 2z9lbuDYScJ58sC/0qQ10J00MujPz7UotbZ0BjsuV4IdRHe4JQqBvt2P/T0PT4DwpNtU NFfbyHo8DhpUl8PRpuZI8Ekkeds57U+v50t++yZfObkFcf/WN6hpIxAwE2V5Qn44uycg 5RvAegUnp7AdKPZRhYwEmoBXTlwihBoK4n0Dk0AdvSkCoPH9ng2n3tNKSECtCtYkmviy vNBLEjtglCUJMgrgSIymw8dMnPjx1vRTIOZ8NdXXIpLOEMTtl/Oha98VthiU2Ky6XSDW RtpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=zGUtHiam; 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 3si6578313plz.759.2017.11.09.07.42.59; Thu, 09 Nov 2017 07:43:00 -0800 (PST) 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=zGUtHiam; 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 S1752535AbdKIPm6 (ORCPT + 22 others); Thu, 9 Nov 2017 10:42:58 -0500 Received: from conuserg-11.nifty.com ([210.131.2.78]:23901 "EHLO conuserg-11.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750740AbdKIPm4 (ORCPT ); Thu, 9 Nov 2017 10:42:56 -0500 Received: from grover.sesame (FL1-125-199-20-195.osk.mesh.ad.jp [125.199.20.195]) (authenticated) by conuserg-11.nifty.com with ESMTP id vA9FfQvB007776; Fri, 10 Nov 2017 00:41:27 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com vA9FfQvB007776 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1510242088; bh=PizTzENAZGokA8zYcC/aulwUXbUws9MjOFKj31l0zi0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zGUtHiamurLG/psJ2Q02XrcDPBOdsGzFDeam2yKDS0fKTKn47dvukOLXirwXnLt9+ /Go8xVNOX8PB6rV2ijcS6QzYRb5mAbq9nvPdIb1MYNGAmFVF69Uy6Eg2OhKsywmOyc hiA7XMzBDx8u7lF7NtSzu+L/uplCK2zzL6kyEC2ZeDaditYOyORfuJ5jRxy95OVX3G K0o+4Gvg390+G53G3tWvo6EtYuD56mWqCEDrMbO9y7+xrvuNL+Qjt7jBH5vqSInUsf 037qyEWm46DDdL6/aUdZVqw6z+6PkojSAi4glQTqW2nx4BWZvBuXl8xD15TiFrA2yZ OJ1ZJ5oJKw9Tw== X-Nifty-SrcIP: [125.199.20.195] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Michal Marek , Sam Ravnborg , Douglas Anderson , Masahiro Yamada Subject: [PATCH 1/4] kbuild: create directory for make cache only when necessary Date: Fri, 10 Nov 2017 00:41:14 +0900 Message-Id: <1510242077-8122-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510242077-8122-1-git-send-email-yamada.masahiro@socionext.com> References: <1510242077-8122-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 Currently, the existence of $(dir $(make-cache)) is always checked, and created if it is missing. We can avoid unnecessary system calls by some tricks. [1] If KBUILD_SRC is unset, we are building in the source tree. The output directory checks can be entirely skipped. [2] If at least one cache data is found, it means the cache file was included. Obiously its directory exists. Skip "mkdir -p". [3] If Makefile does not contain any call of __run-and-store, it will not create a cache file. No need to create its directory. [4] The "mkdir -p" should be only invoked by the first call of __run-and-store Signed-off-by: Masahiro Yamada --- scripts/Kbuild.include | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) -- 2.7.4 diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index be1c9d6..4fb1be1 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -99,18 +99,19 @@ cc-cross-prefix = \ # Include values from last time make-cache := $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/,$(if $(obj),$(obj)/)).cache.mk -ifeq ($(wildcard $(dir $(make-cache))),) -$(shell mkdir -p '$(dir $(make-cache))') -endif $(make-cache): ; -include $(make-cache) +cached-data := $(filter __cached_%, $(.VARIABLES)) + # If cache exceeds 1000 lines, shrink it down to 500. -ifneq ($(word 1000,$(filter __cached_%, $(.VARIABLES))),) +ifneq ($(word 1000,$(cached-data)),) $(shell tail -n 500 $(make-cache) > $(make-cache).tmp; \ mv $(make-cache).tmp $(make-cache)) endif +cache-dir := $(if $(KBUILD_SRC),$(if $(cache-data),,$(dir $(make-cache)))) + # Usage: $(call __sanitize-opt,Hello=Hola$(comma)Goodbye Adios) # # Convert all '$', ')', '(', '\', '=', ' ', ',', ':' to '_' @@ -136,6 +137,10 @@ __sanitize-opt = $(subst $$,_,$(subst $(right_paren),_,$(subst $(left_paren),_,$ define __run-and-store ifeq ($(origin $(1)),undefined) $$(eval $(1) := $$(shell $$(2))) +ifneq ($(cache-dir),) + $$(shell mkdir -p $(cache-dir)) + $$(eval cache-dir :=) +endif $$(shell echo '$(1) := $$($(1))' >> $(make-cache)) endif endef