From patchwork Fri Oct 13 11:25:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 115758 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp614339qgn; Fri, 13 Oct 2017 04:27:45 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDhSEZkDoCHnbh2VZ+ZTpBfJkqk9Khbh66AlWb1HexEXsryCL3pGZ4JJ97zzOUgajxLad/y X-Received: by 10.99.176.79 with SMTP id z15mr1054151pgo.230.1507894065415; Fri, 13 Oct 2017 04:27:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507894065; cv=none; d=google.com; s=arc-20160816; b=rskjnINrUaHmyQt1lood4749Ooyh6mZVbrcrpGS1u51Dz+ywuRNOjKB2HxUbxs8ZGR q9oD1S5XREML3nrpQdu7dHPnR4O5eml3xkWQxamSzU9E7l1sk1FLSva4dQXWx8DvUM3g 7s+ldOGVDIs997/EcbUoV2ChnMzxuYJ4rpt6zcrAovPsQBJCRgNoufExQmfD2L9uyKe0 ZzicJnS8dfYMwfM9nvrFXHZNZ4yO/j2Cyp+503fgWYre6ifI//h5dZnVAcMl8Ly1kxzY J3nTVKrGzXKdbQKlNKlu9GskHABdMM8PqYxEGKU9KV23rQU8+cz9cfE80G2FgRu0h9Ef t4xA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter:arc-authentication-results; bh=QEUc8RKXPluRmzfHHZEYG6G79XsQesMOI09SE15Nbtg=; b=NeUKX5us2WenYZr0hZyp5cZH1hAtGr1ntAP2uU2jSE2YzowOscFieiOd1l8VCVQr8h ct2D1dgn+LsYLeZCHzNeWFNDa8YObLJi5ZeGlxJ25OVZ19gFwprU9wzQ/6/Fjl4rmM5l JJmdGWDYugX78qInTDcF1anQ4WiZz/4JTDHBZicp8PawV3Ah5cuVKMIdIRagonYJJimj L8eW+HkVafH51R/AQ2r18FrhmlyVgtWxxFQv5bxc1sKYzknDWBW0sp3N9NnQbCT+kmKh g5CZNNpnAi0A6XXUOEM+CXEoVyBTioXOZ4YEsPRS03tK81Z7zvo93qCX10lqFUidPLxx 1zGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=wqGcPAPp; 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 s10si461040pgd.559.2017.10.13.04.27.45; Fri, 13 Oct 2017 04:27:45 -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=wqGcPAPp; 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 S1757843AbdJML1m (ORCPT + 27 others); Fri, 13 Oct 2017 07:27:42 -0400 Received: from conuserg-11.nifty.com ([210.131.2.78]:31975 "EHLO conuserg-11.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751480AbdJML1l (ORCPT ); Fri, 13 Oct 2017 07:27:41 -0400 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-11.nifty.com with ESMTP id v9DBPa1i011318; Fri, 13 Oct 2017 20:25:37 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com v9DBPa1i011318 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1507893938; bh=QEUc8RKXPluRmzfHHZEYG6G79XsQesMOI09SE15Nbtg=; h=From:To:Cc:Subject:Date:From; b=wqGcPAPpCWiTnN7ijp0DnPxih8BoNuHmW2SiZFAS28i6cy8SqpkBht+FiymJFXaju 4lG4LJW0f6edMoyODgF1cTfh4uk+SqESDSESVv5abGuNxqIVeuKJDDMOOPQ4gF1mBL sjxBFZNp+yJqXIdtrrPzz7CpSdx28lBtw8gPhOPaZ29YvGl/dNBhlPCkiXGE9AgvKH S61XPi/ZojfgdLlT4QcgGl1Sig6ulPWet8CijeoHvEMA+V4Fx5ECg4a3J1/F8gSHs/ xP6UATryh5XCtp0Qfi4ty8JjrbkEfOh58tm0TBIS7O5RSiN5Gcw7SLDnSt1eF1OO36 iN1KVTqrADjjA== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Douglas Anderson , Sam Ravnborg , Masahiro Yamada , Marcin Nowakowski , Matthias Kaehlcke , Cao jin , Arnd Bergmann , Mark Charlebois , linux-kernel@vger.kernel.org, Josh Poimboeuf , Ingo Molnar Subject: [PATCH v2] kbuild: shrink .cache.mk when it exceeds 1000 lines Date: Fri, 13 Oct 2017 20:25:29 +0900 Message-Id: <1507893929-32573-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The cache files are only cleaned away by "make clean". If you continue incremental builds, the cache files will grow up little by little. It is not a big deal in general use cases because compiler flags do not change quite often. However, if you do build-test for various architectures, compilers, and kernel configurations, you will end up with huge cache files soon. When the cache file exceeds 1000 lines, shrink it down to 500 by "tail". The Least Recently Added lines are cut. (not Least Recently Used) I hope it will work well enough. Signed-off-by: Masahiro Yamada --- Changes in v2: - Simplify code per Douglas Anderson scripts/Kbuild.include | 6 ++++++ 1 file changed, 6 insertions(+) -- 2.7.4 Reviewed-by: Douglas Anderson diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 4203fff..d939490 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -102,6 +102,12 @@ make-cache := $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/,$(if $(obj),$(obj)/)).cach $(make-cache): ; -include $(make-cache) +# If cache exceeds 1000 lines, shrink it down to 500. +ifneq ($(word 1000,$(filter __cached_%, $(.VARIABLES))),) +$(shell tail -n 500 $(make-cache) > $(make-cache).tmp; \ + mv $(make-cache).tmp $(make-cache)) +endif + # Usage: $(call __sanitize-opt,Hello=Hola$(comma)Goodbye Adios) # # Convert all '$', ')', '(', '\', '=', ' ', ',', ':' to '_'