Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp127945imm; Wed, 4 Jul 2018 19:44:04 -0700 (PDT) X-Google-Smtp-Source: AAOMgpejHq8OzXtBVXpH6PSThfCRniY8+97xuy7Gbi2kDpnLnEJ9ESWBIP+dh724az9Ym54oExh9 X-Received: by 2002:a62:8a83:: with SMTP id o3-v6mr4479619pfk.12.1530758644427; Wed, 04 Jul 2018 19:44:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530758644; cv=none; d=google.com; s=arc-20160816; b=YDab1uWqDuNYGkOKc+h839fy0fBfcT+SGuqF91nW1DCAfw774tBvj9BYFbv1S0XhE0 Gk0P6a8Vq+NfeC2xHhlTnOON8us5BfO3rT4jbzfymT/LnZvKN95nj6G4RWkt9HHGh3ee f+g+7CApLqs86tu4qWy7ASymUrNeC7nT0Z8icGR+z2vN4qkMEpeqPev85EynFUDlvuD0 8BL8Tcptf4e5HqJxRuhYIuldxhpVvuxcyLlkCh4LRBK7z82yrIxS/6EV3BEC9aL2BFFg 8XTyG1w0fcDmxC6KTTxcQqD/Pq8SN4Yar0KStBvaGI701x3G82HeI17igMUQLmBiCbvk 9y0g== 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=5iP+WFhN/JF+QJ1sHqvSaieX4HmPr/nz+jZdqsNYU8I=; b=I0j/rGphinc7QYJT+rxTucTX8MMcG7ikcZA34iHWRMWBEz7PQvv0DmIOqKlXaZOHMo RBReAMYZwGHbnA2RAqj+H6skr2R7mLQc7ecMNtT1ObaZAR5ZM1jTT7Sbt2zZC/VcEbFe 0QNlQZ55bZ8hZEEls2S30eBub6mdBmOJ03mxaTjrOnABahdPG381mzAyq3g20GeCrGii hl/6P0K0hD/J1hlQ5tV2l2nSnfutzhhm73kS6Q+aMtmNrFyikXEUHcKoYdQjPheCqBSp 0f0erBiPz7xIbTD//37qNFQ2U9WbCxrzsB9p8CEI+gTZrgVxEmmnyYRF27t/4fclNtCF hLRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=XL8rJ1+z; 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 c7-v6si5211371plz.21.2018.07.04.19.43.50; Wed, 04 Jul 2018 19:44:04 -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=XL8rJ1+z; 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 S1753375AbeGECln (ORCPT + 99 others); Wed, 4 Jul 2018 22:41:43 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:43891 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753062AbeGEClg (ORCPT ); Wed, 4 Jul 2018 22:41:36 -0400 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-07.nifty.com with ESMTP id w652duZe028145; Thu, 5 Jul 2018 11:40:03 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com w652duZe028145 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1530758403; bh=5iP+WFhN/JF+QJ1sHqvSaieX4HmPr/nz+jZdqsNYU8I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XL8rJ1+zSHI2OKUzexfcJNBks8gzC55i7380gz7+FQ+U1PVVjna8ec+i7UGqrf6zN EfvYQ61WvOyBSXmokDGkz1sonGZK8g32tl0rVIMW9bVCPVx9ojsoxHxaPMGktC1lFE CFmh60XXUfx+oRuEzeeVbEoMO7U6V8yqryqWYbAGmSeIv2lIiQ3maZCqaIPUsBzFzO q2p5EKBzLlIdcGDbsblt5h62fJxSce22MdCvKiWoAAecEwuWR+Btdkm/LJvJaDQwLR w+qLRhFHM5x79VLC6QKojXHxoEKq/JP/zaDGb14g4CpZ+8y7OoePnVS3MlIUOnyDpR B7w4ErBiiUwJA== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Dirk Gouders , Ulf Magnusson , Linus Torvalds , Sam Ravnborg , Masahiro Yamada , Michal Marek , linux-kernel@vger.kernel.org Subject: [PATCH v3 08/12] kbuild: add .DELETE_ON_ERROR special target Date: Thu, 5 Jul 2018 11:39:45 +0900 Message-Id: <1530758389-30862-9-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1530758389-30862-1-git-send-email-yamada.masahiro@socionext.com> References: <1530758389-30862-1-git-send-email-yamada.masahiro@socionext.com> 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 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 --- scripts/Kbuild.include | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index c8156d6..b2d14f1 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: -- 2.7.4