From patchwork Fri Jul 20 07:46:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 142435 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2649697ljj; Fri, 20 Jul 2018 00:48:05 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdoQKv6CdK67KtQwCLlx6KpyQ+XunUiG/ZRpLjk5HpQbfg9e+I4bPhCub8ijYbmUHziduSO X-Received: by 2002:a62:6b44:: with SMTP id g65-v6mr1099530pfc.226.1532072885074; Fri, 20 Jul 2018 00:48:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532072885; cv=none; d=google.com; s=arc-20160816; b=o+X5aqMa0ZaEJHUXbQEGWuQwkiTYe0WAfPMBuW+yfkP4jY7VwyxVKblpt7N2Zr4xfn cgwhI7dedKsgCCkhrlQGHHKJUKNYYuRoBOccZpAxnrrI7BPYBzavnL86F/FrZLBoZTcX nUP8dPS85x3uNyQTGXwGoKV7aoirOpDjIW/XV7YSHDowyByfscPT/ok4OnvoT7UreY6d QzNDOO54FSrM4tfjGc5mO9ciRx/ibQih97A7IAcbQZ8bM8KE8+n/CxSFs8KxlZgl7dOa i+T78ncCQpcLcvUb4z7IEwLGJDTVUwKO/9Ul87g1GyknFyqy2FIlEESehNeGQXi0enEe aL/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter:arc-authentication-results; bh=0+xfs+t9qw6M2tt8q3cWVLKoBU4NgX/D4N4D58QqJ4g=; b=erBXcFO03aPJQ73lRWBCLlO7AXlvgSOSUKE54EZbfIS77K0oZN+hV/+A9Ys3Xo7ERQ 9UBbA2pr6Bz+500wmour3ws2o6DGaBIOvktplcIX9rfLRz4M9Oidog68d8LiKbrUa6Im psx1NLLaRTGBkulCFfbch7jlQQeVpztsQSpwm/oJc8ApgzW9jhx1Vl4vsTF/GZeSTB1P qj2gP5Mrh/HaecRONDZAl9z8vrjNzgWO334bToAOH3A1sVIWbhLb4swuBOHeHWSruDN4 BkDN0oBhRhvWWpaWV6JdYaiGKIGEQbXFvYRkrcoLdujMkB52Rinx4oa4OLoDeBvRNWwd MHug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=D49FMcwu; 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 h11-v6si1306263pfe.102.2018.07.20.00.48.04; Fri, 20 Jul 2018 00:48:05 -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=D49FMcwu; 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 S1727740AbeGTIfA (ORCPT + 31 others); Fri, 20 Jul 2018 04:35:00 -0400 Received: from conuserg-08.nifty.com ([210.131.2.75]:28448 "EHLO conuserg-08.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727205AbeGTIe6 (ORCPT ); Fri, 20 Jul 2018 04:34:58 -0400 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-08.nifty.com with ESMTP id w6K7kdj0008048; Fri, 20 Jul 2018 16:46:44 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com w6K7kdj0008048 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1532072804; bh=0+xfs+t9qw6M2tt8q3cWVLKoBU4NgX/D4N4D58QqJ4g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D49FMcwuuk7iycUF/XCYQiqBAMTZrXLhcgFAIHMgOovnwMGGrUgYR7Y3/AQGT87fj Vk4qkmOQ02ds/NGvIqCAVKSr58k4riskgXXbHnUTfADhd8ScXivgrulvE+rtJMTN1l 7bhUUpvfggXeRoOXgURzwfkYoPS9t9kjAyOEI3QkJc6H7tvZofBuhE3MUIcoWaFG80 CC2sf0ybBfYelp04VRYUW4rxLTZOEAPYZmHAFBHMCV3cYRUMMbEWh9bL5hLXleiIMw t5icg3xDpHCxadlvtpbsdu9U+Xog0yxr4IS/z9pfGfZ37RqAAVoZolXeIJ8XRCIQ78 w4SZFSj/IV8qg== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Dirk Gouders , Ulf Magnusson , Sam Ravnborg , Masahiro Yamada , Michal Marek , linux-kernel@vger.kernel.org Subject: [PATCH v4 08/11] kbuild: add .DELETE_ON_ERROR special target Date: Fri, 20 Jul 2018 16:46:33 +0900 Message-Id: <1532072796-7947-9-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1532072796-7947-1-git-send-email-yamada.masahiro@socionext.com> References: <1532072796-7947-1-git-send-email-yamada.masahiro@socionext.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If Make gets a fatal signal while a shell is executing, it may delete the target file that the recipe was supposed to update. This is needed to make sure that it is remade from scratch when Make is next run; if Make is interrupted after the recipe has begun to write the target file, it results in an incomplete file whose time stamp is newer than that of the prerequisites files. Make automatically deletes the incomplete file on interrupt unless the target is marked .PRECIOUS. The situation is just the same as when the shell fails for some reasons. Usually when a recipe line fails, if it has changed the target file at all, the file is corrupted, or at least it is not completely updated. Yet the file’s time stamp says that it is now up to date, so the next time Make runs, it will not try to update that file. However, Make does not cater to delete the incomplete target file in this case. We need to add .DELETE_ON_ERROR somewhere in the Makefile to request it. scripts/Kbuild.include seems a suitable place to add it because it is included from almost all sub-makes. Please note .DELETE_ON_ERROR is not effective for phony targets. The external module building should never ever touch the kernel tree. The following recipe fails if include/generated/autoconf.h is missing. However, include/config/auto.conf is not deleted since it is a phony target. PHONY += include/config/auto.conf include/config/auto.conf: $(Q)test -e include/generated/autoconf.h -a -e $@ || ( \ echo >&2; \ echo >&2 " ERROR: Kernel configuration is invalid."; \ echo >&2 " include/generated/autoconf.h or $@ are missing.";\ echo >&2 " Run 'make oldconfig && make prepare' on kernel src to fix it."; \ echo >&2 ; \ /bin/false) Signed-off-by: Masahiro Yamada --- Changes in v4: None scripts/Kbuild.include | 3 +++ 1 file changed, 3 insertions(+) -- 2.7.4 diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 3d14d0e..7f4b1db 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -400,3 +400,6 @@ endif endef # ############################################################################### + +# delete partially updated (i.e. corrupted) files on error +.DELETE_ON_ERROR: