tech-toolchain archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: make: .PHONY lacks .TARGET
On Wed, 28 Sep 2011 10:23:47 +0000, David Holland writes:
>Does this work with make -j? (I'm just remembering the history of PR
>43534, which is related enough to make me slightly nervous.)
So I just took another look at 43534.
The revised patch bellow appears to fix it,
but then apart from a .PHONY run via .END, I see the same behavior (for
my test case) with your fix for 43534 too.
Do you recall the test case that caused you to revert it?
Eg. just your fix:
.TARGET="phony" .PREFIX="phony" .IMPSRC=""
.TARGET="all" .PREFIX="all" .IMPSRC=""
.TARGET="ok" .PREFIX="ok" .IMPSRC=""
.TARGET="also.ok" .PREFIX="also.ok" .IMPSRC=""
.TARGET="" .PREFIX="" .IMPSRC=""
with -j3:
--- phony ---
.TARGET="phony" .PREFIX="phony" .IMPSRC=""
--- all ---
.TARGET="all" .PREFIX="all" .IMPSRC=""
.TARGET="ok" .PREFIX="ok" .IMPSRC=""
.TARGET="also.ok" .PREFIX="also.ok" .IMPSRC=""
.TARGET="" .PREFIX="" .IMPSRC=""
note that "phony" is the same. The blank .TARGET is "bug".
With just the patch below, we get:
.TARGET="phony" .PREFIX="phony" .IMPSRC=""
.TARGET="all" .PREFIX="all" .IMPSRC=""
.TARGET="ok" .PREFIX="ok" .IMPSRC=""
.TARGET="also.ok" .PREFIX="also.ok" .IMPSRC=""
.TARGET="bug" .PREFIX="bug" .IMPSRC=""
and -j3:
--- phony ---
.TARGET="phony" .PREFIX="phony" .IMPSRC=""
--- all ---
.TARGET="all" .PREFIX="all" .IMPSRC=""
.TARGET="ok" .PREFIX="ok" .IMPSRC=""
.TARGET="also.ok" .PREFIX="also.ok" .IMPSRC=""
.TARGET="bug" .PREFIX="bug" .IMPSRC=""
--sjg
Index: suff.c
===================================================================
RCS file: /cvsroot/src/usr.bin/make/suff.c,v
retrieving revision 1.68
diff -u -p -r1.68 suff.c
--- suff.c 30 Jun 2011 20:09:42 -0000 1.68
+++ suff.c 28 Sep 2011 15:25:02 -0000
@@ -2411,6 +2411,11 @@ SuffFindDeps(GNode *gn, Lst slst)
* If dependencies already found, no need to do it again...
* If this is a .PHONY target, we do not apply suffix rules.
*/
+ if (gn->type & OP_PHONY) {
+ /* But we do want to make sure these are set. */
+ Var_Set(TARGET, gn->path ? gn->path : gn->name, gn, 0);
+ Var_Set(PREFIX, gn->name, gn, 0);
+ }
return;
} else {
gn->type |= OP_DEPS_FOUND;
In fact I think you can go further, and avoid some of the repeated calls
for Var_Set(TARGET) with the patch below.
I've a tree which just did a release build - will clean and run it again
with this...
Index: make.c
===================================================================
RCS file: /cvsroot/src/usr.bin/make/make.c,v
retrieving revision 1.84
diff -u -p -r1.84 make.c
--- make.c 16 Sep 2011 15:38:04 -0000 1.84
+++ make.c 28 Sep 2011 15:44:59 -0000
@@ -1337,7 +1337,6 @@ Make_ExpandUse(Lst targs)
}
(void)Dir_MTime(gn);
- Var_Set(TARGET, gn->path ? gn->path : gn->name, gn, 0);
Lst_ForEach(gn->children, MakeUnmark, gn);
Lst_ForEach(gn->children, MakeHandleUse, gn);
Index: suff.c
===================================================================
RCS file: /cvsroot/src/usr.bin/make/suff.c,v
retrieving revision 1.68
diff -u -p -r1.68 suff.c
--- suff.c 30 Jun 2011 20:09:42 -0000 1.68
+++ suff.c 28 Sep 2011 15:44:59 -0000
@@ -2406,16 +2406,25 @@ Suff_FindDeps(GNode *gn)
static void
SuffFindDeps(GNode *gn, Lst slst)
{
- if (gn->type & (OP_DEPS_FOUND|OP_PHONY)) {
+ if (gn->type & OP_DEPS_FOUND) {
/*
* If dependencies already found, no need to do it again...
- * If this is a .PHONY target, we do not apply suffix rules.
*/
return;
} else {
gn->type |= OP_DEPS_FOUND;
}
-
+ /*
+ * Make sure we have these set, may get revised below.
+ */
+ Var_Set(TARGET, gn->path ? gn->path : gn->name, gn, 0);
+ Var_Set(PREFIX, gn->name, gn, 0);
+ if (gn->type & OP_PHONY) {
+ /*
+ * If this is a .PHONY target, we do not apply suffix rules.
+ */
+ return;
+ }
if (DEBUG(SUFF)) {
fprintf(debug_file, "SuffFindDeps (%s)\n", gn->name);
}
Index: unit-tests/Makefile
===================================================================
RCS file: /cvsroot/src/usr.bin/make/unit-tests/Makefile,v
retrieving revision 1.32
diff -u -p -r1.32 Makefile
--- unit-tests/Makefile 7 Apr 2011 01:40:02 -0000 1.32
+++ unit-tests/Makefile 28 Sep 2011 15:44:59 -0000
@@ -35,6 +35,7 @@ SUBFILES= \
modorder \
modts \
modword \
+ phony-end \
posix \
qequals \
sysv \
Index: unit-tests/phony-end
===================================================================
RCS file: unit-tests/phony-end
diff -N unit-tests/phony-end
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ unit-tests/phony-end 28 Sep 2011 15:44:59 -0000
@@ -0,0 +1,9 @@
+# $Id$
+
+all ok also.ok bug phony:
+ @echo '${.TARGET .PREFIX .IMPSRC:L:@v@$v="${$v}"@}'
+
+.END: ok also.ok bug
+
+phony bug: .PHONY
+all: phony
Index: unit-tests/test.exp
===================================================================
RCS file: /cvsroot/src/usr.bin/make/unit-tests/test.exp,v
retrieving revision 1.38
diff -u -p -r1.38 test.exp
--- unit-tests/test.exp 3 Jun 2011 21:10:42 -0000 1.38
+++ unit-tests/test.exp 28 Sep 2011 15:44:59 -0000
@@ -292,6 +292,11 @@ LIST:tw:C/ /,/g="one two three four five
LIST:tw:C/ /,/1g="one two three four five six"
LIST:tw:tW:C/ /,/="one,two three four five six"
LIST:tW:tw:C/ /,/="one two three four five six"
+.TARGET="phony" .PREFIX="phony" .IMPSRC=""
+.TARGET="all" .PREFIX="all" .IMPSRC=""
+.TARGET="ok" .PREFIX="ok" .IMPSRC=""
+.TARGET="also.ok" .PREFIX="also.ok" .IMPSRC=""
+.TARGET="bug" .PREFIX="bug" .IMPSRC=""
Posix says we should execute the command as if run by system(3)
Expect 'Hello,' and 'World!'
Hello,
Home |
Main Index |
Thread Index |
Old Index