From rb@gid.co.uk Tue Apr  6 11:52:57 1999
Return-Path: <rb@gid.co.uk>
Received: from isbalham.ist.co.uk (isbalham.ist.co.uk [192.31.26.1])
	by hub.freebsd.org (Postfix) with ESMTP id 6790515579
	for <FreeBSD-gnats-submit@freebsd.org>; Tue,  6 Apr 1999 11:52:39 -0700 (PDT)
	(envelope-from rb@gid.co.uk)
Received: from gid.co.uk (uucp@localhost)
	by isbalham.ist.co.uk (8.8.7/8.8.7) with UUCP id TAA01040
	for freebsd.org!FreeBSD-gnats-submit; Tue, 6 Apr 1999 19:50:40 +0100 (BST)
	(envelope-from rb@gid.co.uk)
Message-Id: <7998.199904061835@seagoon.gid.co.uk>
Date: Tue, 6 Apr 1999 19:35:06 +0100 (BST)
From: Bob Bishop <rb@gid.co.uk>
Reply-To: rb@gid.co.uk
To: FreeBSD-gnats-submit@freebsd.org
Subject: make .NOTPARALLEL special target is broken [PATCH]
X-Send-Pr-Version: 3.2

>Number:         10985
>Category:       bin
>Synopsis:       make .NOTPARALLEL special target is broken [PATCH]
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Apr  6 12:00:01 PDT 1999
>Closed-Date:    Thu Jul 22 02:18:16 PDT 1999
>Last-Modified:  Thu Jul 22 02:20:01 PDT 1999
>Originator:     Bob Bishop
>Release:        FreeBSD 4.0-CURRENT i386
>Organization:
GID ltd
>Environment:

	-current as of Tue Apr  6 04:02:32 BST 1999

	Probably affects -STABLE too

>Description:

	.NOTPARALLEL is supposed to "Disable parallel mode".
	However, as implemented it only suppresses parallel
	remote jobs and won't stop an SMP box running parallel
	local jobs in the presence of -jn.

>How-To-Repeat:

	`make -jn -dj' with and without .NOTPARALLEL: in the
	Makefile

>Fix:
	
	Not as easy as it appears, I suspect. Complications
	arise because make has -B turned on by default unless
	-jn is in use (which certainly violated my POLA).  So
	what to do?  Should .NOTPARALLEL turn -B back on as if
	there was no -jn in the first place?  The following
	patch does so, but it's arguable.

Index: src/usr.bin/make/main.c
===================================================================
RCS file: /CVSROOT/src/usr.bin/make/main.c,v
retrieving revision 1.30
diff -c -r1.30 main.c
*** main.c	1999/03/01 06:01:05	1.30
--- main.c	1999/04/06 12:59:59
***************
*** 123,129 ****
  static Lst		variables;	/* list of variables to print */
  int			maxJobs;	/* -j argument */
  static Boolean          forceJobs;      /* -j argument given */
! static int		maxLocal;	/* -L argument */
  Boolean			compatMake;	/* -B argument */
  Boolean			debug;		/* -d flag */
  Boolean			noExecute;	/* -n flag */
--- 123,129 ----
  static Lst		variables;	/* list of variables to print */
  int			maxJobs;	/* -j argument */
  static Boolean          forceJobs;      /* -j argument given */
! int			maxLocal;	/* -L argument */
  Boolean			compatMake;	/* -B argument */
  Boolean			debug;		/* -d flag */
  Boolean			noExecute;	/* -n flag */
Index: src/usr.bin/make/parse.c
===================================================================
RCS file: /CVSROOT/src/usr.bin/make/parse.c,v
retrieving revision 1.20
diff -c -r1.20 parse.c
*** parse.c	1999/01/08 18:37:34	1.20
--- parse.c	1999/04/06 16:34:14
***************
*** 874,881 ****
--- 874,884 ----
  		    case NotParallel:
  		    {
  			extern int  maxJobs;
+ 			extern int  maxLocal;

  			maxJobs = 1;
+ 			maxLocal = 1;
+ 			compatMake = 1;	/* would have been turned on if no -j */
  			break;
  		    }
  		    case SingleShell:


>Release-Note:
>Audit-Trail:

From: hoek@FreeBSD.org
To: freebsd-gnats-submit@FreeBSD.org, rb@gid.co.uk
Cc:  
Subject: Re: bin/10985: make .NOTPARALLEL special target is broken[PATCH]
Date: Sun, 11 Jul 1999 15:59:24 -0400 (EDT)

 >
 >   How-To-Repeat
 >          
 >        `make -jn -dj' with and without .NOTPARALLEL: in the
 >        Makefile
 
 Could you give an example Makefile where .NOTPARRALLEL doesn't work?
 The .NOTPARRALLEL seems to work for me.  Include the specific arguments
 given to make(1), please.
 
 Thanks,
 
 

From: Bob Bishop <rb@gid.co.uk>
To: hoek@FreeBSD.org
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: bin/10985: make .NOTPARALLEL special target is broken[PATCH]
Date: Tue, 13 Jul 1999 00:08:43 +0000

 Hi,
 
 >>
 >>   How-To-Repeat
 >>
 >>        `make -jn -dj' with and without .NOTPARALLEL: in the
 >>        Makefile
 >
 >Could you give an example Makefile where .NOTPARRALLEL doesn't work?
 >The .NOTPARRALLEL seems to work for me.  Include the specific arguments
 >given to make(1), please.
 
 OK, it's not quite straightforward. Unshar the following...
 
 # This is a shell archive.  Save it in a file, remove anything before
 # this line, and then unpack it by entering "sh file".  Note, it may
 # create directories; files and directories will be owned by you and
 # have default permissions.
 #
 # This archive contains:
 #
 #       subdir
 #       makefile
 #       subdir/makefile
 #       subdir/thing
 #
 echo c - subdir
 mkdir -p subdir > /dev/null 2>&1
 echo x - makefile
 sed 's/^X//' >makefile << 'END-of-makefile'
 X.NOTPARALLEL:
 X
 Xall: FRC
 X       cd subdir; make
 X
 XFRC:
 END-of-makefile
 echo x - subdir/makefile
 sed 's/^X//' >subdir/makefile << 'END-of-subdir/makefile'
 Xall: thing1 thing2
 X
 Xthing1: FRC
 X       cp thing thing1
 X
 Xthing2: FRC
 X       cp thing thing2
 X
 XFRC:
 END-of-subdir/makefile
 echo x - subdir/thing
 sed 's/^X//' >subdir/thing << 'END-of-subdir/thing'
 XAny old thing
 END-of-subdir/thing
 exit
 # end of shar
 
 ...and try 'make -j2 -dj' at the top, with and without the .NOTPARALLEL.
 The problem is that the .NOTPARALLEL message isn't correctly passed to the
 submake. Try adding a .NOTPARALLEL in subdir/makefile, this will work. The
 patch in the PR fixes the problem, but I haven't tested it with remote (as
 opposed to SMP) parallel builds (I have no idea whether remote builds work
 anyway).
 
 
 --
 Bob Bishop              (0118) 977 4017  international code +44 118
 rb@gid.co.uk        fax (0118) 989 4254  between 0800 and 1800 UK
 
 
 

From: Tim Vanderhoek <vanderh@ecf.utoronto.ca>
To: Bob Bishop <rb@gid.co.uk>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: bin/10985: make .NOTPARALLEL special target is broken[PATCH]
Date: Mon, 12 Jul 1999 20:39:12 -0400

 On Tue, Jul 13, 1999 at 12:08:43AM +0000, Bob Bishop wrote:
 > 
 [...]
 > X.NOTPARALLEL:
 > X
 > Xall: FRC
 > X       cd subdir; make
 
 Cut'n'Paste error.  You lost some tabs here.
 
 > ...and try 'make -j2 -dj' at the top, with and without the .NOTPARALLEL.
 > The problem is that the .NOTPARALLEL message isn't correctly passed to the
 > submake. Try adding a .NOTPARALLEL in subdir/makefile, this will work. The
 > patch in the PR fixes the problem, but I haven't tested it with remote (as
 > opposed to SMP) parallel builds (I have no idea whether remote builds work
 
 I'm not too worried about remote builds, since the code for remote
 doesn't even exist in our sorce base.  I don't even know where it went
 away too.
 
 I'm extremely surprised that the patch in this PR fixes the problem.
 I haven't tested it.  It's not clear to me how it solves the problem,
 but I guess I'll have to find-out eventually...  :-)
 
 I'm really not sure this is even a bug.  It seems to me that
 .NOTPARALLEL should only apply to the current invocation of make.
 Consider the case where I have a top-level makefile that isn't -j
 safe.  However, it makes several programs, and individually, those
 programs are -j safe.
 
 Or, consider this case:  (using psuedo-makefile code)
 
 top-level makefile:
 
 all: prog1 prog2 prog3
 
 prog1:
 	cd prog1_dir; ${MAKE}
 
 prog2:
 	cd prog2_dir; ${MAKE}
 
 prog3:
 	cd prog3_dir; ${MAKE}
 
 Now, suppose that all the makefiles here are technically -j safe.
 However, if I use -j3 on the top makefile, I will _effectively_ be
 using -j9, since the -j3 will propogate three times to each submake.
 To solve this problem, I need to add .NOTPARALLEL to the top-level
 makefile.
 
 I think that what you are trying to accomplish with the patch in this
 PR can already be done in my.  Try using this,
 
 
 .MAKEFLAGS: -B
 
 Or, more correctly, you should probably be using this,
 
 .MAKEFLAGS: -j1
 
 but that will have a slightly different effect from your patch (that
 is, with regards to compatMake).
 
 
 Does this solve the problem better?
 
 
 -- 
 This is my .signature which gets appended to the end of my messages.
 

From: Bob Bishop <rb@gid.co.uk>
To: Tim Vanderhoek <vanderh@ecf.utoronto.ca>
Cc:  
Subject: Re: bin/10985: make .NOTPARALLEL special target is broken[PATCH]
Date: Tue, 13 Jul 1999 17:50:32 -0400

 Hi,
 
 >I'm really not sure this is even a bug.  It seems to me that
 >.NOTPARALLEL should only apply to the current invocation of make.
 
 Could be, although if that's the case the man page should be improved.
 
 >[...]
 >Now, suppose that all the makefiles here are technically -j safe.
 >However, if I use -j3 on the top makefile, I will _effectively_ be
 >using -j9, since the -j3 will propogate three times to each submake.
 >To solve this problem, I need to add .NOTPARALLEL to the top-level
 >makefile.
 
 Hmm. That could be viewed as a bug, but (a) I'm not sure it's really a
 problem, and (b) it's hard to see how to fix it, except (trivially) by not
 passing down -jx if multiple jobs have been started at the current level.
 
 >I think that what you are trying to accomplish with the patch in this
 >PR can already be done in my.  Try using this,
 >
 >
 >.MAKEFLAGS: -B
 >
 >Or, more correctly, you should probably be using this,
 >
 >.MAKEFLAGS: -j1
 
 Those work, in their different ways, but they hit the current make as well
 as submakes. In the latter case, you get -jx -j1 passed down, which isn't
 very elegant.
 
 
 --
 Bob Bishop              (0118) 977 4017  international code +44 118
 rb@gid.co.uk        fax (0118) 989 4254  between 0800 and 1800 UK
 
 
 

From: Tim Vanderhoek <vanderh@ecf.utoronto.ca>
To: Bob Bishop <rb@gid.co.uk>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: bin/10985: make .NOTPARALLEL special target is broken[PATCH]
Date: Thu, 22 Jul 1999 03:37:30 -0400

 On Tue, Jul 13, 1999 at 05:50:32PM -0400, Bob Bishop wrote:
 > 
 > >.MAKEFLAGS: -B
 > >
 > >Or, more correctly, you should probably be using this,
 > >
 > >.MAKEFLAGS: -j1
 > 
 > Those work, in their different ways, but they hit the current make as well
 > as submakes. In the latter case, you get -jx -j1 passed down, which isn't
 > very elegant.
 
 Having "-jx -j1" passed down doesn't particularly bother me at all.
 
 Anyways, the purpose of using .MAKEFLAGS was to hit the current make
 as well as submakes.  If you don't want to hist the submakes, then you
 just use .NOTPARALLEL.  It makes sense to me, anyways.  :)
 
 Do you still have a problem?
 
 
 -- 
 This is my .signature which gets appended to the end of my messages.
 

From: Bob Bishop <rb@gid.co.uk>
To: Tim Vanderhoek <vanderh@ecf.utoronto.ca>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: bin/10985: make .NOTPARALLEL special target is
  broken[PATCH]
Date: Thu, 22 Jul 1999 09:24:25 +0100

 Hi,
 
 At 03:37 22/07/99 -0400, Tim Vanderhoek wrote:
 >On Tue, Jul 13, 1999 at 05:50:32PM -0400, Bob Bishop wrote:
 >> 
 >> >.MAKEFLAGS: -B
 >> >
 >> >Or, more correctly, you should probably be using this,
 >> >
 >> >.MAKEFLAGS: -j1
 >> 
 >> Those work, in their different ways, but they hit the current make as well
 >> as submakes. In the latter case, you get -jx -j1 passed down, which isn't
 >> very elegant.
 >
 >Having "-jx -j1" passed down doesn't particularly bother me at all.
 >
 >Anyways, the purpose of using .MAKEFLAGS was to hit the current make
 >as well as submakes.  If you don't want to hist the submakes, then you
 >just use .NOTPARALLEL.  It makes sense to me, anyways.  :)
 
 Well OK, close the PR then. I'll probably suggest a clarification to the
 man page in due course.
 
 --
 Bob Bishop		    +44 118 977 4017
 rb@gid.co.uk		fax +44 118 989 4254 (0800-1800 UK)
 
State-Changed-From-To: open->closed 
State-Changed-By: hoek 
State-Changed-When: Thu Jul 22 02:18:16 PDT 1999 
State-Changed-Why:  
.NOTPARALLEL is only guaranteed to work for the current invocation of make, 
not recursively. 

From: Bob Bishop <rb@gid.co.uk>
To: Tim Vanderhoek <vanderh@ecf.utoronto.ca>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: bin/10985: make .NOTPARALLEL special target is
  broken[PATCH]
Date: Thu, 22 Jul 1999 04:24:25 -0400

 Hi,
 
 At 03:37 22/07/99 -0400, Tim Vanderhoek wrote:
 >On Tue, Jul 13, 1999 at 05:50:32PM -0400, Bob Bishop wrote:
 >> 
 >> >.MAKEFLAGS: -B
 >> >
 >> >Or, more correctly, you should probably be using this,
 >> >
 >> >.MAKEFLAGS: -j1
 >> 
 >> Those work, in their different ways, but they hit the current make as well
 >> as submakes. In the latter case, you get -jx -j1 passed down, which isn't
 >> very elegant.
 >
 >Having "-jx -j1" passed down doesn't particularly bother me at all.
 >
 >Anyways, the purpose of using .MAKEFLAGS was to hit the current make
 >as well as submakes.  If you don't want to hist the submakes, then you
 >just use .NOTPARALLEL.  It makes sense to me, anyways.  :)
 
 Well OK, close the PR then. I'll probably suggest a clarification to the
 man page in due course.
 
 --
 Bob Bishop		    +44 118 977 4017
 rb@gid.co.uk		fax +44 118 989 4254 (0800-1800 UK)
 
>Unformatted:
