From patchwork Sun Apr 25 07:07:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 12222989 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9701FC43460 for ; Sun, 25 Apr 2021 07:09:49 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 14B0C613C2 for ; Sun, 25 Apr 2021 07:09:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 14B0C613C2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=LV1jgNR6E40iNbA3Mxj1iO3KlCYFSXCV9Sz4+u0w/3c=; b=llMPtbn8NqWcpeOyxc5XDQjUtq YT2WlTTZOxAg4Z0UGGtrydKXnExRNZV78I4JPsBfaCeNJzXEC6IS4IWSBtt1eUX8QU5gl4K4iytrp FkByDlCgkAKUgiRdB17YarkNDkY8PAzOFukB3BtIKnPGzRbK/2jBtQTJ+KPEinCLH8x+nI8c9ShJm RHLavnKSqSEnpH90DcxTmR0eo+n3qQmg3kM6sNBgOT06C3xF6ELfzWhvblrvkqfgqefQPLxzbEAHq LhcGQsrPhhRplMFTZpiv229AoppPQ6rx6fbzomdgzWC0Xxx1jqn4ENXWJ4d8hyrNC/4uih8rO6y1b g2PPROMQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1laYrn-005B7c-3r; Sun, 25 Apr 2021 07:07:43 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1laYre-005B6x-MD for linux-arm-kernel@desiato.infradead.org; Sun, 25 Apr 2021 07:07:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:In-Reply-To:References; bh=e6ebiU5ULjsvQr300Dk6h49ie/rrrFWrO2lUQXq6JzM=; b=T6TK8t+yxbbAnzsSzU59sR0c/Q 2dWwPtwrX3Bt3GTlGqZ6DBpVSf2lZKzfZMWCop0JUHvShRx7SUF6sSvWNxJUO9uTpD6a4Ck6NZ0ip SPvCOVqnZSqYMmAU7CHnD71iF7lnycVxIzXBl2qgK5CW/wb2eXXDsyO9N7P47a5OZdt8IupvWWhwC IGZZewDcW9S/KMQApdMqZwg7WOn5IDOrpe115PBR1nTti6UnyllhloaN4tTWpDtShyanwseEWJlq6 uQ8U0giyb/vy88jM01eX9E92gBFZSfyhhlwlnzQzcStjRUOk8pgMNgIGIahTW9txAJQOspxTakxE6 LAS7HT5g==; Received: from conuserg-07.nifty.com ([210.131.2.74]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1laYrZ-00FJnH-LG for linux-arm-kernel@lists.infradead.org; Sun, 25 Apr 2021 07:07:33 +0000 Received: from localhost.localdomain (133-32-232-101.west.xps.vectant.ne.jp [133.32.232.101]) (authenticated) by conuserg-07.nifty.com with ESMTP id 13P77E6F032328; Sun, 25 Apr 2021 16:07:14 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com 13P77E6F032328 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1619334435; bh=e6ebiU5ULjsvQr300Dk6h49ie/rrrFWrO2lUQXq6JzM=; h=From:To:Cc:Subject:Date:From; b=I4BunMKeL0Ue5l5vmpDu7RlRqPy/iEWvFuaLJjK5Dz84pf1tUbGmZxRlAj9gfCjxt JL7jroB+Ns3eoTwNDnRgGTQuYmdzpM34IekuYKyIQgX1mebLosKS/typ40B2Aw2yFP /2hZY0sidDJq/DKkE6OfzGHXP7I145Su6bZ9Jqt3b6aIqRqqBQ98JDhAN7t6t2enua eJNOU6HqpDZaTNlYiyzTpCE566HaZj9aISKGNvHt2wn49M+ninryGrrvH/tOhrfvrY 95PpII7S/IBYwCUOTuqn0+qXiqwAwAUB2NW6tWgaVfO6mm2GwNrTrm2W2jW6A6J7oV Xi8CQU8wn2tfw== X-Nifty-SrcIP: [133.32.232.101] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , Michal Marek , Russell King , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] kbuild: add a script to remove stale generated files Date: Sun, 25 Apr 2021 16:07:12 +0900 Message-Id: <20210425070712.1202472-1-masahiroy@kernel.org> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210425_000729_934763_E47DBAF3 X-CRM114-Status: GOOD ( 22.01 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org We maintain .gitignore and Makefiles so build artifacts are properly ignored by Git, and cleaned up by 'make clean'. However, the code is always changing; generated files are often moved to another directory, or removed when they become unnecessary. Such garbage files tend to be left over in the source tree because people usually git-pull without cleaning the tree. This is not only the noise for 'git status', but also a build issue in some cases. One solution is to remove a stale file like commit 223c24a7dba9 ("kbuild: Automatically remove stale file") did. Such workaround should be removed after a while, but we forget about that if we scatter the workaround code in random places. So, this commit adds a new script to collect cleanings of stale files. As a start point, move the code in arch/arm/boot/compressed/Makefile into this script. Signed-off-by: Masahiro Yamada --- Makefile | 6 +++++- arch/arm/boot/compressed/Makefile | 7 ------- scripts/remove-stale-files | 31 +++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 8 deletions(-) create mode 100755 scripts/remove-stale-files diff --git a/Makefile b/Makefile index b14483742a67..e970c8adf272 100644 --- a/Makefile +++ b/Makefile @@ -1202,7 +1202,7 @@ PHONY += prepare archprepare archprepare: outputmakefile archheaders archscripts scripts include/config/kernel.release \ asm-generic $(version_h) $(autoksyms_h) include/generated/utsrelease.h \ - include/generated/autoconf.h + include/generated/autoconf.h remove-stale-files prepare0: archprepare $(Q)$(MAKE) $(build)=scripts/mod @@ -1211,6 +1211,10 @@ prepare0: archprepare # All the preparing.. prepare: prepare0 prepare-objtool prepare-resolve_btfids +PHONY += remove-stale-files +remove-stale-files: + $(Q)$(srctree)/scripts/remove-stale-files + # Support for using generic headers in asm-generic asm-generic := -f $(srctree)/scripts/Makefile.asm-generic obj diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile index fd94e27ba4fa..182b300e3f8a 100644 --- a/arch/arm/boot/compressed/Makefile +++ b/arch/arm/boot/compressed/Makefile @@ -96,13 +96,6 @@ endif $(foreach o, $(libfdt_objs) atags_to_fdt.o fdt_check_mem_start.o, \ $(eval CFLAGS_$(o) := -I $(srctree)/scripts/dtc/libfdt -fno-stack-protector)) -# These were previously generated C files. When you are building the kernel -# with O=, make sure to remove the stale files in the output tree. Otherwise, -# the build system wrongly compiles the stale ones. -ifdef building_out_of_srctree -$(shell rm -f $(addprefix $(obj)/, fdt_rw.c fdt_ro.c fdt_wip.c fdt.c)) -endif - targets := vmlinux vmlinux.lds piggy_data piggy.o \ lib1funcs.o ashldi3.o bswapsdi2.o \ head.o $(OBJS) diff --git a/scripts/remove-stale-files b/scripts/remove-stale-files new file mode 100755 index 000000000000..c3eb81c3f7de --- /dev/null +++ b/scripts/remove-stale-files @@ -0,0 +1,31 @@ +#!/bin/sh + +set -e + +# When you move, remove or rename generated files, you probably also update +# .gitignore and cleaning rules in the Makefile. This is the right thing +# to do. However, people usually do 'git pull', 'git bisect', etc. without +# running 'make clean'. Then, the stale generated files are left over, often +# causing build issues. +# +# Also, 'git status' shows such stale build artifacts as untracked files. +# What is worse, some people send a wrong patch to get them back to .gitignore +# without checking the commit history. +# +# So, when you (re)move generated files, please move the cleaning rules from +# the Makefile to this script. This is run before Kbuild starts building +# anything, so people will not be annoyed by such garbage files. +# +# This script is not intended to grow endlessly. Rather, it is a temporary scrap +# yard. Stale files stay in this file for a while (for some release cycles?), +# then will be really dead and removed from the code base entirely. + +# These were previously generated source files. When you are building the kernel +# with O=, make sure to remove the stale files in the output tree. Otherwise, +# the build system wrongly compiles the stale ones. +if [ -n "${building_out_of_srctree}" ]; then + for f in fdt_rw.c fdt_ro.c fdt_wip.c fdt.c + do + rm -f arch/arm/boot/compressed/${f} + done +fi