Skip to content

Commit bb81955

Browse files
dgoudersmasahir0y
authored andcommitted
kbuild: if_changed: document single use per target limitation
Users of if_changed could easily feel invited to use it to divide a recipe into parts like: a: prereq FORCE $(call if_changed,do_a) $(call if_changed,do_b) But this is problematic, because if_changed should not be used more than once per target: in the above example, if_changed stores the command-line of the given command in .a.cmd and when a is up-to-date with respect to prereq, the file .a.cmd contains the command-line for the last command executed, i.e. do_b. When the recipe is then executed again, without any change of prerequisites, the command-line check for do_a will fail, do_a will be executed and stored in .a.cmd. The next check, however, will still see the old content (the file isn't re-read) and if_changed will skip do_b, because the command-line test will not recognize a change. On the next execution of the recipe the roles will flip: do_a is OK but do_b not and it will be executed. And so on... Signed-off-by: Dirk Gouders <dirk@gouders.net> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
1 parent 0df57d9 commit bb81955

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

‎Documentation/kbuild/makefiles.txt‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,6 +1105,12 @@ When kbuild executes, the following steps are followed (roughly):
11051105
target: source(s) FORCE
11061106
#WRONG!# $(call if_changed, ld/objcopy/gzip/...)
11071107

1108+
Note: if_changed should not be used more than once per target.
1109+
It stores the executed command in a corresponding .cmd
1110+
file and multiple calls would result in overwrites and
1111+
unwanted results when the target is up to date and only the
1112+
tests on changed commands trigger execution of commands.
1113+
11081114
ld
11091115
Link target. Often, LDFLAGS_$@ is used to set specific options to ld.
11101116

0 commit comments

Comments
 (0)