aboutsummaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/busybox/busybox/parallel-make-fix.patch
blob: 120dff10073b1fb38cb1a0dae01bbb9829a8a59d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
When applet_tables is run, we need it to touch both output files,
else make will keep calling the command, potentially leading to races
as the files are potentially rewritten.

We also need to ensure that applet_tables is called once, not twice, 
potentially in parallel. To do this, make one file depend upon the other.

Upstream-Status: Submitted
RP 2016/8/19

Index: busybox-1.24.1/applets/Kbuild.src
===================================================================
--- busybox-1.24.1.orig/applets/Kbuild.src
+++ busybox-1.24.1/applets/Kbuild.src
@@ -29,7 +29,7 @@ applets/applets.o: include/usage_compres
 
 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
@@ -40,5 +40,7 @@ include/usage_compressed.h: applets/usag
 quiet_cmd_gen_applet_tables = GEN     include/applet_tables.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)
+
+include/applet_tables.h: include/NUM_APPLETS.h
Index: busybox-1.24.1/applets/applet_tables.c
===================================================================
--- busybox-1.24.1.orig/applets/applet_tables.c
+++ busybox-1.24.1/applets/applet_tables.c
@@ -151,23 +151,15 @@ int main(int argc, char **argv)
 //	printf("#define MAX_APPLET_NAME_LEN %u\n", MAX_APPLET_NAME_LEN);
 
 	if (argv[2]) {
-		char line_old[80];
 		char line_new[80];
 		FILE *fp;
 
-		line_old[0] = 0;
-		fp = fopen(argv[2], "r");
-		if (fp) {
-			fgets(line_old, sizeof(line_old), fp);
-			fclose(fp);
-		}
 		sprintf(line_new, "#define NUM_APPLETS %u\n", NUM_APPLETS);
-		if (strcmp(line_old, line_new) != 0) {
-			fp = fopen(argv[2], "w");
-			if (!fp)
-				return 1;
-			fputs(line_new, fp);
-		}
+		fp = fopen(argv[2], "w");
+		if (!fp)
+			return 1;
+		fputs(line_new, fp);
+		fclose(fp);
 	}
 
 	return 0;