summaryrefslogtreecommitdiff
path: root/usr.bin/make
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2012-04-11 18:27:31 +0000
committerMarc Espie <espie@cvs.openbsd.org>2012-04-11 18:27:31 +0000
commit519ef5db14c7fa97a982299147d82e71803016ce (patch)
tree134756bca59c352f8e39c3c8ad343822e62358f2 /usr.bin/make
parentf74693e121b2c57b942f04d93f528facfe9bca5b (diff)
make has had heuristics to avoid parallel make recursion.
Sometimes they mess up, so add .CHEAP/.EXPENSIVE to explicitly tell make 'hey this is not THAT bad' or 'worse than you think'. agreed by guenther@, millert@ (and some tweaks)
Diffstat (limited to 'usr.bin/make')
-rw-r--r--usr.bin/make/generate.c4
-rw-r--r--usr.bin/make/gnode.h4
-rw-r--r--usr.bin/make/job.c9
-rw-r--r--usr.bin/make/make.115
-rw-r--r--usr.bin/make/node_int.h4
-rw-r--r--usr.bin/make/parse.c6
6 files changed, 33 insertions, 9 deletions
diff --git a/usr.bin/make/generate.c b/usr.bin/make/generate.c
index 4ca1a08e912..9cf59126365 100644
--- a/usr.bin/make/generate.c
+++ b/usr.bin/make/generate.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: generate.c,v 1.12 2010/07/19 19:46:44 espie Exp $ */
+/* $OpenBSD: generate.c,v 1.13 2012/04/11 18:27:30 espie Exp $ */
/*
* Copyright (c) 2001 Marc Espie.
@@ -116,6 +116,8 @@ char *table_nodes[] = {
M(NODE_BEGIN),
M(NODE_END),
M(NODE_INTERRUPT),
+ M(NODE_CHEAP),
+ M(NODE_EXPENSIVE),
NULL
};
diff --git a/usr.bin/make/gnode.h b/usr.bin/make/gnode.h
index 6dc9d18e1e7..25f5032a2ef 100644
--- a/usr.bin/make/gnode.h
+++ b/usr.bin/make/gnode.h
@@ -1,6 +1,6 @@
#ifndef GNODE_H
#define GNODE_H
-/* $OpenBSD: gnode.h,v 1.18 2012/03/22 13:47:12 espie Exp $ */
+/* $OpenBSD: gnode.h,v 1.19 2012/04/11 18:27:30 espie Exp $ */
/*
* Copyright (c) 2001 Marc Espie.
@@ -205,6 +205,8 @@ struct GNode_ {
* commands for a target */
#define OP_DEPS_FOUND 0x00800000 /* Already processed by Suff_FindDeps */
#define OP_RESOLVED 0x01000000 /* We looked harder already */
+#define OP_CHEAP 0x02000000 /* Assume job is not recursive */
+#define OP_EXPENSIVE 0x04000000 /* Recursive job, don't run in parallel */
/*
* OP_NOP will return true if the node with the given type was not the
diff --git a/usr.bin/make/job.c b/usr.bin/make/job.c
index 374bdb7bd88..82f992362d0 100644
--- a/usr.bin/make/job.c
+++ b/usr.bin/make/job.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: job.c,v 1.121 2012/03/22 13:47:12 espie Exp $ */
+/* $OpenBSD: job.c,v 1.122 2012/04/11 18:27:30 espie Exp $ */
/* $NetBSD: job.c,v 1.16 1996/11/06 17:59:08 christos Exp $ */
/*
@@ -836,9 +836,12 @@ prepare_job(GNode *gn, int flags)
* by the caller are also added to the field.
*/
job->flags = flags;
- if (expensive_commands(&gn->expanded)) {
+
+ if (gn->type & OP_CHEAP)
+ return job;
+ if ((gn->type & OP_EXPENSIVE) ||
+ expensive_commands(&gn->expanded))
job->flags |= JOB_IS_EXPENSIVE;
- }
return job;
}
diff --git a/usr.bin/make/make.1 b/usr.bin/make/make.1
index a438994b4f1..5b031fce343 100644
--- a/usr.bin/make/make.1
+++ b/usr.bin/make/make.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: make.1,v 1.92 2011/05/02 11:14:11 jmc Exp $
+.\" $OpenBSD: make.1,v 1.93 2012/04/11 18:27:30 espie Exp $
.\" $NetBSD: make.1,v 1.18 1997/03/10 21:19:53 christos Exp $
.\"
.\" Copyright (c) 1990, 1993
@@ -30,7 +30,7 @@
.\"
.\" from: @(#)make.1 8.4 (Berkeley) 3/19/94
.\"
-.Dd $Mdocdate: May 2 2011 $
+.Dd $Mdocdate: April 11 2012 $
.Dt MAKE 1
.Os
.Sh NAME
@@ -1184,6 +1184,12 @@ the only target specified.
.It Ic .BEGIN
Any command lines attached to this target are executed before anything
else is done.
+.It Ic .CHEAP
+In parallel mode, don't scan the commands for
+.Nm ,
+let recursive
+.Fl j
+behavior apply.
.It Ic .DEFAULT
This is sort of a
.Ic .USE
@@ -1201,6 +1207,11 @@ to the target's own name.
.It Ic .END
Any command lines attached to this target are executed after everything
else is done.
+.It Ic .EXPENSIVE
+In parallel mode, don't scan the commands for
+.Nm ,
+assume target is recursive and don't start other jobs until
+it is finished.
.It Ic .IGNORE
Mark each of the sources with the
.Ic .IGNORE
diff --git a/usr.bin/make/node_int.h b/usr.bin/make/node_int.h
index 1f063c6cb15..707978edd11 100644
--- a/usr.bin/make/node_int.h
+++ b/usr.bin/make/node_int.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: node_int.h,v 1.2 2010/07/19 19:30:37 espie Exp $ */
+/* $OpenBSD: node_int.h,v 1.3 2012/04/11 18:27:30 espie Exp $ */
/*
* Copyright (c) 2007 Marc Espie.
@@ -59,3 +59,5 @@
#define NODE_BEGIN ".BEGIN"
#define NODE_END ".END"
#define NODE_INTERRUPT ".INTERRUPT"
+#define NODE_CHEAP ".CHEAP"
+#define NODE_EXPENSIVE ".EXPENSIVE"
diff --git a/usr.bin/make/parse.c b/usr.bin/make/parse.c
index 928a81c6f11..72fc76e475d 100644
--- a/usr.bin/make/parse.c
+++ b/usr.bin/make/parse.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.c,v 1.101 2012/03/22 13:47:12 espie Exp $ */
+/* $OpenBSD: parse.c,v 1.102 2012/04/11 18:27:30 espie Exp $ */
/* $NetBSD: parse.c,v 1.29 1997/03/10 21:20:04 christos Exp $ */
/*
@@ -194,6 +194,8 @@ static void dump_targets(void);
#define SPECIAL_WAIT 29U
#define SPECIAL_NOPATH 30U
#define SPECIAL_ERROR 31U
+#define SPECIAL_CHEAP 32U
+#define SPECIAL_EXPENSIVE 33U
#define P(k) k, sizeof(k), K_##k
@@ -232,6 +234,8 @@ static struct {
{ P(NODE_SUFFIXES), SPECIAL_SUFFIXES | SPECIAL_TARGET, 0, },
{ P(NODE_USE), SPECIAL_USE | SPECIAL_TARGETSOURCE, OP_USE, },
{ P(NODE_WAIT), SPECIAL_WAIT | SPECIAL_TARGETSOURCE, 0 },
+ { P(NODE_CHEAP), SPECIAL_CHEAP | SPECIAL_TARGETSOURCE, OP_CHEAP, },
+ { P(NODE_EXPENSIVE),SPECIAL_EXPENSIVE | SPECIAL_TARGETSOURCE,OP_EXPENSIVE, },
#if 0
{ P(NODE_NOPATH), SPECIAL_NOPATH, },
#endif