Lines 1-164
Link Here
|
1 |
From 4762480ae9cb8df4878286411f178d32db14eff0 Mon Sep 17 00:00:00 2001 |
|
|
2 |
From: Paul Smith <psmith@gnu.org> |
3 |
Date: Tue, 31 May 2016 06:56:51 +0000 |
4 |
Subject: [SV 47995] Ensure forced double-colon rules work with -j. |
5 |
|
6 |
The fix for SV 44742 had a side-effect that some double-colon targets |
7 |
were skipped. This happens because the "considered" facility assumed |
8 |
that all targets would be visited on each walk through the dependency |
9 |
graph: we used a bit for considered and toggled it on each pass; if |
10 |
we didn't walk the entire graph on every pass the bit would get out |
11 |
of sync. The new behavior after SV 44742 might return early without |
12 |
walking the entire graph. To fix this I changed the considered value |
13 |
to an integer which is monotonically increasing: it is then never |
14 |
possible to incorrectly determine that a previous pass through the |
15 |
graph already considered the current target. |
16 |
|
17 |
* filedef.h (struct file): make CONSIDERED an unsigned int. |
18 |
* main.c (main): No longer need to reset CONSIDERED. |
19 |
* remake.c (update_goal_chain): increment CONSIDERED rather than |
20 |
inverting it between 0<->1. |
21 |
(update_file_1): Reset CONSIDERED to 0 so it's re-considered. |
22 |
(check_dep): Ditto. |
23 |
* tests/scripts/features/double_colon: Add a regression test. |
24 |
--- |
25 |
diff --git a/filedef.h b/filedef.h |
26 |
index 507a027..14b4187 100644 |
27 |
--- filedef.h |
28 |
+++ filedef.h |
29 |
@@ -58,6 +58,8 @@ struct file |
30 |
FILE_TIMESTAMP last_mtime; /* File's modtime, if already known. */ |
31 |
FILE_TIMESTAMP mtime_before_update; /* File's modtime before any updating |
32 |
has been performed. */ |
33 |
+ unsigned int considered; /* equal to 'considered' if file has been |
34 |
+ considered on current scan of goal chain */ |
35 |
int command_flags; /* Flags OR'd in for cmds; see commands.h. */ |
36 |
enum update_status /* Status of the last attempt to update. */ |
37 |
{ |
38 |
@@ -96,8 +98,6 @@ struct file |
39 |
unsigned int ignore_vpath:1;/* Nonzero if we threw out VPATH name. */ |
40 |
unsigned int pat_searched:1;/* Nonzero if we already searched for |
41 |
pattern-specific variables. */ |
42 |
- unsigned int considered:1; /* equal to 'considered' if file has been |
43 |
- considered on current scan of goal chain */ |
44 |
unsigned int no_diag:1; /* True if the file failed to update and no |
45 |
diagnostics has been issued (dontcare). */ |
46 |
}; |
47 |
diff --git a/main.c b/main.c |
48 |
index 576f2e9..e606488 100644 |
49 |
--- main.c |
50 |
+++ main.c |
51 |
@@ -2262,10 +2262,6 @@ main (int argc, char **argv, char **envp) |
52 |
|
53 |
for (i = 0, d = read_files; d != 0; ++i, d = d->next) |
54 |
{ |
55 |
- /* Reset the considered flag; we may need to look at the file |
56 |
- again to print an error. */ |
57 |
- d->file->considered = 0; |
58 |
- |
59 |
if (d->file->updated) |
60 |
{ |
61 |
/* This makefile was updated. */ |
62 |
diff --git a/remake.c b/remake.c |
63 |
index df1a9e0..5d5d67a 100644 |
64 |
--- remake.c |
65 |
+++ remake.c |
66 |
@@ -57,8 +57,9 @@ unsigned int commands_started = 0; |
67 |
static struct goaldep *goal_list; |
68 |
static struct dep *goal_dep; |
69 |
|
70 |
-/* Current value for pruning the scan of the goal chain (toggle 0/1). */ |
71 |
-static unsigned int considered; |
72 |
+/* Current value for pruning the scan of the goal chain. |
73 |
+ All files start with considered == 0. */ |
74 |
+static unsigned int considered = 0; |
75 |
|
76 |
static enum update_status update_file (struct file *file, unsigned int depth); |
77 |
static enum update_status update_file_1 (struct file *file, unsigned int depth); |
78 |
@@ -90,12 +91,12 @@ update_goal_chain (struct goaldep *goaldeps) |
79 |
|
80 |
goal_list = rebuilding_makefiles ? goaldeps : NULL; |
81 |
|
82 |
- /* All files start with the considered bit 0, so the global value is 1. */ |
83 |
- considered = 1; |
84 |
- |
85 |
#define MTIME(file) (rebuilding_makefiles ? file_mtime_no_search (file) \ |
86 |
: file_mtime (file)) |
87 |
|
88 |
+ /* Start a fresh batch of consideration. */ |
89 |
+ ++considered; |
90 |
+ |
91 |
/* Update all the goals until they are all finished. */ |
92 |
|
93 |
while (goals != 0) |
94 |
@@ -247,10 +248,10 @@ update_goal_chain (struct goaldep *goaldeps) |
95 |
} |
96 |
} |
97 |
|
98 |
- /* If we reached the end of the dependency graph toggle the considered |
99 |
- flag for the next pass. */ |
100 |
+ /* If we reached the end of the dependency graph update CONSIDERED |
101 |
+ for the next pass. */ |
102 |
if (g == 0) |
103 |
- considered = !considered; |
104 |
+ ++considered; |
105 |
} |
106 |
|
107 |
if (rebuilding_makefiles) |
108 |
@@ -615,8 +616,8 @@ update_file_1 (struct file *file, unsigned int depth) |
109 |
break; |
110 |
|
111 |
if (!running) |
112 |
- /* The prereq is considered changed if the timestamp has changed while |
113 |
- it was built, OR it doesn't exist. */ |
114 |
+ /* The prereq is considered changed if the timestamp has changed |
115 |
+ while it was built, OR it doesn't exist. */ |
116 |
d->changed = ((file_mtime (d->file) != mtime) |
117 |
|| (mtime == NONEXISTENT_MTIME)); |
118 |
|
119 |
@@ -650,7 +651,7 @@ update_file_1 (struct file *file, unsigned int depth) |
120 |
/* We may have already considered this file, when we didn't know |
121 |
we'd need to update it. Force update_file() to consider it and |
122 |
not prune it. */ |
123 |
- d->file->considered = !considered; |
124 |
+ d->file->considered = 0; |
125 |
|
126 |
new = update_file (d->file, depth); |
127 |
if (new > dep_status) |
128 |
@@ -1087,7 +1088,7 @@ check_dep (struct file *file, unsigned int depth, |
129 |
/* If the target was waiting for a dependency it has to be |
130 |
reconsidered, as that dependency might have finished. */ |
131 |
if (file->command_state == cs_deps_running) |
132 |
- file->considered = !considered; |
133 |
+ file->considered = 0; |
134 |
|
135 |
set_command_state (file, cs_not_started); |
136 |
} |
137 |
diff --git a/tests/scripts/features/double_colon b/tests/scripts/features/double_colon |
138 |
index 80ddb31..58f126f 100644 |
139 |
--- tests/scripts/features/double_colon |
140 |
+++ tests/scripts/features/double_colon |
141 |
@@ -197,6 +197,21 @@ all:: 3 |
142 |
', |
143 |
'-rs -j2 1 2 root', "all_one\nall_two\nroot\n"); |
144 |
|
145 |
+# SV 47995 : Parallel double-colon rules with FORCE |
146 |
+ |
147 |
+run_make_test(' |
148 |
+all:: ; @echo one |
149 |
+ |
150 |
+all:: joe ; @echo four |
151 |
+ |
152 |
+joe: FORCE ; touch joe-is-forced |
153 |
+ |
154 |
+FORCE: |
155 |
+', |
156 |
+ '-j5', "one\ntouch joe-is-forced\nfour\n"); |
157 |
+ |
158 |
+unlink('joe-is-forced'); |
159 |
+ |
160 |
# This tells the test driver that the perl test script executed properly. |
161 |
1; |
162 |
|
163 |
-- |
164 |
cgit v0.9.0.2 |