From: Dirk Gouders <dirk@gouders.net>
To: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Linux Kbuild mailing list <linux-kbuild@vger.kernel.org>,
Ulf Magnusson <ulfalizer@gmail.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
Sam Ravnborg <sam@ravnborg.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Kees Cook <keescook@chromium.org>, Ingo Molnar <mingo@kernel.org>,
Michal Simek <monstr@monstr.eu>,
"David S. Miller" <davem@davemloft.net>
Subject: Re: [PATCH v3 05/12] kconfig: make syncconfig update .config regardless of sym_change_count
Date: Sat, 14 Jul 2018 09:12:03 +0200 [thread overview]
Message-ID: <ghefg6ffzw.fsf@lena.gouders.net> (raw)
In-Reply-To: <CAK7LNASN6_TM6a8ciVdgOH19d+CypMP+RQBnDsCSCtqub5co=g@mail.gmail.com> (Masahiro Yamada's message of "Fri, 13 Jul 2018 23:57:17 +0900")
Masahiro Yamada <yamada.masahiro@socionext.com> writes:
> 2018-07-12 20:32 GMT+09:00 Dirk Gouders <dirk@gouders.net>:
>> Masahiro Yamada <yamada.masahiro@socionext.com> writes:
>>
>>> 2018-07-09 20:39 GMT+09:00 Dirk Gouders <dirk@gouders.net>:
>>>> Dirk Gouders <dirk@gouders.net> writes:
>>>>
>>>> I think, I solved the puzzle and perhaps, that saves others some time:
>>>>
>>>> The problem is that "if_changed" was not designed for multiple use
>>>> inside a recipe and in the case of compressed/vmlinux, the 2-fold use
>>>> created a kind of flip-flop for situations when nothing has to be done
>>>> to build the target.
>>>>
>>>> Because each of the two users of "if_changed" stores it's footprint in
>>>> .vmlinux.cmd but that file then isn't re-read, one of the two
>>>> "if_changed" calculates that nothing has to be done wheras the other one
>>>> recognizes a change in the commandline, because it sees the command-line
>>>> for the other part of the reciepe.
>>>>
>>>> In the next make, the roles flip, because the previously satisfied
>>>> "if_changed" now sees the command-line of the other one. And so on...
>>>>
>>>> I am not a Kbuild expert but the attached patch fixes that problem by
>>>> introducing "if_changed_multi" that accepts two commands -- one whose
>>>> commandline should be checked and a second one that should be
>>>> executed.
>>>
>>>
>>> if_changed should not appear multiple times in one target.
>>>
>>> I think the simplest fix-up is to
>>> create a new command that combines
>>> 'cmd_check_data_rel' and 'cmd_ld'.
>>>
>>>
>>> quiet_cmd_link-vmlinux = LD $@
>>> cmd_link-vmlinux = $(cmd_check_data_rel); $(cmd_ld)
>>>
>>> $(obj)/vmlinux: $(vmlinux-objs-y) FORCE
>>> $(call if_changed,link-vmlinux)
>>>
>>> Kbuild also supports if_changed_rule,
>>> but the usage is more complex.
>>>
>>> There are only a few usages:
>>> https://github.com/torvalds/linux/blob/v4.17/scripts/Makefile.build#L288
>>
>> Just for completeness I will copy in part of a reply from Kees that
>> shows how double-colon rules can also avoid multiple use of if_changed
>> for one target:
>>
>> -$(obj)/vmlinux: $(vmlinux-objs-y) FORCE
>> - $(call if_changed,check_data_rel)
>> +$(obj)/vmlinux:: $(vmlinux-objs-y)
>> + $(call cmd,check_data_rel)
>> +$(obj)/vmlinux:: $(vmlinux-objs-y) FORCE
>> $(call if_changed,ld)
>
> It is difficult to use double-colon rules in a _sane_ way.
>
> The first one just checks data_rel,
> but does not actually generate anything.
>
> Such targets should be marked as .PHONY,
> but $(obj)/vmlinux is not a phony target.
> This is strange.
>
>> The combined command seems to have the advantage that every command to
>> build the target gets recorded in the .cmd file
>>
>> A search showed me that we have two more users that use if_changed more
>> than once for a single target:
>>
>> arch/microblaze/boot/Makefile (fourfold)
>> arch/sparc/boot/Makefile (2 times twofold)
>>
>> The sparc case seems to apply to any of the two suggested fixes,
>
> Neither is correct.
>
>
> $(obj)/uImage: $(obj)/image.gz
> $(call if_changed,uimage)
> $(call if_changed,uimage.o)
>
>
> should be split into two targets.
>
>
> $(obj)/uImage: $(obj)/image.gz FORCE
> $(call if_changed,uimage)
>
> $(obj)/uImage.o: $(obj)/uImage FORCE
> $(call if_changed,uimage.o)
>
>
> It is wrong in multiple ways. FORCE is missing too.
>
> but
>> microblaze uses if_changed in a pattern rule and also makes use of
>> parameter arguments in the sub-commands:
>>
>> $(obj)/simpleImage.%: vmlinux FORCE
>> $(call if_changed,cp,.unstrip)
>> $(call if_changed,objcopy)
>> $(call if_changed,uimage)
>> $(call if_changed,strip,.strip)
>> @echo 'Kernel: $(UIMAGE_OUT) is ready' ' (#'`cat .version`')'
>
>
> Probably, this is the same.
>
> Create a target for each step.
>
>
>> In this case, double colons would have a different meaning and the
>> combined command solution would result in a change of the sub-commands,
>> as well. I note this in case Michal perhaps has other preferences.
>>
>>
>> In addition to extend the documentation, we could modify if_changed to
>> warn about it is being used more than once for a target:
>>
>> # Execute command if command has changed or prerequisite(s) are updated.
>> if_changed = $(if $(filter-out undefined,$(origin if_changed_$@)), \
>> @set -e; \
>> echo "Warning: $@: multiple use of if_changed!" >&2; , \
>> @set -e $(eval if_changed_$@ := 1) ; ) \
>> $(if $(strip $(any-prereq) $(arg-check)), \
>> $(echo-cmd) $(cmd_$(1)); \
>> printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd, :)
>>
>> But this fires only if if_changed is actually called and it defines many
>> variables for just that purpose, so this is perhaps not what we want...
>>
>
> I do not want to mess up Makefile.
>
>
> Please do this check in scripts/checkpatch.pl
> if you want.
Thank you for spending your time in the detailed explanation.
I will use it to assemble that all to a fix and then send it for review.
Dirk
next prev parent reply other threads:[~2018-07-14 7:27 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-05 2:39 [PATCH v3 00/12] kbuild/kconfig: do not update config during installation Masahiro Yamada
2018-07-05 2:39 ` [PATCH v3 01/12] kconfig: rename file_write_dep and move it to confdata.c Masahiro Yamada
2018-07-05 2:39 ` [PATCH v3 02/12] kconfig: split out helpers to check file/directory, create directory Masahiro Yamada
2018-07-05 2:39 ` [PATCH v3 03/12] kconfig: remove unneeded directory generation from local*config Masahiro Yamada
2018-07-05 2:39 ` [PATCH v3 04/12] kconfig: create directories needed for syncconfig by itself Masahiro Yamada
2018-07-05 2:39 ` [PATCH v3 05/12] kconfig: make syncconfig update .config regardless of sym_change_count Masahiro Yamada
2018-07-06 12:23 ` Dirk Gouders
2018-07-06 23:38 ` Dirk Gouders
2018-07-09 11:39 ` Dirk Gouders
2018-07-10 15:19 ` Kees Cook
2018-07-12 2:12 ` Masahiro Yamada
2018-07-12 11:32 ` Dirk Gouders
2018-07-12 21:06 ` Dirk Gouders
2018-07-13 14:57 ` Masahiro Yamada
2018-07-14 7:12 ` Dirk Gouders [this message]
2018-07-05 2:39 ` [PATCH v3 06/12] kconfig: allow all config targets to write auto.conf if missing Masahiro Yamada
2018-07-05 2:39 ` [PATCH v3 07/12] kbuild: use 'include' directive to load auto.conf from top Makefile Masahiro Yamada
2018-07-05 2:39 ` [PATCH v3 08/12] kbuild: add .DELETE_ON_ERROR special target Masahiro Yamada
2018-07-05 2:39 ` [PATCH v3 09/12] kbuild: do not update config when running install targets Masahiro Yamada
2018-07-05 2:39 ` [PATCH v3 10/12] kbuild: do not update config for 'make kernelrelease' Masahiro Yamada
2018-07-05 2:39 ` [PATCH v3 11/12] kbuild: remove auto.conf and tristate.conf from prerequisites Masahiro Yamada
2018-07-05 2:39 ` [PATCH v3 12/12] kbuild: replace include/config/%.conf with include/config/auto.conf Masahiro Yamada
2018-07-10 11:34 ` [PATCH v3 00/12] kbuild/kconfig: do not update config during installation Dirk Gouders
2018-07-12 8:29 ` Masahiro Yamada
2018-07-13 7:44 ` Dirk Gouders
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=ghefg6ffzw.fsf@lena.gouders.net \
--to=dirk@gouders.net \
--cc=davem@davemloft.net \
--cc=keescook@chromium.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=monstr@monstr.eu \
--cc=sam@ravnborg.org \
--cc=torvalds@linux-foundation.org \
--cc=ulfalizer@gmail.com \
--cc=yamada.masahiro@socionext.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®