[PATCH v2 2/2] kbuild: Use relative paths in generated .incbin directives

Simon Glass sjg at chromium.org
Thu Mar 26 12:54:57 CET 2026


The generated .S files for fonts and splash screens use .incbin with the
full prerequisite path. When building with O= this bakes an absolute
path into the .S file. If the build directory is later used on a
different machine (e.g. in a container), the assembler cannot find the
source file.

Use $(src)/$(notdir $<) instead of $< so the .incbin directive contains
a source-relative path like drivers/video/fonts/nimbus_sans_l_regular.ttf
rather than an absolute one. Add per-file AFLAGS with -Wa,-I$(srctree)
in the subdirectory Makefiles so the assembler can resolve these paths,
keeping scripts/Makefile.lib free of U-Boot-specific changes.

The EFI rule is left unchanged since its prerequisite is a generated
file in the build directory, like the DTB and DTBO rules.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

Changes in v2:
- Move U-Boot .incbin rules to Makefile.lib-u-boot first (previous patch)
- Drop the EFI .incbin change since .efi files are generated, not source
- Use per-file AFLAGS instead of modifying a_flags in Makefile.lib

 drivers/video/Makefile       | 1 +
 drivers/video/fonts/Makefile | 8 ++++++++
 scripts/Makefile.lib-u-boot  | 4 ++--
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index 984768ea156..020b6680345 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -25,6 +25,7 @@ obj-$(CONFIG_PANEL_HX8238D) += hx8238d.o
 obj-$(CONFIG_$(PHASE_)SIMPLE_PANEL) += simple_panel.o
 
 obj-$(CONFIG_VIDEO_LOGO) += u_boot_logo.o
+AFLAGS_u_boot_logo.o += -Wa,-I$(srctree)
 obj-$(CONFIG_$(PHASE_)BMP) += bmp.o
 
 endif
diff --git a/drivers/video/fonts/Makefile b/drivers/video/fonts/Makefile
index 1111f92a2c6..a2ac4bd40b3 100644
--- a/drivers/video/fonts/Makefile
+++ b/drivers/video/fonts/Makefile
@@ -8,3 +8,11 @@ obj-$(CONFIG_CONSOLE_TRUETYPE_ANKACODER) += ankacoder_c75_r.o
 obj-$(CONFIG_CONSOLE_TRUETYPE_RUFSCRIPT) += rufscript010.o
 obj-$(CONFIG_CONSOLE_TRUETYPE_CANTORAONE) += cantoraone_regular.o
 obj-$(CONFIG_CONSOLE_TRUETYPE_DEJAVU) += dejavu_mono.o
+
+# The .S files generated from .ttf fonts use .incbin with a source-relative
+# path, so tell the assembler where to find the source tree.
+AFLAGS_nimbus_sans_l_regular.o += -Wa,-I$(srctree)
+AFLAGS_ankacoder_c75_r.o += -Wa,-I$(srctree)
+AFLAGS_rufscript010.o += -Wa,-I$(srctree)
+AFLAGS_cantoraone_regular.o += -Wa,-I$(srctree)
+AFLAGS_dejavu_mono.o += -Wa,-I$(srctree)
diff --git a/scripts/Makefile.lib-u-boot b/scripts/Makefile.lib-u-boot
index c55f8d8e0c3..4c4de359fe5 100644
--- a/scripts/Makefile.lib-u-boot
+++ b/scripts/Makefile.lib-u-boot
@@ -14,7 +14,7 @@ cmd_S_ttf=						\
 	echo '.balign 16';				\
 	echo '.global __ttf_$(*F)_begin';		\
 	echo '__ttf_$(*F)_begin:';			\
-	echo '.incbin "$<" ';				\
+	echo '.incbin "$(src)/$(notdir $<)" ';				\
 	echo '__ttf_$(*F)_end:';			\
 	echo '.global __ttf_$(*F)_end';			\
 	echo '.balign 16';				\
@@ -34,7 +34,7 @@ cmd_S_splash=						\
 	echo '.balign 16';				\
 	echo '.global __splash_$(*F)_begin';		\
 	echo '__splash_$(*F)_begin:';			\
-	echo '.incbin "$<" ';				\
+	echo '.incbin "$(src)/$(notdir $<)" ';				\
 	echo '__splash_$(*F)_end:';			\
 	echo '.global __splash_$(*F)_end';		\
 	echo '.balign 16';				\
-- 
2.43.0

base-commit: 1ffc541eafc96d5eebcf837ab892dccec3b93568
branch: font-us2


More information about the U-Boot mailing list