Fix file listing logic for top-level parallel build
cover Fix file listing logic for top-level parallel build
Hello,
The current logic in pkg-generic.mk that calculates the list of files installed by packages is not compatible with top-level parallel build. Indeed, when package N-1 has been finished installing, we keep a file that is then used after package N is installed to calculate which files were installed by package N. This is inherently broken for top-level parallel build, and we have seen build failures caused by this in top-level parallel build mode.
For example:
http://autobuild.buildroot.net/results/4e6/4e60fa31b1cd08bc7fdf9c5dd3a3f4941e029ba3/build-end.log
shows:
Quoted 1 line
Quoted 1 line
Quoted 1 line
capnproto 0.7.0 Installing to staging directory
comm: /home/giuliobenetti/autobuild/run/instance-0/output-1/build/.files-list-staging.new: No such file or directory package/pkg-generic.mk:311: recipe for target '/home/giuliobenetti/autobuild/run/instance-0/output-1/build/c-ares-1.15.0/.stamp_staging_installed' failed
which is an example of that: the .new file has been deleted in the mean time by another package being built.
This paytch series fixes that by making the installed file calculation a per-package logic, until target-finalize which will use the per-package file lists and gather them in a single global file list.
Thanks!
Thomas
Thomas Petazzoni (2):
package/pkg-generic.mk: simplify step_pkg_size package/pkg-generic: make file list logic parallel build compatible
Makefile | 15 ++++------ package/pkg-generic.mk | 65 +++++++++++++++++++----------------------- 2 files changed, 36 insertions(+), 44 deletions(-)
Signature · 1 line
2.24.1
PATCH 1/2 package/pkg-generic.mk: simplify step_pkg_size
Use the same trick in step_pkg_size as the one used in check_bin_arch:
factorize the two $(filter ...) calls into one, checking in one step the step and whether it's the beginning or end of the step.
--- package/pkg-generic.mk | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
package/pkg-generic.mk +6 -6
@@ -95,12 +95,12 @@ define step_pkg_size_inner endef define step_pkg_size - $(if $(filter install-target,$(2)),\ - $(if $(filter end,$(1)),$(call step_pkg_size_inner,$(3),$(TARGET_DIR)))) - $(if $(filter install-staging,$(2)),\ - $(if $(filter end,$(1)),$(call step_pkg_size_inner,$(3),$(STAGING_DIR),-staging))) - $(if $(filter install-host,$(2)),\ - $(if $(filter end,$(1)),$(call step_pkg_size_inner,$(3),$(HOST_DIR),-host))) + $(if $(filter end-install-target,$(1)-$(2)),\ + $(call step_pkg_size_inner,$(3),$(TARGET_DIR))) + $(if $(filter end-install-staging,$(1)-$(2)),\ + $(call step_pkg_size_inner,$(3),$(STAGING_DIR),-staging)) + $(if $(filter end-install-host,$(1)-$(2)),\ + $(call step_pkg_size_inner,$(3),$(HOST_DIR),-host)) endef GLOBAL_INSTRUMENTATION_HOOKS += step_pkg_size
Signature · 1 line
2.24.1
PATCH 1/2 package/pkg-generic.mk: simplify step_pkg_size
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Thomas" == Thomas Petazzoni <[email protected]> writes:
Use the same trick in
step_pkg_sizeas the one used incheck_bin_arch:
factorize the two $(filter ...) calls into one, checking in one step the step and whether it's the beginning or end of the step.Signed-off-by Thomas Petazzoni <[email protected]>
Committed, thanks.
Signature · 1 line
Bye, Peter Korsgaard
PATCH 1/2 package/pkg-generic.mk: simplify step_pkg_size
Quoted 9 lines · On Thu, 27 Feb 2020 22:51:08 +0100 Peter Korsgaard <[email protected]> wrote:
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Thomas" == Thomas Petazzoni <[email protected]> writes:
Use the same trick in
step_pkg_sizeas the one used incheck_bin_arch:
factorize the two $(filter ...) calls into one, checking in one step the step and whether it's the beginning or end of the step.Signed-off-by Thomas Petazzoni <[email protected]>Committed, thanks.
Is this something you applied to master?
Even though PATCH 2/2 fixes some build issues, it is also a pretty radical change and I'm not sure it's a good idea to apply to master so late in the dev cycle.
Best regards,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
PATCH 1/2 package/pkg-generic.mk: simplify step_pkg_size
Quoted 11 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Thomas" == Thomas Petazzoni <[email protected]> writes:
Quoted 6 lines · On Thu, 27 Feb 2020 22:51:08 +0100 Peter Korsgaard <[email protected]> wrote:
Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Thomas" == Thomas Petazzoni <[email protected]> writes:
Use the same trick in
step_pkg_sizeas the one used incheck_bin_arch:
factorize the two $(filter ...) calls into one, checking in one step the step and whether it's the beginning or end of the step.
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Thomas Petazzoni <[email protected]>Committed, thanks.
Is this something you applied to master?
Yes.
Quoted 3 lines
Even though PATCH 2/2 fixes some build issues, it is also a pretty radical change and I'm not sure it's a good idea to apply to master so late in the dev cycle.
I know, but what is the alternative? Tell people to not use the toplevel parallel build feature? That also isn't really great.
Signature · 1 line
Bye, Peter Korsgaard
PATCH 2/2 package/pkg-generic: make file list logic parallel build compatible
In reply to Thomas PetazzoniThe current solution use to collect the list of files installed by packages does not work for top-level parallel build. Indeed, we rely on a file created after the installation of the previous package to build the list of files installed by the current package.
This works well when packages are built sequentially, but badly fails when using top-level parallel build.
More specifically, top-level parallel build can fail with:
comm: /home/thomas/buildroot/output/build/.files-list-host.new: No such file or directory
Because that file has been removed concurrently by the build process of another package.
This commit reworks the logic in a very straight-forward way. Before the installation of each package, we store the list of files that are already installed and store it in the package build directory. After the installation of each package, we store again that list of files, calculate the difference with the before file, and store that as the list of files installed by that package, still in the package build directory.
At the end of the build, in target-finalize we collect all the collected information into the global package file lists, that continue to be installed in the same location as before, with the same name.
There are however some differences:
(1) The files are no longer ordered in build order, but by alphabetic ordering of packages. Indeed, "build order" no longer makes any sense in the context of top-level parallel build.
(2) Some files which were incorrectly tracked are no longer tracked. For example, the toolchain package is a target package, but it installs files in $(HOST_DIR). In the previous logic, the files installed by the toolchain package in $(HOST_DIR) were incorrectly affected to the next host package that was installed after the toolchain package. With our new logic, those files are no longer tracked at all. To fix this, we would have to change the logic to scan HOST_DIR/TARGET_DIR/STAGING_DIR for all installation steps, not just for the install-host, install-target and install-staging steps respecitively. But the result was already incorrect anyway, and therefore this should be fixed separately.
Note that the check_bin_arch hook needs to be adjusted: it was using the global package-file-list.txt file, but this file is now created only at the very end of the build. So instead, we use the current package .file-list.txt file to know which packages have been installed by the current package in $(TARGET_DIR).
Fixes:
http://autobuild.buildroot.net/results/4e60fa31b1cd08bc7fdf9c5dd3a3f4941e029ba3/
--- Makefile | 15 +++++------ package/pkg-generic.mk | 59 +++++++++++++++++++----------------------- 2 files changed, 33 insertions(+), 41 deletions(-)
Makefile +6 -9
@@ -804,15 +804,12 @@ endif # merged /usr touch $(TARGET_DIR)/usr -# AFTER ALL FILE-CHANGING ACTIONS: -# Update timestamps in internal file list to fix attribution of files -# to packages on subsequent builds - @$(call step_pkg_size_file_list,$(TARGET_DIR)) - @$(call step_pkg_size_finalize) - @$(call step_pkg_size_file_list,$(STAGING_DIR),-staging) - @$(call step_pkg_size_finalize,-staging) - @$(call step_pkg_size_file_list,$(HOST_DIR),-host) - @$(call step_pkg_size_finalize,-host) + cat $(sort $(wildcard $(BUILD_DIR)/*/.files-list.txt)) > \ + $(BUILD_DIR)/packages-file-list.txt + cat $(sort $(wildcard $(BUILD_DIR)/*/.files-list-host.txt)) > \ + $(BUILD_DIR)/packages-file-list-host.txt + cat $(sort $(wildcard $(BUILD_DIR)/*/.files-list-staging.txt)) > \ + $(BUILD_DIR)/packages-file-list-staging.txt .PHONY: target-post-image target-post-image: $(TARGETS_ROOTFS) target-finalize staging-finalize
package/pkg-generic.mk +27 -32
84 lines not on this page · raw message
Signature · 1 line
2.24.1
PATCH 2/2 package/pkg-generic: make file list logic parallel build compatible
Quoted 55 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Thomas" == Thomas Petazzoni <[email protected]> writes:
The current solution use to collect the list of files installed by packages does not work for top-level parallel build. Indeed, we rely on a file created after the installation of the previous package to build the list of files installed by the current package.
This works well when packages are built sequentially, but badly fails when using top-level parallel build.
More specifically, top-level parallel build can fail with:
comm:
/home/thomas/buildroot/output/build/.files-list-host.new: No such file or directoryBecause that file has been removed concurrently by the build process of another package.
This commit reworks the logic in a very straight-forward way. Before the installation of each package, we store the list of files that are already installed and store it in the package build directory. After the installation of each package, we store again that list of files, calculate the difference with the before file, and store that as the list of files installed by that package, still in the package build directory.
At the end of the build, in target-finalize we collect all the collected information into the global package file lists, that continue to be installed in the same location as before, with the same name.
There are however some differences:
(1) The files are no longer ordered in build order, but by alphabetic ordering of packages. Indeed, "build order" no longer makes any sense in the context of top-level parallel build.
(2) Some files which were incorrectly tracked are no longer tracked. For example, the toolchain package is a target package, but it installs files in $(HOST_DIR). In the previous logic, the files installed by the toolchain package in $(HOST_DIR) were incorrectly affected to the next host package that was installed after the toolchain package. With our new logic, those files are no longer tracked at all. To fix this, we would have to change the logic to scan HOST_DIR/TARGET_DIR/STAGING_DIR for all installation steps, not just for the install-host, install-target and install-staging steps respecitively. But the result was already incorrect anyway, and therefore this should be fixed separately.
Note that the
check_bin_archhook needs to be adjusted: it was using the global package-file-list.txt file, but this file is now created only at the very end of the build. So instead, we use the current package .file-list.txt file to know which packages have been installed by the current package in $(TARGET_DIR).
Quoted 5 lines
Fixes:
http://autobuild.buildroot.net/results/4e60fa31b1cd08bc7fdf9c5dd3a3f4941e029ba3/
Signed-off-by Thomas Petazzoni <[email protected]>
Committed, thanks.
Signature · 1 line
Bye, Peter Korsgaard