mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH v2 0/5] images: fix issues around misuse of FORCE
@ 2024-12-12  8:30 Ahmad Fatoum
  2024-12-12  8:30 ` [PATCH v2 1/5] images: don't compare filesizes if file didn't change Ahmad Fatoum
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Ahmad Fatoum @ 2024-12-12  8:30 UTC (permalink / raw)
  To: barebox

v1 was here: https://lore.barebox.org/barebox/20241202124404.1814203-1-a.fatoum@pengutronix.de/

This series only adapts the commit message titles compared to v1.
Since v1 however, changes to scripts/Kbuild.include have been merged,
which are required to avoid a build error when no BAREBOX_MAX_IMAGE_SIZE
is specified.

Ahmad Fatoum (5):
  images: don't compare filesizes if file didn't change
  images: don't check for missing FW if file didn't change
  images: fix missing FORCE prerequisite
  images: don't prelink if input file didn't change
  images: don't compute size if input file didn't change

 images/Makefile      | 23 ++++++++++++-----------
 scripts/Makefile.lib | 12 +++++++++---
 2 files changed, 21 insertions(+), 14 deletions(-)

-- 
2.39.5




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

* [PATCH v2 1/5] images: don't compare filesizes if file didn't change
  2024-12-12  8:30 [PATCH v2 0/5] images: fix issues around misuse of FORCE Ahmad Fatoum
@ 2024-12-12  8:30 ` Ahmad Fatoum
  2024-12-12  8:30 ` [PATCH v2 2/5] images: don't check for missing FW " Ahmad Fatoum
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Ahmad Fatoum @ 2024-12-12  8:30 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

If the input file didn't change, there is no point in repeating the file
size check and cluttering the log. Therefore use if_changed and remove
the extraneous semicolon, which make would then complain about.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 images/Makefile      | 2 +-
 scripts/Makefile.lib | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/images/Makefile b/images/Makefile
index 9007911278e2..80ea582728a5 100644
--- a/images/Makefile
+++ b/images/Makefile
@@ -78,7 +78,7 @@ $(obj)/%.pblb: $(obj)/%.pbl FORCE
 	$(call if_changed,objcopy_bin,$(*F))
 	$(Q)$(OBJCOPY) -O binary --only-section=.missing_fw $< $@.missing-firmware
 	$(Q)[ -s $@.missing-firmware ] || rm -f $@.missing-firmware
-	$(call cmd,check_file_size,$@,$(CONFIG_BAREBOX_MAX_IMAGE_SIZE))
+	$(call if_changed,check_file_size,$@,$(CONFIG_BAREBOX_MAX_IMAGE_SIZE))
 
 #
 # For each start symbol create three variables containing the
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index e8a85f3f1bf6..b698161f43f6 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -531,7 +531,7 @@ quiet_cmd_check_file_size = CHKFILESIZE $2
 	then								\
 		echo "$@ size $$size > maximum size $$max_size" >&2;	\
 		exit 1 ;						\
-	fi;
+	fi
 
 quiet_cmd_imximage__S_dcd= DCD_S   $@
 cmd_imximage_S_dcd=						\
-- 
2.39.5




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

* [PATCH v2 2/5] images: don't check for missing FW if file didn't change
  2024-12-12  8:30 [PATCH v2 0/5] images: fix issues around misuse of FORCE Ahmad Fatoum
  2024-12-12  8:30 ` [PATCH v2 1/5] images: don't compare filesizes if file didn't change Ahmad Fatoum
@ 2024-12-12  8:30 ` Ahmad Fatoum
  2024-12-12  8:30 ` [PATCH v2 3/5] images: fix missing FORCE prerequisite Ahmad Fatoum
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Ahmad Fatoum @ 2024-12-12  8:30 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

The information about the missing firmware is contained in an ELF
section and the ELF file is dependency to the $(obj)/%.pblb: $(obj)/%.pbl
rule.

We can thus don't need to rerun the missing firmware check if the
input file hasn't been changed since the last time.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 images/Makefile      | 3 +--
 scripts/Makefile.lib | 6 ++++++
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/images/Makefile b/images/Makefile
index 80ea582728a5..f781ecb59ccb 100644
--- a/images/Makefile
+++ b/images/Makefile
@@ -76,8 +76,7 @@ $(obj)/%.elf: $(pbl-lds) $(BAREBOX_PBL_OBJS) $(obj)/piggy.o $(obj)/sha_sum.o FOR
 
 $(obj)/%.pblb: $(obj)/%.pbl FORCE
 	$(call if_changed,objcopy_bin,$(*F))
-	$(Q)$(OBJCOPY) -O binary --only-section=.missing_fw $< $@.missing-firmware
-	$(Q)[ -s $@.missing-firmware ] || rm -f $@.missing-firmware
+	$(call if_changed,check_missing_fw,$@,$<)
 	$(call if_changed,check_file_size,$@,$(CONFIG_BAREBOX_MAX_IMAGE_SIZE))
 
 #
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index b698161f43f6..e2d0168550f8 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -533,6 +533,12 @@ quiet_cmd_check_file_size = CHKFILESIZE $2
 		exit 1 ;						\
 	fi
 
+# Check for missing firmware
+quiet_cmd_check_missing_fw = # no message as we collect info for later
+      cmd_check_missing_fw = set -e;						    \
+	$(OBJCOPY) -O binary --only-section=.missing_fw	$3 $2.missing-firmware;	    \
+	[ -s $2.missing-firmware ] || rm -f $2.missing-firmware
+
 quiet_cmd_imximage__S_dcd= DCD_S   $@
 cmd_imximage_S_dcd=						\
 (								\
-- 
2.39.5




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

* [PATCH v2 3/5] images: fix missing FORCE prerequisite
  2024-12-12  8:30 [PATCH v2 0/5] images: fix issues around misuse of FORCE Ahmad Fatoum
  2024-12-12  8:30 ` [PATCH v2 1/5] images: don't compare filesizes if file didn't change Ahmad Fatoum
  2024-12-12  8:30 ` [PATCH v2 2/5] images: don't check for missing FW " Ahmad Fatoum
@ 2024-12-12  8:30 ` Ahmad Fatoum
  2024-12-12  8:30 ` [PATCH v2 4/5] images: don't prelink if input file didn't change Ahmad Fatoum
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Ahmad Fatoum @ 2024-12-12  8:30 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

With the recent changes updating fixdep, we now get warnings when we
miss the FORCE prerequisite:

  images/Makefile:151: FORCE prerequisite is missing

Fix this by adding the missing FORCE and using if_changed as intended.
While at it, we also make the output a little less verbose, so the
SHIPPED/DELETE output is omitted:

  SHIPPED images/barebox-nxp-imx8mm-evk.img
  SHIPPED images/barebox-prt-prt8mm.img
  DELETE  images/barebox-tqma93xx.img
  images built:
  barebox-nxp-imx8mm-evk.img
  barebox-prt-prt8mm.img
  ** barebox-tqma93xx.img skipped due to missing firmware **

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 images/Makefile | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/images/Makefile b/images/Makefile
index f781ecb59ccb..5ce563a426ab 100644
--- a/images/Makefile
+++ b/images/Makefile
@@ -144,11 +144,13 @@ $(obj)/barebox.z: $(obj)/../barebox.bin FORCE
 
 missing_fw = $(strip $(wildcard $(obj)/$(FILE_$(@F)).missing-firmware $(basename $(obj)/$(FILE_$(@F))).missing-firmware))
 
+quiet_cmd_report_missing_fw = # no message as we collect info for later
+      cmd_report_missing_fw = $(if $2,cat $2 >$@.missing-firmware;$(cmd_delete),rm -f $@.missing-firmware;$(cmd_shipped))
+
 .SECONDEXPANSION:
-$(obj)/%.img: $(obj)/$$(FILE_$$(@F))
+$(obj)/%.img: $(obj)/$$(FILE_$$(@F)) FORCE
 	$(Q)if [ -z $(FILE_$(@F)) ]; then echo "FILE_$(@F) empty!"; false; fi
-	$(Q)$(if $(missing_fw),cat $(missing_fw) >$@.missing-firmware,rm -f $@.missing-firmware)
-	$(call if_changed,$(if $(missing_fw),delete,shipped))
+	$(call if_changed,report_missing_fw,$(missing_fw))
 
 board = $(srctree)/arch/$(SRCARCH)/boards
 objboard = $(objtree)/arch/$(SRCARCH)/boards
-- 
2.39.5




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

* [PATCH v2 4/5] images: don't prelink if input file didn't change
  2024-12-12  8:30 [PATCH v2 0/5] images: fix issues around misuse of FORCE Ahmad Fatoum
                   ` (2 preceding siblings ...)
  2024-12-12  8:30 ` [PATCH v2 3/5] images: fix missing FORCE prerequisite Ahmad Fatoum
@ 2024-12-12  8:30 ` Ahmad Fatoum
  2024-12-12  8:30 ` [PATCH v2 5/5] images: don't compute size " Ahmad Fatoum
  2024-12-16  8:20 ` [PATCH v2 0/5] images: fix issues around misuse of FORCE Sascha Hauer
  5 siblings, 0 replies; 7+ messages in thread
From: Ahmad Fatoum @ 2024-12-12  8:30 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

If the input file hasn't changed, there is no need to re-prelink it.
Thus turn the cmd into a if_changed and ensure it's not empty as
otherwise, make will raise an error.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 images/Makefile      | 4 ++--
 scripts/Makefile.lib | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/images/Makefile b/images/Makefile
index 5ce563a426ab..0ef2ea6bf6de 100644
--- a/images/Makefile
+++ b/images/Makefile
@@ -68,11 +68,11 @@ PBL_CPPFLAGS	+= -fdata-sections -ffunction-sections
 
 $(obj)/%.pbl: $(pbl-lds) $(BAREBOX_PBL_OBJS) $(obj)/piggy.o $(obj)/sha_sum.o FORCE
 	$(call if_changed,elf__,$(*F))
-	$(call cmd,prelink__)
+	$(call if_changed,prelink__)
 
 $(obj)/%.elf: $(pbl-lds) $(BAREBOX_PBL_OBJS) $(obj)/piggy.o $(obj)/sha_sum.o FORCE
 	$(call if_changed,elf__,$(*F))
-	$(call cmd,prelink__)
+	$(call if_changed,prelink__)
 
 $(obj)/%.pblb: $(obj)/%.pbl FORCE
 	$(call if_changed,objcopy_bin,$(*F))
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index e2d0168550f8..19aa506dc645 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -282,7 +282,7 @@ quiet_cmd_prelink__ = PRELINK $@
 endif
 
 quiet_cmd_prelink__ ?=
-      cmd_prelink__ ?=
+      cmd_prelink__ ?= :
 
 # Linking
 # ---------------------------------------------------------------------------
-- 
2.39.5




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

* [PATCH v2 5/5] images: don't compute size if input file didn't change
  2024-12-12  8:30 [PATCH v2 0/5] images: fix issues around misuse of FORCE Ahmad Fatoum
                   ` (3 preceding siblings ...)
  2024-12-12  8:30 ` [PATCH v2 4/5] images: don't prelink if input file didn't change Ahmad Fatoum
@ 2024-12-12  8:30 ` Ahmad Fatoum
  2024-12-16  8:20 ` [PATCH v2 0/5] images: fix issues around misuse of FORCE Sascha Hauer
  5 siblings, 0 replies; 7+ messages in thread
From: Ahmad Fatoum @ 2024-12-12  8:30 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

If the input file didn't change, there is no point in repeating image
size checks and cluttering the log. Therefore use if_changed and remove
the extraneous semicolon, which make would then complain about.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 images/Makefile      | 6 +++---
 scripts/Makefile.lib | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/images/Makefile b/images/Makefile
index 0ef2ea6bf6de..a74aa6023e73 100644
--- a/images/Makefile
+++ b/images/Makefile
@@ -100,15 +100,15 @@ $(obj)/%.pblb: $(obj)/%.pbl FORCE
 # code/memory/image for this PBL may get. Check these values.
 #
 	$(if $(MAX_PBL_CODE_SIZE_$*), \
-		$(call cmd,check_size, $(PBL_CODE_SIZE_$*), $(MAX_PBL_CODE_SIZE_$*)) \
+		$(call if_changed,check_size,$(PBL_CODE_SIZE_$*),$(MAX_PBL_CODE_SIZE_$*)) \
 	)
 
 	$(if $(MAX_PBL_MEMORY_SIZE_$*), \
-		$(call cmd,check_size, $(PBL_MEMORY_SIZE_$*), $(MAX_PBL_MEMORY_SIZE_$*)) \
+		$(call if_changed,check_size,$(PBL_MEMORY_SIZE_$*),$(MAX_PBL_MEMORY_SIZE_$*)) \
 	)
 
 	$(if $(MAX_PBL_IMAGE_SIZE_$*), \
-		$(call cmd,check_size, $(PBL_IMAGE_SIZE_$*), $(MAX_PBL_IMAGE_SIZE_$*)) \
+		$(call if_changed,check_size,$(PBL_IMAGE_SIZE_$*),$(MAX_PBL_IMAGE_SIZE_$*)) \
 	)
 
 $(obj)/%.s: $(obj)/% FORCE
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 19aa506dc645..c32adf07cc51 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -520,7 +520,7 @@ quiet_cmd_check_size = CHKSIZE $2
 	then								\
 		echo "$@ size $$size > maximum size $$max_size" >&2;	\
 		exit 1 ;						\
-	fi;
+	fi
 
 # Check size of a file
 quiet_cmd_check_file_size = CHKFILESIZE $2
-- 
2.39.5




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

* Re: [PATCH v2 0/5] images: fix issues around misuse of FORCE
  2024-12-12  8:30 [PATCH v2 0/5] images: fix issues around misuse of FORCE Ahmad Fatoum
                   ` (4 preceding siblings ...)
  2024-12-12  8:30 ` [PATCH v2 5/5] images: don't compute size " Ahmad Fatoum
@ 2024-12-16  8:20 ` Sascha Hauer
  5 siblings, 0 replies; 7+ messages in thread
From: Sascha Hauer @ 2024-12-16  8:20 UTC (permalink / raw)
  To: barebox, Ahmad Fatoum


On Thu, 12 Dec 2024 09:30:28 +0100, Ahmad Fatoum wrote:
> v1 was here: https://lore.barebox.org/barebox/20241202124404.1814203-1-a.fatoum@pengutronix.de/
> 
> This series only adapts the commit message titles compared to v1.
> Since v1 however, changes to scripts/Kbuild.include have been merged,
> which are required to avoid a build error when no BAREBOX_MAX_IMAGE_SIZE
> is specified.
> 
> [...]

Applied, thanks!

[1/5] images: don't compare filesizes if file didn't change
      https://git.pengutronix.de/cgit/barebox/commit/?id=8ddc2d799b4a (link may not be stable)
[2/5] images: don't check for missing FW if file didn't change
      https://git.pengutronix.de/cgit/barebox/commit/?id=c2e320f6b243 (link may not be stable)
[3/5] images: fix missing FORCE prerequisite
      https://git.pengutronix.de/cgit/barebox/commit/?id=c718cfb50ca2 (link may not be stable)
[4/5] images: don't prelink if input file didn't change
      https://git.pengutronix.de/cgit/barebox/commit/?id=4c31478919f5 (link may not be stable)
[5/5] images: don't compute size if input file didn't change
      https://git.pengutronix.de/cgit/barebox/commit/?id=912696b571bb (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




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

end of thread, other threads:[~2024-12-16  8:21 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-12-12  8:30 [PATCH v2 0/5] images: fix issues around misuse of FORCE Ahmad Fatoum
2024-12-12  8:30 ` [PATCH v2 1/5] images: don't compare filesizes if file didn't change Ahmad Fatoum
2024-12-12  8:30 ` [PATCH v2 2/5] images: don't check for missing FW " Ahmad Fatoum
2024-12-12  8:30 ` [PATCH v2 3/5] images: fix missing FORCE prerequisite Ahmad Fatoum
2024-12-12  8:30 ` [PATCH v2 4/5] images: don't prelink if input file didn't change Ahmad Fatoum
2024-12-12  8:30 ` [PATCH v2 5/5] images: don't compute size " Ahmad Fatoum
2024-12-16  8:20 ` [PATCH v2 0/5] images: fix issues around misuse of FORCE Sascha Hauer

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