Linux kbuild/kconfig development
 help / color / mirror / Atom feed
* [PATCH v2] kbuild: fix compilation of dtb specified on command-line without make rule
@ 2025-11-26 10:00 Thomas De Schampheleire
  2025-12-01 17:36 ` Rob Herring
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Thomas De Schampheleire @ 2025-11-26 10:00 UTC (permalink / raw)
  To: linux-kbuild
  Cc: Thomas De Schampheleire, Rob Herring, Masahiro Yamada,
	Nathan Chancellor, Nicolas Schier, linux-kernel

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>
---
v2: fix 'make dtbs' by moving the 'Build' rule along

 scripts/Makefile.build | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index d0ee33a487be..82a6e328ceee 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -527,18 +527,6 @@ ifneq ($(userprogs),)
 include $(srctree)/scripts/Makefile.userprogs
 endif
 
-ifneq ($(need-dtbslist)$(dtb-y)$(dtb-)$(filter %.dtb %.dtb.o %.dtbo.o,$(targets)),)
-include $(srctree)/scripts/Makefile.dtbs
-endif
-
-# Build
-# ---------------------------------------------------------------------------
-
-$(obj)/: $(if $(KBUILD_BUILTIN), $(targets-for-builtin)) \
-	 $(if $(KBUILD_MODULES), $(targets-for-modules)) \
-	 $(subdir-ym) $(always-y)
-	@:
-
 # Single targets
 # ---------------------------------------------------------------------------
 
@@ -568,6 +556,20 @@ FORCE:
 targets += $(filter-out $(single-subdir-goals), $(MAKECMDGOALS))
 targets := $(filter-out $(PHONY), $(targets))
 
+# Now that targets is fully known, include dtb rules if needed
+ifneq ($(need-dtbslist)$(dtb-y)$(dtb-)$(filter %.dtb %.dtb.o %.dtbo.o,$(targets)),)
+include $(srctree)/scripts/Makefile.dtbs
+endif
+
+# Build
+# Needs to be after the include of Makefile.dtbs, which updates always-y
+# ---------------------------------------------------------------------------
+
+$(obj)/: $(if $(KBUILD_BUILTIN), $(targets-for-builtin)) \
+	 $(if $(KBUILD_MODULES), $(targets-for-modules)) \
+	 $(subdir-ym) $(always-y)
+	@:
+
 # Read all saved command lines and dependencies for the $(targets) we
 # may be building above, using $(if_changed{,_dep}). As an
 # optimization, we don't need to read them if the target does not

base-commit: deab487e0f9b39ae4603e22d7d00908ebfc9753c
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] kbuild: fix compilation of dtb specified on command-line without make rule
  2025-11-26 10:00 [PATCH v2] kbuild: fix compilation of dtb specified on command-line without make rule Thomas De Schampheleire
@ 2025-12-01 17:36 ` Rob Herring
  2025-12-02 20:09 ` Nathan Chancellor
  2025-12-27 20:10 ` Nicolas Schier
  2 siblings, 0 replies; 4+ messages in thread
From: Rob Herring @ 2025-12-01 17:36 UTC (permalink / raw)
  To: Thomas De Schampheleire
  Cc: linux-kbuild, Masahiro Yamada, Nathan Chancellor, Nicolas Schier,
	linux-kernel

On Wed, Nov 26, 2025 at 4:00 AM Thomas De Schampheleire
<thomas.de_schampheleire@nokia.com> wrote:
>
> 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>
> ---
> v2: fix 'make dtbs' by moving the 'Build' rule along
>
>  scripts/Makefile.build | 26 ++++++++++++++------------
>  1 file changed, 14 insertions(+), 12 deletions(-)

Acked-by: Rob Herring (Arm) <robh@kernel.org>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] kbuild: fix compilation of dtb specified on command-line without make rule
  2025-11-26 10:00 [PATCH v2] kbuild: fix compilation of dtb specified on command-line without make rule Thomas De Schampheleire
  2025-12-01 17:36 ` Rob Herring
@ 2025-12-02 20:09 ` Nathan Chancellor
  2025-12-27 20:10 ` Nicolas Schier
  2 siblings, 0 replies; 4+ messages in thread
From: Nathan Chancellor @ 2025-12-02 20:09 UTC (permalink / raw)
  To: Thomas De Schampheleire
  Cc: linux-kbuild, Rob Herring, Masahiro Yamada, Nicolas Schier,
	linux-kernel

On Wed, Nov 26, 2025 at 11:00:16AM +0100, Thomas De Schampheleire wrote:
> 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>

>  scripts/Makefile.build | 26 ++++++++++++++------------
>  1 file changed, 14 insertions(+), 12 deletions(-)
> 
> diff --git a/scripts/Makefile.build b/scripts/Makefile.build
> index d0ee33a487be..82a6e328ceee 100644
> --- a/scripts/Makefile.build
> +++ b/scripts/Makefile.build
> @@ -527,18 +527,6 @@ ifneq ($(userprogs),)
>  include $(srctree)/scripts/Makefile.userprogs
>  endif
>  
> -ifneq ($(need-dtbslist)$(dtb-y)$(dtb-)$(filter %.dtb %.dtb.o %.dtbo.o,$(targets)),)
> -include $(srctree)/scripts/Makefile.dtbs
> -endif
> -
> -# Build
> -# ---------------------------------------------------------------------------
> -
> -$(obj)/: $(if $(KBUILD_BUILTIN), $(targets-for-builtin)) \
> -	 $(if $(KBUILD_MODULES), $(targets-for-modules)) \
> -	 $(subdir-ym) $(always-y)
> -	@:
> -
>  # Single targets
>  # ---------------------------------------------------------------------------
>  
> @@ -568,6 +556,20 @@ FORCE:
>  targets += $(filter-out $(single-subdir-goals), $(MAKECMDGOALS))
>  targets := $(filter-out $(PHONY), $(targets))
>  
> +# Now that targets is fully known, include dtb rules if needed
> +ifneq ($(need-dtbslist)$(dtb-y)$(dtb-)$(filter %.dtb %.dtb.o %.dtbo.o,$(targets)),)
> +include $(srctree)/scripts/Makefile.dtbs
> +endif
> +
> +# Build
> +# Needs to be after the include of Makefile.dtbs, which updates always-y
> +# ---------------------------------------------------------------------------
> +
> +$(obj)/: $(if $(KBUILD_BUILTIN), $(targets-for-builtin)) \
> +	 $(if $(KBUILD_MODULES), $(targets-for-modules)) \
> +	 $(subdir-ym) $(always-y)
> +	@:
> +
>  # Read all saved command lines and dependencies for the $(targets) we
>  # may be building above, using $(if_changed{,_dep}). As an
>  # optimization, we don't need to read them if the target does not
> 
> base-commit: deab487e0f9b39ae4603e22d7d00908ebfc9753c
> -- 
> 2.51.0
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] kbuild: fix compilation of dtb specified on command-line without make rule
  2025-11-26 10:00 [PATCH v2] kbuild: fix compilation of dtb specified on command-line without make rule Thomas De Schampheleire
  2025-12-01 17:36 ` Rob Herring
  2025-12-02 20:09 ` Nathan Chancellor
@ 2025-12-27 20:10 ` Nicolas Schier
  2 siblings, 0 replies; 4+ messages in thread
From: Nicolas Schier @ 2025-12-27 20:10 UTC (permalink / raw)
  To: linux-kbuild, Thomas De Schampheleire
  Cc: Nicolas Schier, Rob Herring, Masahiro Yamada, Nathan Chancellor,
	linux-kernel


On Wed, 26 Nov 2025 11:00:16 +0100, Thomas De Schampheleire wrote:
> 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
> 
> [...]

Applied to kbuild-next, thanks!

[1/1] kbuild: fix compilation of dtb specified on command-line without make rule
      commit: b08fc4d0ec2466558f6d5511434efdfabbddf2a6
      https://git.kernel.org/kbuild/c/b08fc4d0ec24

Best regards,
-- 
Nicolas


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-12-27 21:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-26 10:00 [PATCH v2] kbuild: fix compilation of dtb specified on command-line without make rule Thomas De Schampheleire
2025-12-01 17:36 ` Rob Herring
2025-12-02 20:09 ` Nathan Chancellor
2025-12-27 20:10 ` Nicolas Schier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox