[PATCH master] kbuild: do not descend into images/ twice

Ahmad Fatoum a.fatoum at pengutronix.de
Thu Sep 4 01:14:58 PDT 2025


By having a dependency on images/barebox-dt-2nd.img for the symlink we
may hit a race where the rule for barebox-dt-2nd.img inside in
images/Makefile is executed twice leading to build breakage.

Fix this by changing the dependency in the top-level Makefile to be on
images/, so make doesn't attempt descending twice into images/Makefile
in parallel.

Fixes: a1f893cc16e6 ("kbuild: collect compatibility symlink creation in symlink-y")
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 Makefile | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 7620c47cf459..169b750fe151 100644
--- a/Makefile
+++ b/Makefile
@@ -829,6 +829,7 @@ images/%: $(BAREBOX_PROPER) FORCE
 
 ifdef CONFIG_PBL_IMAGE
 SYMLINK_TARGET_barebox.efi = images/barebox-dt-2nd.img
+SYMLINK_DEP_barebox.efi = images
 symlink-$(CONFIG_EFI_STUB) += barebox.efi
 all: $(BAREBOX_PROPER) images
 else
@@ -840,8 +841,8 @@ endif
 all: $(symlink-y)
 
 .SECONDEXPANSION:
-$(symlink-y): $$(SYMLINK_TARGET_$$(@F)) FORCE
-	$(call if_changed,symlink_quiet)
+$(symlink-y): $$(or $$(SYMLINK_DEP_$$(@F)),$$(SYMLINK_TARGET_$$(@F))) FORCE
+	@ln -fsn --relative $(SYMLINK_TARGET_$(@F)) $@
 
 common-$(CONFIG_PBL_IMAGE)	+= pbl/
 common-$(CONFIG_DEFAULT_ENVIRONMENT) += defaultenv/
-- 
2.47.2




More information about the barebox mailing list