From patchwork Thu Jul 5 02:39:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 141092 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1409376ljj; Wed, 4 Jul 2018 19:41:45 -0700 (PDT) X-Google-Smtp-Source: AAOMgpefMNN+udyWkG363Pod29xKGveAFCKR4koT8EzoZDGCO6UaHgH4zQWTJvFHADK7mpEUVBGk X-Received: by 2002:a62:968f:: with SMTP id s15-v6mr4408056pfk.191.1530758505132; Wed, 04 Jul 2018 19:41:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530758505; cv=none; d=google.com; s=arc-20160816; b=ChGp3Ax3ehuuWv390qmOPpvg0EaST+CRaG14P69N4tbce8nE3RErJ1csG1iH9vDk2O cEEfhR5L+lXNmc+6EjKyjT3qjsfrC4TDSoFZpT/t8BVxNufDfK/AORxPhan0jH+Flzk/ TbmPCfHn1t6B9TB+r53X9AHJwFswnVp5EbPN1NyrPb9+ELsljLIpyIrSfoDJ2AJHC8dF go+Mt7a0DynUTrLRbVwsgldyr+E1ieNOn8MLUQu/WTEMf10Z6OQqwdw5NgZzfA2+pKCs VuGZ622O5AhT1DrU/7KyynsHQkOCoiD5PCHBrorLHbSPyJ2CfoCtCAtt1BDa3pEKxMhP wy/A== 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 h15-v6si804986pgh.566.2018.07.04.19.41.44; Wed, 04 Jul 2018 19:41: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=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 S1753383AbeGECln (ORCPT + 31 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 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(+) -- 2.7.4 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: