diff mbox series

[v2] arm-trusted-firmware-mvebu: stop cluttering Image Builder

Message ID 20220831150340.275994-1-tmn505@terefe.re
State Superseded
Headers show
Series [v2] arm-trusted-firmware-mvebu: stop cluttering Image Builder | expand

Commit Message

Tomasz Maciej Nowak Aug. 31, 2022, 3:03 p.m. UTC
From: Tomasz Maciej Nowak <tmn505@gmail.com>

All contents of staging_dir/image are included in Image Builder (IB) in
case some binary needs to be included in final image. But in case of
this package, all sources are stored there and those clutter the final
tarball of IB for no reason. Those sources are not used during image
creation and are just dead weight. To put it in perspective, the IB for
21.02.0 is 158 MiB, 22.03.0-rc6 is 366 MiB and snapshot is over 620 MiB!
To fix it, put them in package build directory, so they won't end up
included in IB tarball. With that, the custom clean definition can be
removed, as the default one will take over.

Signed-off-by: Tomasz Maciej Nowak <tmn505@gmail.com>
Reviewed-by: Andre Heider <a.heider@gmail.com>
---
v1 -> v2
- as pointed by Andre, we can use default clean definition
- add his review tag

 .../boot/arm-trusted-firmware-mvebu/Makefile  | 40 +++++++------------
 1 file changed, 15 insertions(+), 25 deletions(-)

Comments

Hauke Mehrtens Sept. 6, 2022, 10:15 p.m. UTC | #1
On 8/31/22 17:03, Tomasz Maciej Nowak wrote:
> From: Tomasz Maciej Nowak <tmn505@gmail.com>
> 
> All contents of staging_dir/image are included in Image Builder (IB) in
> case some binary needs to be included in final image. But in case of
> this package, all sources are stored there and those clutter the final
> tarball of IB for no reason. Those sources are not used during image
> creation and are just dead weight. To put it in perspective, the IB for
> 21.02.0 is 158 MiB, 22.03.0-rc6 is 366 MiB and snapshot is over 620 MiB!
> To fix it, put them in package build directory, so they won't end up
> included in IB tarball. With that, the custom clean definition can be
> removed, as the default one will take over.
> 
> Signed-off-by: Tomasz Maciej Nowak <tmn505@gmail.com>
> Reviewed-by: Andre Heider <a.heider@gmail.com>
> ---
> v1 -> v2
> - as pointed by Andre, we can use default clean definition
> - add his review tag

I think the build times are much higher with this change compared to 
before. I haven't found the time to do real measurements. I used this 
configuration to test:
CONFIG_TARGET_mvebu=y
CONFIG_TARGET_mvebu_cortexa53=y
CONFIG_TARGET_mvebu_cortexa53_DEVICE_globalscale_espressobin=y

Hauke
Tomasz Maciej Nowak Sept. 7, 2022, 5:23 p.m. UTC | #2
W dniu 7.09.2022 o 00:15, Hauke Mehrtens pisze:
> On 8/31/22 17:03, Tomasz Maciej Nowak wrote:
>> From: Tomasz Maciej Nowak <tmn505@gmail.com>
>>
>> All contents of staging_dir/image are included in Image Builder (IB) in
>> case some binary needs to be included in final image. But in case of
>> this package, all sources are stored there and those clutter the final
>> tarball of IB for no reason. Those sources are not used during image
>> creation and are just dead weight. To put it in perspective, the IB for
>> 21.02.0 is 158 MiB, 22.03.0-rc6 is 366 MiB and snapshot is over 620 MiB!
>> To fix it, put them in package build directory, so they won't end up
>> included in IB tarball. With that, the custom clean definition can be
>> removed, as the default one will take over.
>>
>> Signed-off-by: Tomasz Maciej Nowak <tmn505@gmail.com>
>> Reviewed-by: Andre Heider <a.heider@gmail.com>
>> ---
>> v1 -> v2
>> - as pointed by Andre, we can use default clean definition
>> - add his review tag
> 
> I think the build times are much higher with this change compared to before.

Yes, that's correct, since all source is extracted/rebuilt for each variant.
The toolchain tarball is huge and it takes lot of time to extract. The second
culprit is cryptopp. It's rebuilt for each variant with one job.

> I haven't found the time to do real measurements. I used this configuration to test:
> CONFIG_TARGET_mvebu=y
> CONFIG_TARGET_mvebu_cortexa53=y
> CONFIG_TARGET_mvebu_cortexa53_DEVICE_globalscale_espressobin=y

I did measurements, before change:
time make -j4 package/arm-trusted-firmware-mvebu/compile
[ ... ]
real    13m17,046s
user    25m24,272s
sys     1m49,963s

with the change:
time make -j4 package/arm-trusted-firmware-mvebu/compile
[ ... ]
real    28m26,566s
user    79m45,906s
sys     4m6,547s

As You can see it's more than double. I also did test where $(BUILD_DIR)
was used:
time make -j4 package/arm-trusted-firmware-mvebu/compile
[ ... ]
real    13m19,462s
user    25m21,511s
sys     1m53,047s

which looks same as in current state (ignore spinning rust hiccups). Should
I use $(BUILD_DIR) for the sources?

> 
> Hauke

Regards, Tomek
Hauke Mehrtens Sept. 7, 2022, 8:57 p.m. UTC | #3
On 9/7/22 19:23, Tomasz Maciej Nowak wrote:
> W dniu 7.09.2022 o 00:15, Hauke Mehrtens pisze:
>> On 8/31/22 17:03, Tomasz Maciej Nowak wrote:
>>> From: Tomasz Maciej Nowak <tmn505@gmail.com>
>>>
>>> All contents of staging_dir/image are included in Image Builder (IB) in
>>> case some binary needs to be included in final image. But in case of
>>> this package, all sources are stored there and those clutter the final
>>> tarball of IB for no reason. Those sources are not used during image
>>> creation and are just dead weight. To put it in perspective, the IB for
>>> 21.02.0 is 158 MiB, 22.03.0-rc6 is 366 MiB and snapshot is over 620 MiB!
>>> To fix it, put them in package build directory, so they won't end up
>>> included in IB tarball. With that, the custom clean definition can be
>>> removed, as the default one will take over.
>>>
>>> Signed-off-by: Tomasz Maciej Nowak <tmn505@gmail.com>
>>> Reviewed-by: Andre Heider <a.heider@gmail.com>
>>> ---
>>> v1 -> v2
>>> - as pointed by Andre, we can use default clean definition
>>> - add his review tag
>>
>> I think the build times are much higher with this change compared to before.
> 
> Yes, that's correct, since all source is extracted/rebuilt for each variant.
> The toolchain tarball is huge and it takes lot of time to extract. The second
> culprit is cryptopp. It's rebuilt for each variant with one job.
> 
>> I haven't found the time to do real measurements. I used this configuration to test:
>> CONFIG_TARGET_mvebu=y
>> CONFIG_TARGET_mvebu_cortexa53=y
>> CONFIG_TARGET_mvebu_cortexa53_DEVICE_globalscale_espressobin=y
> 
> I did measurements, before change:
> time make -j4 package/arm-trusted-firmware-mvebu/compile
> [ ... ]
> real    13m17,046s
> user    25m24,272s
> sys     1m49,963s
> 
> with the change:
> time make -j4 package/arm-trusted-firmware-mvebu/compile
> [ ... ]
> real    28m26,566s
> user    79m45,906s
> sys     4m6,547s
> 
> As You can see it's more than double. I also did test where $(BUILD_DIR)
> was used:
> time make -j4 package/arm-trusted-firmware-mvebu/compile
> [ ... ]
> real    13m19,462s
> user    25m21,511s
> sys     1m53,047s
> 
> which looks same as in current state (ignore spinning rust hiccups). Should
> I use $(BUILD_DIR) for the sources?

did you mean a common folder in $(BUILD_DIR) with your $(BUILD_DIR) 
approach?

I think it would be better to place the bootloader toolchain in some 
common place and not duplicated for each variant.
Is cryptopp also common for all variant and only used on the host?

Maybe we can make this all a host package?

Hauke
Tomasz Maciej Nowak Sept. 7, 2022, 10:12 p.m. UTC | #4
W dniu 7.09.2022 o 22:57, Hauke Mehrtens pisze:
> On 9/7/22 19:23, Tomasz Maciej Nowak wrote:
>> W dniu 7.09.2022 o 00:15, Hauke Mehrtens pisze:
>>> On 8/31/22 17:03, Tomasz Maciej Nowak wrote:
>>>> From: Tomasz Maciej Nowak <tmn505@gmail.com>
>>>>
>>>> All contents of staging_dir/image are included in Image Builder (IB) in
>>>> case some binary needs to be included in final image. But in case of
>>>> this package, all sources are stored there and those clutter the final
>>>> tarball of IB for no reason. Those sources are not used during image
>>>> creation and are just dead weight. To put it in perspective, the IB for
>>>> 21.02.0 is 158 MiB, 22.03.0-rc6 is 366 MiB and snapshot is over 620 MiB!
>>>> To fix it, put them in package build directory, so they won't end up
>>>> included in IB tarball. With that, the custom clean definition can be
>>>> removed, as the default one will take over.
>>>>
>>>> Signed-off-by: Tomasz Maciej Nowak <tmn505@gmail.com>
>>>> Reviewed-by: Andre Heider <a.heider@gmail.com>
>>>> ---
>>>> v1 -> v2
>>>> - as pointed by Andre, we can use default clean definition
>>>> - add his review tag
>>>
>>> I think the build times are much higher with this change compared to before.
>>
>> Yes, that's correct, since all source is extracted/rebuilt for each variant.
>> The toolchain tarball is huge and it takes lot of time to extract. The second
>> culprit is cryptopp. It's rebuilt for each variant with one job.
>>
>>> I haven't found the time to do real measurements. I used this configuration to test:
>>> CONFIG_TARGET_mvebu=y
>>> CONFIG_TARGET_mvebu_cortexa53=y
>>> CONFIG_TARGET_mvebu_cortexa53_DEVICE_globalscale_espressobin=y
>>
>> I did measurements, before change:
>> time make -j4 package/arm-trusted-firmware-mvebu/compile
>> [ ... ]
>> real    13m17,046s
>> user    25m24,272s
>> sys     1m49,963s
>>
>> with the change:
>> time make -j4 package/arm-trusted-firmware-mvebu/compile
>> [ ... ]
>> real    28m26,566s
>> user    79m45,906s
>> sys     4m6,547s
>>
>> As You can see it's more than double. I also did test where $(BUILD_DIR)
>> was used:
>> time make -j4 package/arm-trusted-firmware-mvebu/compile
>> [ ... ]
>> real    13m19,462s
>> user    25m21,511s
>> sys     1m53,047s
>>
>> which looks same as in current state (ignore spinning rust hiccups). Should
>> I use $(BUILD_DIR) for the sources?
> 
> did you mean a common folder in $(BUILD_DIR) with your $(BUILD_DIR) approach?

Simply $(BUILD_DIR), which in our example translates to
"build_dir/target-aarch64_cortex-a53_musl" without any subdir. Naturally each
source is untarred to own subdir.

> I think it would be better to place the bootloader toolchain in some common place and not duplicated for each variant.

That's with current state using STAGING_DIR_IMAGE or with using BUILD_DIR,
so I'll use BUILD_DIR instead of PKG_BUILD_DIR.

> Is cryptopp also common for all variant and only used on the host?

Yes to both.

> Maybe we can make this all a host package?

That would make sense if we would untangle the whole TF-A build for mvebu,
which at current form, needs work, as we already discussed that [1]. Having
a second look at the build flow of it, I saw it's even more entangled than 
what I described in that topic. Anyway, lets keep it in current state, until
me/someone finds time to fix it.

1. http://lists.openwrt.org/pipermail/openwrt-devel/2020-October/031677.html

> Hauke

Regards, Tomek
diff mbox series

Patch

diff --git a/package/boot/arm-trusted-firmware-mvebu/Makefile b/package/boot/arm-trusted-firmware-mvebu/Makefile
index dba4836a6b98..ad7b14b1051f 100644
--- a/package/boot/arm-trusted-firmware-mvebu/Makefile
+++ b/package/boot/arm-trusted-firmware-mvebu/Makefile
@@ -108,12 +108,12 @@  TFA_TARGETS:= \
 	udpu
 
 TFA_MAKE_FLAGS += \
-		CROSS_CM3=$(STAGING_DIR_IMAGE)/$(CM3_GCC_NAME)-$(CM3_GCC_RELEASE)-$(CM3_GCC_VERSION)/bin/arm-none-eabi- \
+		CROSS_CM3=$(PKG_BUILD_DIR)/$(CM3_GCC_NAME)-$(CM3_GCC_RELEASE)-$(CM3_GCC_VERSION)/bin/arm-none-eabi- \
 		BL33=$(STAGING_DIR_IMAGE)/$(UBOOT)-u-boot.bin \
-		MV_DDR_PATH=$(STAGING_DIR_IMAGE)/$(MV_DDR_NAME) \
-		WTP=$(STAGING_DIR_IMAGE)/$(A3700_UTILS_NAME) \
-		WTMI_IMG=$(STAGING_DIR_IMAGE)/$(MOX_BB_NAME)-$(MOX_BB_RELEASE)/wtmi_app.bin \
-		CRYPTOPP_PATH=$(STAGING_DIR_IMAGE)/$(CRYPTOPP_NAME) \
+		MV_DDR_PATH=$(PKG_BUILD_DIR)/$(MV_DDR_NAME) \
+		WTP=$(PKG_BUILD_DIR)/$(A3700_UTILS_NAME) \
+		WTMI_IMG=$(PKG_BUILD_DIR)/$(MOX_BB_NAME)-$(MOX_BB_RELEASE)/wtmi_app.bin \
+		CRYPTOPP_PATH=$(PKG_BUILD_DIR)/$(CRYPTOPP_NAME) \
 		USE_COHERENT_MEM=0 \
 		FIP_ALIGN=0x100 \
 		DDR_TOPOLOGY=$(DDR_TOPOLOGY) \
@@ -188,15 +188,6 @@  else
 endif
 endef
 
-define Build/Clean
-	rm -rf \
-		$(STAGING_DIR_IMAGE)/$(CRYPTOPP_NAME) \
-		$(STAGING_DIR_IMAGE)/$(A3700_UTILS_NAME) \
-		$(STAGING_DIR_IMAGE)/$(MV_DDR_NAME) \
-		$(STAGING_DIR_IMAGE)/$(MOX_BB_NAME)-$(MOX_BB_RELEASE) \
-		$(STAGING_DIR_IMAGE)/$(CM3_GCC_NAME)-$(CM3_GCC_RELEASE)-$(CM3_GCC_VERSION)
-endef
-
 define Build/Prepare
 	# Download sources
 	$(eval $(call Download,a3700-utils))
@@ -207,23 +198,22 @@  define Build/Prepare
 
 	$(call Build/Prepare/Default,)
 
-	mkdir -p $(STAGING_DIR_IMAGE)
-	$(TAR) -C $(STAGING_DIR_IMAGE) -xf $(DL_DIR)/$(CRYPTOPP_SOURCE)
-	$(TAR) -C $(STAGING_DIR_IMAGE) -xf $(DL_DIR)/$(A3700_UTILS_SOURCE)
-	$(call PatchDir/Default,$(STAGING_DIR_IMAGE)/$(A3700_UTILS_NAME),./patches-a3700-utils)
-	$(TAR) -C $(STAGING_DIR_IMAGE) -xf $(DL_DIR)/$(MV_DDR_SOURCE)
-	$(call PatchDir/Default,$(STAGING_DIR_IMAGE)/$(MV_DDR_NAME),./patches-mv-ddr-marvell)
-	$(TAR) -C $(STAGING_DIR_IMAGE) -xf $(DL_DIR)/$(MOX_BB_SOURCE)
-	$(call PatchDir/Default,$(STAGING_DIR_IMAGE)/$(MOX_BB_NAME)-$(MOX_BB_RELEASE),./patches-mox-boot-builder)
-	$(TAR) -C $(STAGING_DIR_IMAGE) -xf $(DL_DIR)/$(CM3_GCC_SOURCE)
+	$(TAR) -C $(PKG_BUILD_DIR) -xf $(DL_DIR)/$(CRYPTOPP_SOURCE)
+	$(TAR) -C $(PKG_BUILD_DIR) -xf $(DL_DIR)/$(A3700_UTILS_SOURCE)
+	$(call PatchDir/Default,$(PKG_BUILD_DIR)/$(A3700_UTILS_NAME),./patches-a3700-utils)
+	$(TAR) -C $(PKG_BUILD_DIR) -xf $(DL_DIR)/$(MV_DDR_SOURCE)
+	$(call PatchDir/Default,$(PKG_BUILD_DIR)/$(MV_DDR_NAME),./patches-mv-ddr-marvell)
+	$(TAR) -C $(PKG_BUILD_DIR) -xf $(DL_DIR)/$(MOX_BB_SOURCE)
+	$(call PatchDir/Default,$(PKG_BUILD_DIR)/$(MOX_BB_NAME)-$(MOX_BB_RELEASE),./patches-mox-boot-builder)
+	$(TAR) -C $(PKG_BUILD_DIR) -xf $(DL_DIR)/$(CM3_GCC_SOURCE)
 endef
 
 define Build/Compile
 	+$(MAKE) \
-		CROSS_CM3=$(STAGING_DIR_IMAGE)/$(CM3_GCC_NAME)-$(CM3_GCC_RELEASE)-$(CM3_GCC_VERSION)/bin/arm-none-eabi- \
+		CROSS_CM3=$(PKG_BUILD_DIR)/$(CM3_GCC_NAME)-$(CM3_GCC_RELEASE)-$(CM3_GCC_VERSION)/bin/arm-none-eabi- \
 		WTMI_VERSION=$(MOX_BB_RELEASE) \
 		CRYPTOPP_PATH=$PWD/cryptopp/ \
-		-C $(STAGING_DIR_IMAGE)/$(MOX_BB_NAME)-$(MOX_BB_RELEASE) \
+		-C $(PKG_BUILD_DIR)/$(MOX_BB_NAME)-$(MOX_BB_RELEASE) \
 		wtmi_app.bin
 	$(call Build/Compile/Default)
 endef