Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make PR/48367: David A. Holland: Mark possible subma...
details: https://anonhg.NetBSD.org/src/rev/4502288b8fb1
branches: trunk
changeset: 797383:4502288b8fb1
user: christos <christos%NetBSD.org@localhost>
date: Wed Jul 16 15:33:41 2014 +0000
description:
PR/48367: David A. Holland: Mark possible submake nodes so that we can
avoid closing the job pipe on exec for them in order to make recursive
makes work in parallel.
diffstat:
usr.bin/make/job.c | 8 ++++----
usr.bin/make/make.h | 3 ++-
usr.bin/make/parse.c | 48 ++++++++++++++++++++++++++++++++++++++++++++----
3 files changed, 50 insertions(+), 9 deletions(-)
diffs (141 lines):
diff -r 44f2149d245e -r 4502288b8fb1 usr.bin/make/job.c
--- a/usr.bin/make/job.c Wed Jul 16 14:47:59 2014 +0000
+++ b/usr.bin/make/job.c Wed Jul 16 15:33:41 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: job.c,v 1.176 2013/08/04 16:48:15 sjg Exp $ */
+/* $NetBSD: job.c,v 1.177 2014/07/16 15:33:41 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: job.c,v 1.176 2013/08/04 16:48:15 sjg Exp $";
+static char rcsid[] = "$NetBSD: job.c,v 1.177 2014/07/16 15:33:41 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)job.c 8.2 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: job.c,v 1.176 2013/08/04 16:48:15 sjg Exp $");
+__RCSID("$NetBSD: job.c,v 1.177 2014/07/16 15:33:41 christos Exp $");
#endif
#endif /* not lint */
#endif
@@ -1346,7 +1346,7 @@
(void)fcntl(0, F_SETFD, 0);
(void)lseek(0, (off_t)0, SEEK_SET);
- if (job->node->type & OP_MAKE) {
+ if (job->node->type & (OP_MAKE | OP_SUBMAKE)) {
/*
* Pass job token pipe to submakes.
*/
diff -r 44f2149d245e -r 4502288b8fb1 usr.bin/make/make.h
--- a/usr.bin/make/make.h Wed Jul 16 14:47:59 2014 +0000
+++ b/usr.bin/make/make.h Wed Jul 16 15:33:41 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: make.h,v 1.92 2013/09/04 15:38:26 sjg Exp $ */
+/* $NetBSD: make.h,v 1.93 2014/07/16 15:33:41 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -273,6 +273,7 @@
#define OP_NOMETA 0x00080000 /* .NOMETA do not create a .meta file */
#define OP_META 0x00100000 /* .META we _do_ want a .meta file */
#define OP_NOMETA_CMP 0x00200000 /* Do not compare commands in .meta file */
+#define OP_SUBMAKE 0x00400000 /* Possibly a submake node */
/* Attributes applied by PMake */
#define OP_TRANSFORM 0x80000000 /* The node is a transformation rule */
#define OP_MEMBER 0x40000000 /* Target is a member of an archive */
diff -r 44f2149d245e -r 4502288b8fb1 usr.bin/make/parse.c
--- a/usr.bin/make/parse.c Wed Jul 16 14:47:59 2014 +0000
+++ b/usr.bin/make/parse.c Wed Jul 16 15:33:41 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.194 2014/02/15 00:17:17 christos Exp $ */
+/* $NetBSD: parse.c,v 1.195 2014/07/16 15:33:41 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: parse.c,v 1.194 2014/02/15 00:17:17 christos Exp $";
+static char rcsid[] = "$NetBSD: parse.c,v 1.195 2014/07/16 15:33:41 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: parse.c,v 1.194 2014/02/15 00:17:17 christos Exp $");
+__RCSID("$NetBSD: parse.c,v 1.195 2014/07/16 15:33:41 christos Exp $");
#endif
#endif /* not lint */
#endif
@@ -1952,6 +1952,42 @@
}
+/*
+ * ParseMaybeSubMake --
+ * Scan the command string to see if it a possible submake node
+ * Input:
+ * cmd the command to scan
+ * Results:
+ * TRUE if the command is possibly a submake, FALSE if not.
+ */
+static Boolean
+ParseMaybeSubMake(const char *cmd)
+{
+ static struct {
+ const char *name;
+ size_t len;
+ } vals[] = {
+#define MKV(A) { A, sizeof(A) - 1 }
+ MKV("${MAKE}"),
+ MKV("${.MAKE}"),
+ MKV("$(MAKE)"),
+ MKV("$(.MAKE)"),
+ MKV("make"),
+ };
+ for (size_t i = 0; i < __arraycount(vals); i++) {
+ char *ptr;
+ if ((ptr = strstr(cmd, vals[i].name)) == NULL)
+ continue;
+ if ((ptr == cmd || !isalnum((unsigned char)ptr[-1]))
+ && !isalnum((unsigned char)ptr[vals[i].len])) {
+ printf("good [%c] [%c] [%s]\n", ptr[-1], ptr[vals[i].len], cmd);
+ return TRUE;
+ }
+ printf("bad [%c] [%c] [%s]\n", ptr[-1], ptr[vals[i].len], cmd);
+ }
+ return FALSE;
+}
+
/*-
* ParseAddCmd --
* Lst_ForEach function to add a command line to all targets
@@ -1964,7 +2000,9 @@
* Always 0
*
* Side Effects:
- * A new element is added to the commands list of the node.
+ * A new element is added to the commands list of the node,
+ * and the node can be marked as a submake node if the command is
+ * determined to be that.
*/
static int
ParseAddCmd(void *gnp, void *cmd)
@@ -1978,6 +2016,8 @@
/* if target already supplied, ignore commands */
if (!(gn->type & OP_HAS_COMMANDS)) {
(void)Lst_AtEnd(gn->commands, cmd);
+ if (ParseIsSubMake(cmd))
+ gn->type |= OP_SUBMAKE;
ParseMark(gn);
} else {
#ifdef notyet
Home |
Main Index |
Thread Index |
Old Index