Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

kbuild: fix compilation of dtb specified on command-line without make rule

Since commit e7e2941300d2 ("kbuild: split device tree build rules into
scripts/Makefile.dtbs"), it is no longer possible to compile a device tree
blob that is not specified in a make rule
like:
dtb-$(CONFIG_FOO) += foo.dtb

Before the mentioned commit, one could copy a dts file to e.g.
arch/arm64/boot/dts/ (or a new subdirectory) and then convert it to a dtb
file using:
make ARCH=arm64 foo.dtb

In this scenario, both 'dtb-y' and 'dtb-' are empty, and the inclusion of
scripts/Makefile.dtbs relies on 'targets' to contain the MAKECMDGOALS. The
value of 'targets', however, is only final later in the code.

Move the conditional include of scripts/Makefile.dtbs down to where the
value of 'targets' is final. Since Makefile.dtbs updates 'always-y' which is
used as a prerequisite in the build rule, the build rule also needs to move
down.

Fixes: e7e2941300d2 ("kbuild: split device tree build rules into scripts/Makefile.dtbs")
Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Acked-by: Rob Herring (Arm) <robh@kernel.org>
Link: https://patch.msgid.link/20251126100017.1162330-1-thomas.de_schampheleire@nokia.com
Signed-off-by: Nicolas Schier <nsc@kernel.org>

authored by

Thomas De Schampheleire and committed by
Nicolas Schier
b08fc4d0 07fe35b7

+14 -12
+14 -12
scripts/Makefile.build
··· 527 527 include $(srctree)/scripts/Makefile.userprogs 528 528 endif 529 529 530 - ifneq ($(need-dtbslist)$(dtb-y)$(dtb-)$(filter %.dtb %.dtb.o %.dtbo.o,$(targets)),) 531 - include $(srctree)/scripts/Makefile.dtbs 532 - endif 533 - 534 - # Build 535 - # --------------------------------------------------------------------------- 536 - 537 - $(obj)/: $(if $(KBUILD_BUILTIN), $(targets-for-builtin)) \ 538 - $(if $(KBUILD_MODULES), $(targets-for-modules)) \ 539 - $(subdir-ym) $(always-y) 540 - @: 541 - 542 530 # Single targets 543 531 # --------------------------------------------------------------------------- 544 532 ··· 555 567 556 568 targets += $(filter-out $(single-subdir-goals), $(MAKECMDGOALS)) 557 569 targets := $(filter-out $(PHONY), $(targets)) 570 + 571 + # Now that targets is fully known, include dtb rules if needed 572 + ifneq ($(need-dtbslist)$(dtb-y)$(dtb-)$(filter %.dtb %.dtb.o %.dtbo.o,$(targets)),) 573 + include $(srctree)/scripts/Makefile.dtbs 574 + endif 575 + 576 + # Build 577 + # Needs to be after the include of Makefile.dtbs, which updates always-y 578 + # --------------------------------------------------------------------------- 579 + 580 + $(obj)/: $(if $(KBUILD_BUILTIN), $(targets-for-builtin)) \ 581 + $(if $(KBUILD_MODULES), $(targets-for-modules)) \ 582 + $(subdir-ym) $(always-y) 583 + @: 558 584 559 585 # Read all saved command lines and dependencies for the $(targets) we 560 586 # may be building above, using $(if_changed{,_dep}). As an