Skip to content

Commit 712aba5

Browse files
committed
kbuild: avoid build error when single DTB is turned into composite DTB
As commit afa974b ("kbuild: add real-prereqs shorthand for $(filter-out FORCE,$^)") explained, $(real-prereqs) is not just a list of objects when linking a multi-object module. If a single-object module is turned into a multi-object module, $^ (and therefore $(real-prereqs) as well) contains header files recorded in the *.cmd file. Such headers must be filtered out. Now that a DTB can be built either from a single source or multiple source files, the same issue can occur. Consider the following scenario: First, foo.dtb is implemented as a single-blob device tree. The code looks something like this: [Sample Code 1] Makefile: dtb-y += foo.dtb foo.dts: #include <dt-bindings/gpio/gpio.h> /dts-v1/; / { }; When it is compiled, .foo.dtb.cmd records that foo.dtb depends on scripts/dtc/include-prefixes/dt-bindings/gpio/gpio.h. Later, foo.dtb is split into a base and an overlay. The code looks something like this: [Sample Code 2] Makefile: dtb-y += foo.dtb foo-dtbs := foo-base.dtb foo-addon.dtbo foo-base.dts: #include <dt-bindings/gpio/gpio.h> /dts-v1/; / { }; foo-addon.dtso: /dts-v1/; /plugin/; / { }; If you rebuild foo.dtb without 'make clean', you will get this error: Overlay 'scripts/dtc/include-prefixes/dt-bindings/gpio/gpio.h' is incomplete $(real-prereqs) contains not only foo-base.dtb and foo-addon.dtbo but also scripts/dtc/include-prefixes/dt-bindings/gpio/gpio.h, which is passed to scripts/dtc/fdtoverlay. Fixes: 15d16d6 ("kbuild: Add generic rule to apply fdtoverlay") Signed-off-by: Masahiro Yamada <[email protected]>
1 parent c041441 commit 712aba5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

scripts/Makefile.lib

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,12 @@ cmd_dtc = $(HOSTCC) -E $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ;
407407
-d $(depfile).dtc.tmp $(dtc-tmp) ; \
408408
cat $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile)
409409

410+
# NOTE:
411+
# Do not replace $(filter %.dtb %.dtbo, $^) with $(real-prereqs). When a single
412+
# DTB is turned into a multi-blob DTB, $^ will contain header file dependencies
413+
# recorded in the .*.cmd file.
410414
quiet_cmd_fdtoverlay = DTOVL $@
411-
cmd_fdtoverlay = $(objtree)/scripts/dtc/fdtoverlay -o $@ -i $(real-prereqs)
415+
cmd_fdtoverlay = $(objtree)/scripts/dtc/fdtoverlay -o $@ -i $(filter %.dtb %.dtbo, $^)
412416

413417
$(multi-dtb-y): FORCE
414418
$(call if_changed,fdtoverlay)

0 commit comments

Comments
 (0)