* [PATCH master 1/2] kbuild: images/Makefile: fix broken if_changed usage
@ 2025-08-14 20:22 Ahmad Fatoum
2025-08-14 20:22 ` [PATCH master 2/2] RISC-V: stacktrace: add missing header for eprintf Ahmad Fatoum
0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2025-08-14 20:22 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
if_changed also triggers when the command line changes by comparing the
command executed against what was written last time.
This necessarily means that there may only be a single if_changed called
per target, a rule which we violated.
This led to breakage on RISC-V, because every build triggered a relink
of the PBLs, but only every second build executed cmd_prelink__.
Switch over to if_changed_rule to fix this. This also means we need to
move the comments out of the define, so they aren't printed.
Fixes: 912696b571bb ("images: don't compute size if input file didn't change")
Fixes: 4c31478919f5 ("images: don't prelink if input file didn't change")
Fixes: c2e320f6b243 ("images: don't check for missing FW if file didn't change")
Fixes: 8ddc2d799b4a ("images: don't compare filesizes if file didn't change")
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
images/Makefile | 38 +++++++++++++++++++++++---------------
1 file changed, 23 insertions(+), 15 deletions(-)
diff --git a/images/Makefile b/images/Makefile
index e20d11e1501a..03c7fdc0240b 100644
--- a/images/Makefile
+++ b/images/Makefile
@@ -69,19 +69,20 @@ quiet_cmd_elf__ ?= LD $@
PBL_CPPFLAGS += -fdata-sections -ffunction-sections
+define rule_elf
+ $(call cmd,elf__,$(*F))
+ $(call cmd,prelink__)
+endef
+
$(obj)/%.pbl: $(pbl-lds) $(BAREBOX_PBL_OBJS) $(BAREBOX_PIGGY_OBJS) FORCE
- $(call if_changed,elf__,$(*F))
- $(call if_changed,prelink__)
+ $(call if_changed_rule,elf)
$(obj)/%.elf: $(pbl-lds) $(BAREBOX_PBL_OBJS) $(BAREBOX_PIGGY_OBJS) FORCE
- $(call if_changed,elf__,$(*F))
- $(call if_changed,prelink__)
+ $(call if_changed_rule,elf)
-$(obj)/%.pblb: $(obj)/%.pbl FORCE
- $(call if_changed,objcopy_bin,$(*F))
- $(call if_changed,check_missing_fw,$@,$<)
- $(call if_changed,check_file_size,$@,$(CONFIG_BAREBOX_MAX_IMAGE_SIZE))
+# Convert the ELF into a linear binary, check for missing firmware
+# and verify file sizes:
#
# For each start symbol create three variables containing the
# relevant sizes in the image:
@@ -91,6 +92,13 @@ $(obj)/%.pblb: $(obj)/%.pbl FORCE
# PBL_IMAGE_SIZE_$(symbol) - contains the full image size including the
# compressed payload
#
+# if MAX_PBL_xxx_SIZE_$(symbol) is defined it contains the maximum size the
+# code/memory/image for this PBL may get. Check these values.
+define rule_pblb
+ $(call cmd,objcopy_bin,$(*F))
+ $(call cmd,check_missing_fw,$@,$<)
+ $(call cmd,check_file_size,$@,$(CONFIG_BAREBOX_MAX_IMAGE_SIZE))
+
$(eval PBL_CODE_SIZE_$* = \
$(shell $(srctree)/scripts/extract_symbol_offset pbl_code_size $^))
$(eval PBL_MEMORY_SIZE_$*= \
@@ -98,21 +106,21 @@ $(obj)/%.pblb: $(obj)/%.pbl FORCE
$(eval PBL_IMAGE_SIZE_$*= \
$(shell $(srctree)/scripts/extract_symbol_offset pbl_image_size $^))
-#
-# if MAX_PBL_xxx_SIZE_$(symbol) is defined it contains the maximum size the
-# code/memory/image for this PBL may get. Check these values.
-#
$(if $(MAX_PBL_CODE_SIZE_$*), \
- $(call if_changed,check_size,$(PBL_CODE_SIZE_$*),$(MAX_PBL_CODE_SIZE_$*)) \
+ $(call cmd,check_size,$(PBL_CODE_SIZE_$*),$(MAX_PBL_CODE_SIZE_$*)) \
)
$(if $(MAX_PBL_MEMORY_SIZE_$*), \
- $(call if_changed,check_size,$(PBL_MEMORY_SIZE_$*),$(MAX_PBL_MEMORY_SIZE_$*)) \
+ $(call cmd,check_size,$(PBL_MEMORY_SIZE_$*),$(MAX_PBL_MEMORY_SIZE_$*)) \
)
$(if $(MAX_PBL_IMAGE_SIZE_$*), \
- $(call if_changed,check_size,$(PBL_IMAGE_SIZE_$*),$(MAX_PBL_IMAGE_SIZE_$*)) \
+ $(call cmd,check_size,$(PBL_IMAGE_SIZE_$*),$(MAX_PBL_IMAGE_SIZE_$*)) \
)
+endef
+
+$(obj)/%.pblb: $(obj)/%.pbl FORCE
+ $(call if_changed_rule,pblb)
$(obj)/%.s: $(obj)/% FORCE
$(call if_changed,disasm)
--
2.39.5
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH master 2/2] RISC-V: stacktrace: add missing header for eprintf
2025-08-14 20:22 [PATCH master 1/2] kbuild: images/Makefile: fix broken if_changed usage Ahmad Fatoum
@ 2025-08-14 20:22 ` Ahmad Fatoum
0 siblings, 0 replies; 2+ messages in thread
From: Ahmad Fatoum @ 2025-08-14 20:22 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
eprintf is defined in stdio.h, which was not included.
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
arch/riscv/lib/stacktrace.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/riscv/lib/stacktrace.c b/arch/riscv/lib/stacktrace.c
index 7cf102a06fe0..30daec7caad2 100644
--- a/arch/riscv/lib/stacktrace.c
+++ b/arch/riscv/lib/stacktrace.c
@@ -9,6 +9,7 @@
#include <linux/kernel.h>
#include <printf.h>
+#include <stdio.h>
#include <asm/unwind.h>
#include <asm/ptrace.h>
#include <asm-generic/memory_layout.h>
--
2.39.5
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-08-14 20:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-08-14 20:22 [PATCH master 1/2] kbuild: images/Makefile: fix broken if_changed usage Ahmad Fatoum
2025-08-14 20:22 ` [PATCH master 2/2] RISC-V: stacktrace: add missing header for eprintf Ahmad Fatoum
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox