All of lore.kernel.org
 help / color / mirror / Atom feed
From: Masahiro Yamada <yamada.masahiro@socionext.com>
To: linux-kbuild@vger.kernel.org
Cc: Dirk Gouders <dirk@gouders.net>,
	Ulf Magnusson <ulfalizer@gmail.com>,
	Sam Ravnborg <sam@ravnborg.org>,
	Masahiro Yamada <yamada.masahiro@socionext.com>,
	Michal Marek <michal.lkml@markovi.net>,
	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	[thread overview]
Message-ID: <1532072796-7947-9-git-send-email-yamada.masahiro@socionext.com> (raw)
In-Reply-To: <1532072796-7947-1-git-send-email-yamada.masahiro@socionext.com>

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 <yamada.masahiro@socionext.com>
---

Changes in v4: None

 scripts/Kbuild.include | 3 +++
 1 file changed, 3 insertions(+)

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:
-- 
2.7.4


  parent reply	other threads:[~2018-07-20  7:48 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-20  7:46 [PATCH v4 00/11] kbuild/kconfig: do not update config during installation Masahiro Yamada
2018-07-20  7:46 ` [PATCH v4 01/11] kconfig: rename file_write_dep and move it to confdata.c Masahiro Yamada
2018-07-20  7:46 ` [PATCH v4 02/11] kconfig: split out useful helpers in confdata.c Masahiro Yamada
2018-07-20  7:46 ` [PATCH v4 03/11] kconfig: remove unneeded directory generation from local*config Masahiro Yamada
2018-07-20  7:46 ` [PATCH v4 04/11] kconfig: create directories needed for syncconfig by itself Masahiro Yamada
2018-07-20  7:46 ` [PATCH v4 05/11] kconfig: make syncconfig update .config regardless of sym_change_count Masahiro Yamada
2018-07-20  7:46 ` [PATCH v4 06/11] kconfig: allow all config targets to write auto.conf if missing Masahiro Yamada
2018-07-20  7:46 ` [PATCH v4 07/11] kbuild: use 'include' directive to load auto.conf from top Makefile Masahiro Yamada
2018-09-03  9:39   ` Borislav Petkov
2018-09-03  9:54     ` Masahiro Yamada
2018-09-03 10:00       ` Borislav Petkov
2018-09-05 22:53         ` Segher Boessenkool
2018-09-06  0:46           ` Masahiro Yamada
2018-07-20  7:46 ` Masahiro Yamada [this message]
2018-07-20  7:46 ` [PATCH v4 09/11] kbuild: do not update config when running install targets Masahiro Yamada
2018-07-20  7:46 ` [PATCH v4 10/11] kbuild: do not update config for 'make kernelrelease' Masahiro Yamada
2018-07-20  7:46 ` [PATCH v4 11/11] kbuild: remove auto.conf from prerequisite of phony targets Masahiro Yamada
2018-07-25 14:40 ` [PATCH v4 00/11] kbuild/kconfig: do not update config during installation Masahiro Yamada

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1532072796-7947-9-git-send-email-yamada.masahiro@socionext.com \
    --to=yamada.masahiro@socionext.com \
    --cc=dirk@gouders.net \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.lkml@markovi.net \
    --cc=sam@ravnborg.org \
    --cc=ulfalizer@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.