]> git.itanic.dy.fi Git - linux-stable/commit
efi/libstub: zboot: do not use $(shell ...) in cmd_copy_and_pad
authorMasahiro Yamada <masahiroy@kernel.org>
Mon, 18 Dec 2023 08:01:27 +0000 (17:01 +0900)
committerWill Deacon <will@kernel.org>
Tue, 19 Dec 2023 10:02:40 +0000 (10:02 +0000)
commit97ba4416d6dd53c4202038ee7d86dfb29774e00f
treeac1240178233004d75360ca3f8959450d219a6a7
parent7b21ed7d119dc06b0ed2ba3e406a02cafe3a8d03
efi/libstub: zboot: do not use $(shell ...) in cmd_copy_and_pad

You do not need to use $(shell ...) in recipe lines, as they are already
executed in a shell. An alternative solution is $$(...), which is an
escaped sequence of the shell's command substituion, $(...).

For this case, there is a reason to avoid $(shell ...).

Kbuild detects command changes by using the if_changed macro, which
compares the previous command recorded in .*.cmd with the current
command from Makefile. If they differ, Kbuild re-runs the build rule.

To diff the commands, Make must expand $(shell ...) first. It means that
hexdump is executed every time, even when nothing needs rebuilding. If
Kbuild determines that vmlinux.bin needs rebuilding, hexdump will be
executed again to evaluate the 'cmd' macro, one more time to really
build vmlinux.bin, and finally yet again to record the expanded command
into .*.cmd.

Replace $(shell ...) with $$(...) to avoid multiple, unnecessay shell
evaluations. Since Make is agnostic about the shell code, $(...), the
if_changed macro compares the string "$(hexdump -s16 -n4 ...)" verbatim,
so hexdump is run only for building vmlinux.bin.

For the same reason, $(shell ...) in EFI_ZBOOT_OBJCOPY_FLAGS should be
eliminated.

While I was here, I replaced '&&' with ';' because a command for
if_changed is executed with 'set -e'.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Link: https://lore.kernel.org/r/20231218080127.907460-1-masahiroy@kernel.org
Signed-off-by: Will Deacon <will@kernel.org>
arch/arm64/boot/Makefile
drivers/firmware/efi/libstub/Makefile.zboot