Race during Busybox parallel build
cover Race during Busybox parallel build
There is an occasional race observed when building Busybox with parallel make. It has been discussed on Busybox mailing list, see:
https://www.mail-archive.com/[email protected]/msg23244.html
There were several Busybox attempts to fix this issue:0dddbc1a59795a77679d8c5ef48a2795cb470563 ("build system: always rewrite NUM_APPLETS.h") d8e61bbf13d0cf38d477255cfd5dc71c5d51d575 ("build system: different fix for include/applet_tables.h/include/NUM_APPLETS.h")
Although the above patches alleviated the problem somewhat (also included in this patches), the race can still be observed. The error is consistently the same:
libbb/appletlib.c:164:13: error: 'NUM_APPLETS' undeclared (first use in this function)
while (i < NUM_APPLETS) {
The reason is the include file where NUM_APPLETS is defined is not yet generated (or is being modified) at the time libbb/appletlib.c is compiled.
The attached patch fixes the problem by assuring libb is compiled as the last directory.
Juro Bystricky (1):
busybox: Avoid race building libbb
.../busybox-kbuild-race-fix-commit-d8e61bb.patch | 45 +++++++++++++++ .../commit-applet_tables-fix-commit-0dddbc1.patch | 53 ++++++++++++++++++ .../busybox/busybox/makefile-libbb-race.patch | 34 +++++++++++ .../busybox/busybox/parallel-make-fix.patch | 65 ---------------------- meta/recipes-core/busybox/busybox_1.24.1.bb | 4 +- 5 files changed, 135 insertions(+), 66 deletions(-) create mode 100644 meta/recipes-core/busybox/busybox/busybox-kbuild-race-fix-commit-d8e61bb.patch create mode 100644 meta/recipes-core/busybox/busybox/commit-applet_tables-fix-commit-0dddbc1.patch create mode 100644 meta/recipes-core/busybox/busybox/makefile-libbb-race.patch delete mode 100644 meta/recipes-core/busybox/busybox/parallel-make-fix.patch
Signature · 1 line
2.7.4
PATCH 1/1 busybox: Avoid race building libbb
When building busybox, an occasional error was observed. The error is consistently the same:
libbb/appletlib.c:164:13: error: 'NUM_APPLETS' undeclared (first use in this function)
while (i < NUM_APPLETS) {
The reason is the include file where NUM_APPLETS is defined is not yet generated (or is being modified) at the time libbb/appletlib.c is compiled.
The attached patchset fixes the problem by assuring libb is compiled as the last directory.
[YOCTO#10116]
--- .../busybox-kbuild-race-fix-commit-d8e61bb.patch | 45 +++++++++++++++ .../commit-applet_tables-fix-commit-0dddbc1.patch | 53 ++++++++++++++++++ .../busybox/busybox/makefile-libbb-race.patch | 34 +++++++++++ .../busybox/busybox/parallel-make-fix.patch | 65 ---------------------- meta/recipes-core/busybox/busybox_1.24.1.bb | 4 +- 5 files changed, 135 insertions(+), 66 deletions(-) create mode 100644 meta/recipes-core/busybox/busybox/busybox-kbuild-race-fix-commit-d8e61bb.patch create mode 100644 meta/recipes-core/busybox/busybox/commit-applet_tables-fix-commit-0dddbc1.patch create mode 100644 meta/recipes-core/busybox/busybox/makefile-libbb-race.patch delete mode 100644 meta/recipes-core/busybox/busybox/parallel-make-fix.patch
meta/recipes-core/busybox/busybox/busybox-kbuild-race-fix-commit-d8e61bb.patch new file +45 -0
@@ -0,0 +1,45 @@ +From d8e61bbf13d0cf38d477255cfd5dc71c5d51d575 Mon Sep 17 00:00:00 2001 +From: Denys Vlasenko <[email protected]> +Date: Sun, 21 Aug 2016 22:00:20 +0200 +Subject: build system: different fix for + include/applet_tables.h/include/NUM_APPLETS.h + +Signed-off-by: Denys Vlasenko <[email protected]> + +diff --git a/applets/Kbuild.src b/applets/Kbuild.src +index 5cc1827..3aedbbf 100644 +--- a/applets/Kbuild.src ++++ b/applets/Kbuild.src +@@ -29,7 +29,7 @@ applets/applets.o: include/usage_compressed.h include/applet_tables.h + + applets/applet_tables: .config include/applets.h + applets/usage: .config include/applets.h +-applets/usage_pod: .config include/applets.h include/applet_tables.h include/NUM_APPLETS.h ++applets/usage_pod: .config include/applets.h include/applet_tables.h + + quiet_cmd_gen_usage_compressed = GEN include/usage_compressed.h + cmd_gen_usage_compressed = $(srctree_slash)applets/usage_compressed include/usage_compressed.h applets +@@ -37,8 +37,21 @@ quiet_cmd_gen_usage_compressed = GEN include/usage_compressed.h + include/usage_compressed.h: applets/usage $(srctree_slash)applets/usage_compressed + $(call cmd,gen_usage_compressed) + +-quiet_cmd_gen_applet_tables = GEN include/applet_tables.h ++quiet_cmd_gen_applet_tables = GEN include/applet_tables.h include/NUM_APPLETS.h + cmd_gen_applet_tables = applets/applet_tables include/applet_tables.h include/NUM_APPLETS.h + +-include/applet_tables.h include/NUM_APPLETS.h: applets/applet_tables ++include/NUM_APPLETS.h: applets/applet_tables ++ $(call cmd,gen_applet_tables) ++ ++# In fact, include/applet_tables.h depends only on applets/applet_tables, ++# and is generated by it. But specifying only it can run ++# applets/applet_tables twice, possibly in parallel. ++# We say that it also needs NUM_APPLETS.h ++# ++# Unfortunately, we need to list the same command, ++# and it can be executed twice (sequentially). ++# The alternative is to not list any command, ++# and then if include/applet_tables.h is deleted, it won't be rebuilt. ++# ++include/applet_tables.h: include/NUM_APPLETS.h applets/applet_tables + $(call cmd,gen_applet_tables)
meta/recipes-core/busybox/busybox/commit-applet_tables-fix-commit-0dddbc1.patch new file +53 -0
53 lines not on this page · raw message
meta/recipes-core/busybox/busybox/makefile-libbb-race.patch new file +34 -0
@@ -0,0 +1,34 @@ +There is a potential race when building libbb, as some header files +needed by libbb are not generated yet (or are being modified) at the time +libbb is compiled. +This patch avoids this scenario by building libbb as the last directory. + +Upstream-Status: Submitted +Signed-off-by: Juro Bystricky <[email protected]> + +Index: busybox-1.24.1/Makefile +=================================================================== +diff --git a/Makefile b/Makefile +index 5cfc763..69f3831 100644 +--- a/Makefile ++++ b/Makefile +@@ -738,9 +738,18 @@ $(sort $(busybox-all)): $(busybox-dirs) ; + # Error messages still appears in the original language + + PHONY += $(busybox-dirs) +-$(busybox-dirs): prepare scripts ++ ++libbb-dir = $(filter libbb,$(busybox-dirs)) ++busybox-dirs1 = $(filter-out libbb,$(busybox-dirs)) ++ ++$(busybox-dirs1): prepare scripts + $(Q)$(MAKE) $(build)=$@ + ++ifneq ($(libbb-dir),) ++$(libbb-dir): | $(busybox-dirs1) ++ $(Q)$(MAKE) $(build)=$@ ++endif ++ + # Build the kernel release string + # The KERNELRELEASE is stored in a file named .kernelrelease + # to be used when executing for example make install or make modules_install
meta/recipes-core/busybox/busybox/parallel-make-fix.patch deleted +0 -65
65 lines not on this page · raw message
meta/recipes-core/busybox/busybox_1.24.1.bb +3 -1
@@ -49,8 +49,10 @@ SRC_URI = "http://www.busybox.net/downloads/busybox-${PV}.tar.bz2;name=tarball \ file://CVE-2016-2147_2.patch \ file://ip_fix_problem_on_mips64_n64_big_endian_musl_systems.patch \ file://makefile-fix-backport.patch \ - file://parallel-make-fix.patch \ file://0001-sed-fix-sed-n-flushes-pattern-space-terminates-early.patch \ + file://busybox-kbuild-race-fix-commit-d8e61bb.patch \ + file://commit-applet_tables-fix-commit-0dddbc1.patch \ + file://makefile-libbb-race.patch \ " SRC_URI_append_libc-musl = " file://musl.cfg "
Signature · 1 line
2.7.4
Re: [PATCH 1/1] busybox: Avoid race building libbb
meta/recipes-core/busybox/busybox/busybox-kbuild-race-fix-commit-d8e61bb.patch line 7
Quoted 11 lines · Juro Bystricky
+++ b/meta/recipes-core/busybox/busybox/busybox-kbuild-race- fix-commit-d8e61bb.patch
meta/recipes-core/busybox/busybox/busybox-kbuild-race-fix-commit-d8e61bb.patch new file +7
-0@@ -0,0 +1,45 @@ +From d8e61bbf13d0cf38d477255cfd5dc71c5d51d575 Mon Sep 17 00:00:00 2001 +From: Denys Vlasenko <[email protected]> +Date: Sun, 21 Aug 2016 22:00:20 +0200 +Subject: build system: different fix for + include/applet_tables.h/include/NUM_APPLETS.h + +Signed-off-by: Denys Vlasenko <[email protected]>
The two backport patches need your Signed-off-by and Upstream-Status:
Backport tags.
Ross
From: Juro Bystricky <[email protected]>
(Resending updated patches... hopefully got it right this time)
There is an occasional race observed when building Busybox. It has been discussed on Busybox mailing list (see:
https://www.mail-archive.com/[email protected]/msg23244.html )
There were several Busybox attempts to fix this issue:0dddbc1a59795a77679d8c5ef48a2795cb470563 ("build system: always rewrite NUM_APPLETS.h") d8e61bbf13d0cf38d477255cfd5dc71c5d51d575 ("build system: different fix for include/applet_tables.h/include/NUM_APPLETS.h")
Although the patches alleviated the problem somewhat, the race can still be observed. The error is consistently the same:
libbb/appletlib.c:164:13: error: 'NUM_APPLETS' undeclared (first use in this function)
while (i < NUM_APPLETS) {
The reason is the include file where NUM_APPLETS is defined is not yet generated (or is being modified) at the time libbb/appletlib.c is compiled.
The attached patch fixes the problem by assuring libb is compiled as the last directory.
*** BLURB HERE ***
Juro Bystricky (1):
busybox: Avoid race building libbb
.../busybox-kbuild-race-fix-commit-d8e61bb.patch | 53 ++++++++++++++++++ .../commit-applet_tables-fix-commit-0dddbc1.patch | 61 ++++++++++++++++++++ .../busybox/busybox/makefile-libbb-race.patch | 34 +++++++++++ .../busybox/busybox/parallel-make-fix.patch | 65 ---------------------- meta/recipes-core/busybox/busybox_1.24.1.bb | 4 +- 5 files changed, 151 insertions(+), 66 deletions(-) create mode 100644 meta/recipes-core/busybox/busybox/busybox-kbuild-race-fix-commit-d8e61bb.patch create mode 100644 meta/recipes-core/busybox/busybox/commit-applet_tables-fix-commit-0dddbc1.patch create mode 100644 meta/recipes-core/busybox/busybox/makefile-libbb-race.patch delete mode 100644 meta/recipes-core/busybox/busybox/parallel-make-fix.patch
Signature · 1 line
2.7.4
PATCH v2 1/1 busybox: Avoid race building libbb
When building busybox, an occasional error was observed. The error is consistently the same:
libbb/appletlib.c:164:13: error: 'NUM_APPLETS' undeclared (first use in this function)
while (i < NUM_APPLETS) {
The reason is the include file where NUM_APPLETS is defined is not yet generated (or is being modified) at the time libbb/appletlib.c is compiled.
The attached patchset fixes the problem by assuring libb is compiled as the last directory.
[YOCTO#10116]
--- .../busybox-kbuild-race-fix-commit-d8e61bb.patch | 53 ++++++++++++++++++ .../commit-applet_tables-fix-commit-0dddbc1.patch | 61 ++++++++++++++++++++ .../busybox/busybox/makefile-libbb-race.patch | 34 +++++++++++ .../busybox/busybox/parallel-make-fix.patch | 65 ---------------------- meta/recipes-core/busybox/busybox_1.24.1.bb | 4 +- 5 files changed, 151 insertions(+), 66 deletions(-) create mode 100644 meta/recipes-core/busybox/busybox/busybox-kbuild-race-fix-commit-d8e61bb.patch create mode 100644 meta/recipes-core/busybox/busybox/commit-applet_tables-fix-commit-0dddbc1.patch create mode 100644 meta/recipes-core/busybox/busybox/makefile-libbb-race.patch delete mode 100644 meta/recipes-core/busybox/busybox/parallel-make-fix.patch
meta/recipes-core/busybox/busybox/busybox-kbuild-race-fix-commit-d8e61bb.patch new file +53 -0
@@ -0,0 +1,53 @@ +Upstream-Status: Backport + +Patch addressing a parallel make race in Busybox + + http://git.busybox.net/busybox/commit/?id=d8e61bbf13d0cf38d477255cfd5dc71c5d51d575 + +Signed-off-by: Juro Bystricky <[email protected]> + +From d8e61bbf13d0cf38d477255cfd5dc71c5d51d575 Mon Sep 17 00:00:00 2001 +From: Denys Vlasenko <[email protected]> +Date: Sun, 21 Aug 2016 22:00:20 +0200 +Subject: build system: different fix for + include/applet_tables.h/include/NUM_APPLETS.h + +Signed-off-by: Denys Vlasenko <[email protected]> + +diff --git a/applets/Kbuild.src b/applets/Kbuild.src +index 5cc1827..3aedbbf 100644 +--- a/applets/Kbuild.src ++++ b/applets/Kbuild.src +@@ -29,7 +29,7 @@ applets/applets.o: include/usage_compressed.h include/applet_tables.h + + applets/applet_tables: .config include/applets.h + applets/usage: .config include/applets.h +-applets/usage_pod: .config include/applets.h include/applet_tables.h include/NUM_APPLETS.h ++applets/usage_pod: .config include/applets.h include/applet_tables.h + + quiet_cmd_gen_usage_compressed = GEN include/usage_compressed.h + cmd_gen_usage_compressed = $(srctree_slash)applets/usage_compressed include/usage_compressed.h applets +@@ -37,8 +37,21 @@ quiet_cmd_gen_usage_compressed = GEN include/usage_compressed.h + include/usage_compressed.h: applets/usage $(srctree_slash)applets/usage_compressed + $(call cmd,gen_usage_compressed) + +-quiet_cmd_gen_applet_tables = GEN include/applet_tables.h ++quiet_cmd_gen_applet_tables = GEN include/applet_tables.h include/NUM_APPLETS.h + cmd_gen_applet_tables = applets/applet_tables include/applet_tables.h include/NUM_APPLETS.h + +-include/applet_tables.h include/NUM_APPLETS.h: applets/applet_tables ++include/NUM_APPLETS.h: applets/applet_tables ++ $(call cmd,gen_applet_tables) ++ ++# In fact, include/applet_tables.h depends only on applets/applet_tables, ++# and is generated by it. But specifying only it can run ++# applets/applet_tables twice, possibly in parallel. ++# We say that it also needs NUM_APPLETS.h ++# ++# Unfortunately, we need to list the same command, ++# and it can be executed twice (sequentially). ++# The alternative is to not list any command, ++# and then if include/applet_tables.h is deleted, it won't be rebuilt. ++# ++include/applet_tables.h: include/NUM_APPLETS.h applets/applet_tables + $(call cmd,gen_applet_tables)
meta/recipes-core/busybox/busybox/commit-applet_tables-fix-commit-0dddbc1.patch new file +61 -0
61 lines not on this page · raw message
meta/recipes-core/busybox/busybox/makefile-libbb-race.patch new file +34 -0
@@ -0,0 +1,34 @@ +There is a potential race when building libbb, as some header files +needed by libbb are not generated yet (or are being modified) at the time +libbb is compiled. +This patch avoids this scenario by building libbb as the last directory. + +Upstream-Status: Submitted +Signed-off-by: Juro Bystricky <[email protected]> + +Index: busybox-1.24.1/Makefile +=================================================================== +diff --git a/Makefile b/Makefile +index 5cfc763..69f3831 100644 +--- a/Makefile ++++ b/Makefile +@@ -738,9 +738,18 @@ $(sort $(busybox-all)): $(busybox-dirs) ; + # Error messages still appears in the original language + + PHONY += $(busybox-dirs) +-$(busybox-dirs): prepare scripts ++ ++libbb-dir = $(filter libbb,$(busybox-dirs)) ++busybox-dirs1 = $(filter-out libbb,$(busybox-dirs)) ++ ++$(busybox-dirs1): prepare scripts + $(Q)$(MAKE) $(build)=$@ + ++ifneq ($(libbb-dir),) ++$(libbb-dir): | $(busybox-dirs1) ++ $(Q)$(MAKE) $(build)=$@ ++endif ++ + # Build the kernel release string + # The KERNELRELEASE is stored in a file named .kernelrelease + # to be used when executing for example make install or make modules_install
meta/recipes-core/busybox/busybox/parallel-make-fix.patch deleted +0 -65
65 lines not on this page · raw message
meta/recipes-core/busybox/busybox_1.24.1.bb +3 -1
@@ -49,8 +49,10 @@ SRC_URI = "http://www.busybox.net/downloads/busybox-${PV}.tar.bz2;name=tarball \ file://CVE-2016-2147_2.patch \ file://ip_fix_problem_on_mips64_n64_big_endian_musl_systems.patch \ file://makefile-fix-backport.patch \ - file://parallel-make-fix.patch \ file://0001-sed-fix-sed-n-flushes-pattern-space-terminates-early.patch \ + file://busybox-kbuild-race-fix-commit-d8e61bb.patch \ + file://commit-applet_tables-fix-commit-0dddbc1.patch \ + file://makefile-libbb-race.patch \ " SRC_URI_append_libc-musl = " file://musl.cfg "
Signature · 1 line
2.7.4