Module Name: src Committed By: christos Date: Wed Jul 16 15:33:41 UTC 2014
Modified Files: src/usr.bin/make: job.c make.h parse.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.176 -r1.177 src/usr.bin/make/job.c cvs rdiff -u -r1.92 -r1.93 src/usr.bin/make/make.h cvs rdiff -u -r1.194 -r1.195 src/usr.bin/make/parse.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/make/job.c diff -u src/usr.bin/make/job.c:1.176 src/usr.bin/make/job.c:1.177 --- src/usr.bin/make/job.c:1.176 Sun Aug 4 12:48:15 2013 +++ src/usr.bin/make/job.c Wed Jul 16 11:33:41 2014 @@ -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 @@ JobExec(Job *job, char **argv) (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. */ Index: src/usr.bin/make/make.h diff -u src/usr.bin/make/make.h:1.92 src/usr.bin/make/make.h:1.93 --- src/usr.bin/make/make.h:1.92 Wed Sep 4 11:38:26 2013 +++ src/usr.bin/make/make.h Wed Jul 16 11:33:41 2014 @@ -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 @@ typedef struct GNode { #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 */ Index: src/usr.bin/make/parse.c diff -u src/usr.bin/make/parse.c:1.194 src/usr.bin/make/parse.c:1.195 --- src/usr.bin/make/parse.c:1.194 Fri Feb 14 19:17:17 2014 +++ src/usr.bin/make/parse.c Wed Jul 16 11:33:41 2014 @@ -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 @@ Parse_DoVar(char *line, GNode *ctxt) } +/* + * 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 @@ Parse_DoVar(char *line, GNode *ctxt) * 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 @@ ParseAddCmd(void *gnp, void *cmd) /* 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