summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorJuro Bystricky <juro.bystricky@intel.com>2016-09-14 10:05:46 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-09-15 12:15:07 +0100
commita6f0bced4c15f93a5e1c1b8782aa5dc6ca8d1113 (patch)
treec481099dcd78e2a84d6e3ed549f436e3ac812a69 /meta
parentde915fb7d387a7a3dcaba61b6e116bb28db9d8ff (diff)
downloadpoky-a6f0bced4c15f93a5e1c1b8782aa5dc6ca8d1113.tar.gz
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] (From OE-Core rev: a866a05e2c7d090a77aa6e95339c93e3592703a6) Signed-off-by: Juro Bystricky <juro.bystricky@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/recipes-core/busybox/busybox/busybox-kbuild-race-fix-commit-d8e61bb.patch53
-rw-r--r--meta/recipes-core/busybox/busybox/commit-applet_tables-fix-commit-0dddbc1.patch61
-rw-r--r--meta/recipes-core/busybox/busybox/makefile-libbb-race.patch34
-rw-r--r--meta/recipes-core/busybox/busybox/parallel-make-fix.patch65
-rw-r--r--meta/recipes-core/busybox/busybox_1.24.1.bb4
5 files changed, 151 insertions, 66 deletions
diff --git a/meta/recipes-core/busybox/busybox/busybox-kbuild-race-fix-commit-d8e61bb.patch b/meta/recipes-core/busybox/busybox/busybox-kbuild-race-fix-commit-d8e61bb.patch
new file mode 100644
index 0000000000..38302e0b68
--- /dev/null
+++ b/meta/recipes-core/busybox/busybox/busybox-kbuild-race-fix-commit-d8e61bb.patch
@@ -0,0 +1,53 @@
1Upstream-Status: Backport
2
3Patch addressing a parallel make race in Busybox
4
5 http://git.busybox.net/busybox/commit/?id=d8e61bbf13d0cf38d477255cfd5dc71c5d51d575
6
7Signed-off-by: Juro Bystricky <juro.bystricky@intel.com>
8
9From d8e61bbf13d0cf38d477255cfd5dc71c5d51d575 Mon Sep 17 00:00:00 2001
10From: Denys Vlasenko <vda.linux@googlemail.com>
11Date: Sun, 21 Aug 2016 22:00:20 +0200
12Subject: build system: different fix for
13 include/applet_tables.h/include/NUM_APPLETS.h
14
15Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
16
17diff --git a/applets/Kbuild.src b/applets/Kbuild.src
18index 5cc1827..3aedbbf 100644
19--- a/applets/Kbuild.src
20+++ b/applets/Kbuild.src
21@@ -29,7 +29,7 @@ applets/applets.o: include/usage_compressed.h include/applet_tables.h
22
23 applets/applet_tables: .config include/applets.h
24 applets/usage: .config include/applets.h
25-applets/usage_pod: .config include/applets.h include/applet_tables.h include/NUM_APPLETS.h
26+applets/usage_pod: .config include/applets.h include/applet_tables.h
27
28 quiet_cmd_gen_usage_compressed = GEN include/usage_compressed.h
29 cmd_gen_usage_compressed = $(srctree_slash)applets/usage_compressed include/usage_compressed.h applets
30@@ -37,8 +37,21 @@ quiet_cmd_gen_usage_compressed = GEN include/usage_compressed.h
31 include/usage_compressed.h: applets/usage $(srctree_slash)applets/usage_compressed
32 $(call cmd,gen_usage_compressed)
33
34-quiet_cmd_gen_applet_tables = GEN include/applet_tables.h
35+quiet_cmd_gen_applet_tables = GEN include/applet_tables.h include/NUM_APPLETS.h
36 cmd_gen_applet_tables = applets/applet_tables include/applet_tables.h include/NUM_APPLETS.h
37
38-include/applet_tables.h include/NUM_APPLETS.h: applets/applet_tables
39+include/NUM_APPLETS.h: applets/applet_tables
40+ $(call cmd,gen_applet_tables)
41+
42+# In fact, include/applet_tables.h depends only on applets/applet_tables,
43+# and is generated by it. But specifying only it can run
44+# applets/applet_tables twice, possibly in parallel.
45+# We say that it also needs NUM_APPLETS.h
46+#
47+# Unfortunately, we need to list the same command,
48+# and it can be executed twice (sequentially).
49+# The alternative is to not list any command,
50+# and then if include/applet_tables.h is deleted, it won't be rebuilt.
51+#
52+include/applet_tables.h: include/NUM_APPLETS.h applets/applet_tables
53 $(call cmd,gen_applet_tables)
diff --git a/meta/recipes-core/busybox/busybox/commit-applet_tables-fix-commit-0dddbc1.patch b/meta/recipes-core/busybox/busybox/commit-applet_tables-fix-commit-0dddbc1.patch
new file mode 100644
index 0000000000..7f80a1d915
--- /dev/null
+++ b/meta/recipes-core/busybox/busybox/commit-applet_tables-fix-commit-0dddbc1.patch
@@ -0,0 +1,61 @@
1Upstream-Status: Backport
2
3Patch addressing a parallel make race in Busybox
4
5 http://git.busybox.net/busybox/commit/?id=0dddbc1a59795a77679d8c5ef48a2795cb470563
6
7Signed-off-by: Juro Bystricky <juro.bystricky@intel.com>
8
9From 0dddbc1a59795a77679d8c5ef48a2795cb470563 Mon Sep 17 00:00:00 2001
10From: Denys Vlasenko <vda.linux@googlemail.com>
11Date: Tue, 23 Aug 2016 20:21:36 +0200
12Subject: build system: always rewrite NUM_APPLETS.h
13
14Conditional rewrite can keep NUM_APPLETS.h mtime old,
15this causes make to try to regenerate it at every invocation.
16
17Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
18
19diff --git a/applets/applet_tables.c b/applets/applet_tables.c
20index 8401a15..ef911a4 100644
21--- a/applets/applet_tables.c
22+++ b/applets/applet_tables.c
23@@ -192,27 +192,28 @@ int main(int argc, char **argv)
24 printf("};\n");
25 #endif
26 //printf("#endif /* SKIP_definitions */\n");
27+
28 // printf("\n");
29 // printf("#define MAX_APPLET_NAME_LEN %u\n", MAX_APPLET_NAME_LEN);
30
31 if (argv[2]) {
32- char line_old[80];
33- char line_new[80];
34 FILE *fp;
35+ char line_new[80];
36+// char line_old[80];
37
38- line_old[0] = 0;
39- fp = fopen(argv[2], "r");
40- if (fp) {
41- fgets(line_old, sizeof(line_old), fp);
42- fclose(fp);
43- }
44 sprintf(line_new, "#define NUM_APPLETS %u\n", NUM_APPLETS);
45- if (strcmp(line_old, line_new) != 0) {
46+// line_old[0] = 0;
47+// fp = fopen(argv[2], "r");
48+// if (fp) {
49+// fgets(line_old, sizeof(line_old), fp);
50+// fclose(fp);
51+// }
52+// if (strcmp(line_old, line_new) != 0) {
53 fp = fopen(argv[2], "w");
54 if (!fp)
55 return 1;
56 fputs(line_new, fp);
57- }
58+// }
59 }
60
61 return 0;
diff --git a/meta/recipes-core/busybox/busybox/makefile-libbb-race.patch b/meta/recipes-core/busybox/busybox/makefile-libbb-race.patch
new file mode 100644
index 0000000000..97278ab973
--- /dev/null
+++ b/meta/recipes-core/busybox/busybox/makefile-libbb-race.patch
@@ -0,0 +1,34 @@
1There is a potential race when building libbb, as some header files
2needed by libbb are not generated yet (or are being modified) at the time
3libbb is compiled.
4This patch avoids this scenario by building libbb as the last directory.
5
6Upstream-Status: Submitted
7Signed-off-by: Juro Bystricky <juro.bystricky@intel.com>
8
9Index: busybox-1.24.1/Makefile
10===================================================================
11diff --git a/Makefile b/Makefile
12index 5cfc763..69f3831 100644
13--- a/Makefile
14+++ b/Makefile
15@@ -738,9 +738,18 @@ $(sort $(busybox-all)): $(busybox-dirs) ;
16 # Error messages still appears in the original language
17
18 PHONY += $(busybox-dirs)
19-$(busybox-dirs): prepare scripts
20+
21+libbb-dir = $(filter libbb,$(busybox-dirs))
22+busybox-dirs1 = $(filter-out libbb,$(busybox-dirs))
23+
24+$(busybox-dirs1): prepare scripts
25 $(Q)$(MAKE) $(build)=$@
26
27+ifneq ($(libbb-dir),)
28+$(libbb-dir): | $(busybox-dirs1)
29+ $(Q)$(MAKE) $(build)=$@
30+endif
31+
32 # Build the kernel release string
33 # The KERNELRELEASE is stored in a file named .kernelrelease
34 # to be used when executing for example make install or make modules_install
diff --git a/meta/recipes-core/busybox/busybox/parallel-make-fix.patch b/meta/recipes-core/busybox/busybox/parallel-make-fix.patch
deleted file mode 100644
index 120dff1007..0000000000
--- a/meta/recipes-core/busybox/busybox/parallel-make-fix.patch
+++ /dev/null
@@ -1,65 +0,0 @@
1When applet_tables is run, we need it to touch both output files,
2else make will keep calling the command, potentially leading to races
3as the files are potentially rewritten.
4
5We also need to ensure that applet_tables is called once, not twice,
6potentially in parallel. To do this, make one file depend upon the other.
7
8Upstream-Status: Submitted
9RP 2016/8/19
10
11Index: busybox-1.24.1/applets/Kbuild.src
12===================================================================
13--- busybox-1.24.1.orig/applets/Kbuild.src
14+++ busybox-1.24.1/applets/Kbuild.src
15@@ -29,7 +29,7 @@ applets/applets.o: include/usage_compres
16
17 applets/applet_tables: .config include/applets.h
18 applets/usage: .config include/applets.h
19-applets/usage_pod: .config include/applets.h include/applet_tables.h include/NUM_APPLETS.h
20+applets/usage_pod: .config include/applets.h include/applet_tables.h
21
22 quiet_cmd_gen_usage_compressed = GEN include/usage_compressed.h
23 cmd_gen_usage_compressed = $(srctree_slash)applets/usage_compressed include/usage_compressed.h applets
24@@ -40,5 +40,7 @@ include/usage_compressed.h: applets/usag
25 quiet_cmd_gen_applet_tables = GEN include/applet_tables.h
26 cmd_gen_applet_tables = applets/applet_tables include/applet_tables.h include/NUM_APPLETS.h
27
28-include/applet_tables.h include/NUM_APPLETS.h: applets/applet_tables
29+include/NUM_APPLETS.h: applets/applet_tables
30 $(call cmd,gen_applet_tables)
31+
32+include/applet_tables.h: include/NUM_APPLETS.h
33Index: busybox-1.24.1/applets/applet_tables.c
34===================================================================
35--- busybox-1.24.1.orig/applets/applet_tables.c
36+++ busybox-1.24.1/applets/applet_tables.c
37@@ -151,23 +151,15 @@ int main(int argc, char **argv)
38 // printf("#define MAX_APPLET_NAME_LEN %u\n", MAX_APPLET_NAME_LEN);
39
40 if (argv[2]) {
41- char line_old[80];
42 char line_new[80];
43 FILE *fp;
44
45- line_old[0] = 0;
46- fp = fopen(argv[2], "r");
47- if (fp) {
48- fgets(line_old, sizeof(line_old), fp);
49- fclose(fp);
50- }
51 sprintf(line_new, "#define NUM_APPLETS %u\n", NUM_APPLETS);
52- if (strcmp(line_old, line_new) != 0) {
53- fp = fopen(argv[2], "w");
54- if (!fp)
55- return 1;
56- fputs(line_new, fp);
57- }
58+ fp = fopen(argv[2], "w");
59+ if (!fp)
60+ return 1;
61+ fputs(line_new, fp);
62+ fclose(fp);
63 }
64
65 return 0;
diff --git a/meta/recipes-core/busybox/busybox_1.24.1.bb b/meta/recipes-core/busybox/busybox_1.24.1.bb
index f370451a3c..df0e131266 100644
--- a/meta/recipes-core/busybox/busybox_1.24.1.bb
+++ b/meta/recipes-core/busybox/busybox_1.24.1.bb
@@ -49,8 +49,10 @@ SRC_URI = "http://www.busybox.net/downloads/busybox-${PV}.tar.bz2;name=tarball \
49 file://CVE-2016-2147_2.patch \ 49 file://CVE-2016-2147_2.patch \
50 file://ip_fix_problem_on_mips64_n64_big_endian_musl_systems.patch \ 50 file://ip_fix_problem_on_mips64_n64_big_endian_musl_systems.patch \
51 file://makefile-fix-backport.patch \ 51 file://makefile-fix-backport.patch \
52 file://parallel-make-fix.patch \
53 file://0001-sed-fix-sed-n-flushes-pattern-space-terminates-early.patch \ 52 file://0001-sed-fix-sed-n-flushes-pattern-space-terminates-early.patch \
53 file://busybox-kbuild-race-fix-commit-d8e61bb.patch \
54 file://commit-applet_tables-fix-commit-0dddbc1.patch \
55 file://makefile-libbb-race.patch \
54" 56"
55SRC_URI_append_libc-musl = " file://musl.cfg " 57SRC_URI_append_libc-musl = " file://musl.cfg "
56 58