Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2484242imm; Mon, 24 Sep 2018 05:17:05 -0700 (PDT) X-Google-Smtp-Source: ACcGV62n+CWN+ND7lcguo2h7+8CMscStxaFq4lkFGn+DzBt2+6Aeeh5MEuZCWL2IyaTjdM3YwAmf X-Received: by 2002:a62:9f4c:: with SMTP id g73-v6mr10165149pfe.142.1537791425688; Mon, 24 Sep 2018 05:17:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537791425; cv=none; d=google.com; s=arc-20160816; b=rBZshJDwk1Smh+YGXLGi5DVu2xKavf4e1YxATqHHkAca9R94cgoYq0e0e7vwhOmcIS sAEU6Ay3zi3ZJb1knd2MhFHW7zsVZ8TUdvFI/uo//6BhMph83AiS6WBoBYcriG3k8mUe iSDNUcRWuzkxVIi+FWBhxFSZe5vX0B3FU+63HMsabGzDMMchpNND8Fs/I+DDcbCN0pcY bkVsKBHvDuDV0hj/XTscGHDrzN+xmJtwNBOcImN11i4JVV8wq1PY5tt/Dft7T+x2BBJY vVlbEUt7Xs9tqsiBXy8eDhCgguMjf508Ejfi1C7BA6WYLnRRAOfY9w7JKcABYIJOTjfv x1OQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=Ai7qrnRlNyySWZlOWoXf8BoJW44WPouZCh4sAB8bJeo=; b=vNiaI2qroCwohNvxRaFRkWS4XaMCYRI68JHCrb0TqeIfJs4M5bS6/dkXUd+eY+zvZw Ibkx/PDnwWtpF4B+fj/krIboGrC7SA4rGhwliDIIONObWBP6od0+wQT0bqYfj0oQlh4B gGzVQ0tZpyfgus4WhVHKo9ztntJsNXap+CWIaMb7k/G/A879Jk0nhN8bj+3yO0M2vOYq p+61cBlrvXeek/wnZC01r861SdQ4/VSCEmJVgrziavyNzFiN0ewWAYgfh3GDL+r/6mlo 4JFpVsr+4r7zRoOcNauujP4yIqcHT+/l+u6LeDaPj2wSvMljZbY6FuQyigj8fpCYVAN5 QyGQ== ARC-Authentication-Results: i=1; mx.google.com; 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 i5-v6si6077145pgn.314.2018.09.24.05.16.50; Mon, 24 Sep 2018 05:17: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; 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 S1732111AbeIXSRb (ORCPT + 99 others); Mon, 24 Sep 2018 14:17:31 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:55602 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730150AbeIXSRb (ORCPT ); Mon, 24 Sep 2018 14:17:31 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id DCC0C10A5; Mon, 24 Sep 2018 12:15:39 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Masahiro Yamada , Sasha Levin Subject: [PATCH 4.14 024/173] kbuild: add .DELETE_ON_ERROR special target Date: Mon, 24 Sep 2018 13:50:58 +0200 Message-Id: <20180924113117.451547930@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180924113114.334025954@linuxfoundation.org> References: <20180924113114.334025954@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Masahiro Yamada [ Upstream commit 9c2af1c7377a8a6ef86e5cabf80978f3dbbb25c0 ] 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 Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- scripts/Kbuild.include | 3 +++ 1 file changed, 3 insertions(+) --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -403,3 +403,6 @@ endif endef # ############################################################################### + +# delete partially updated (i.e. corrupted) files on error +.DELETE_ON_ERROR: