NetBSD Problem Report #40115

From asau@inbox.ru  Fri Dec  5 23:18:17 2008
Return-Path: <asau@inbox.ru>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by narn.NetBSD.org (Postfix) with ESMTP id 489E763BAE7
	for <gnats-bugs@gnats.NetBSD.org>; Fri,  5 Dec 2008 23:18:17 +0000 (UTC)
Message-Id: <87tz9irz2j.fsf@inbox.ru>
Date: Sat, 06 Dec 2008 02:18:12 +0300
From: Aleksej Saushev <asau@inbox.ru>
Reply-To:
To: gnats-bugs@gnats.NetBSD.org
Subject: make(1) behaviour is inconsistent across parallel and ordinary builds

>Number:         40115
>Category:       bin
>Synopsis:       make(1) behaviour is inconsistent across parallel and ordinary builds
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Dec 05 23:20:00 +0000 2008
>Closed-Date:    Tue May 03 09:15:30 +0000 2011
>Last-Modified:  Wed May 04 21:15:03 +0000 2011
>Originator:     Aleksej Saushev <asau@inbox.ru>
>Release:        NetBSD 5.0_BETA
>Organization:
>Environment:
System: NetBSD asau.local 5.0_BETA NetBSD 5.0_BETA (KERN) #0: Fri Nov 28 23:33:42 MSK 2008 asau@asau.local:/mnt/heap/asau/obj/sys/arch/i386/compile/KERN i386
Architecture: i386
Machine: i386
>Description:
	When running parallel build, change of working directory affects
	consequent command associated to the same target.
	This behaviour is inconsistent with ordinary build, where
	working directory is restored for all consequent commands.

	Create two subdirectories "this" and "that" and the following Makefile:

	all: .PHONY
		pwd && cd ${.CURDIR}/this && echo this
		pwd && cd ${.CURDIR}/that && echo that

	Now run "make" and "make -j2":

	$ make
	pwd && cd /tmp/mk/this && echo this
	/tmp/mk
	this
	pwd && cd /tmp/mk/that && echo that
	/tmp/mk
	that
	$ make -j2
	--- all ---
	pwd && cd /tmp/mk/this && echo this
	/tmp/mk
	this
	pwd && cd /tmp/mk/that && echo that
	/tmp/mk/this
	that

	Notice, that in the second ("-j2") case the working directory of
	the second ("that") command differs from respective of the first
	case: "/tmp/mk/this" vs. "/tmp/mk".

	make(1) exhibit the same behaviour for "-j1":

        $ make -j1
        pwd && cd /tmp/mk/this && echo this
        /tmp/mk
        this
        pwd && cd /tmp/mk/that && echo that
        /tmp/mk/this
        that
>How-To-Repeat:
        mkdir this that
        cat > Makefile << EOF
        all: .PHONY
		pwd && cd ${.CURDIR}/this && echo this
		pwd && cd ${.CURDIR}/that && echo that
	EOF
        make
        make -j1
>Fix:

>Release-Note:

>Audit-Trail:
From: christos@zoulas.com (Christos Zoulas)
To: gnats-bugs@NetBSD.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Cc: 
Subject: Re: bin/40115: make(1) behaviour is inconsistent across parallel and ordinary builds
Date: Sat, 6 Dec 2008 23:53:13 -0500

 On Dec 5, 11:20pm, asau@inbox.ru (Aleksej Saushev) wrote:
 -- Subject: bin/40115: make(1) behaviour is inconsistent across parallel and 

 This is not a bug. When -j is present, make tries to execute multiple
 shell commands in a single shell instance for efficiency. This is not
 very well documented in the man page, but -B gives a hint about it.
 If you want to execute each line in its own shell process, use -B.
 Most shell snippets that don't cd or chdir, benefit from the new way
 of execution.

 christos

From: Aleksej Saushev <asau@inbox.ru>
To: gnats-bugs@NetBSD.org
Cc: gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Subject: Re: bin/40115: make(1) behaviour is inconsistent across parallel and ordinary builds
Date: Sun, 07 Dec 2008 11:02:33 +0300

 christos@zoulas.com (Christos Zoulas) writes:

 >  This is not a bug. When -j is present, make tries to execute multiple
 >  shell commands in a single shell instance for efficiency. This is not
 >  very well documented in the man page, but -B gives a hint about it.
 >  If you want to execute each line in its own shell process, use -B.
 >  Most shell snippets that don't cd or chdir, benefit from the new way
 >  of execution.

 I'd rather say, it isn't documented at all. The respective parts read:

 -B
    Try to be backwards compatible by executing a single shell per
    command and by executing the commands to make the sources of a
    dependency line in sequence.

 -j max_jobs
    Specify the maximum number of jobs that make may have running at
    any one time.  Turns compatibility mode off, unless the B flag is
    also specified.

 That "try to be backwards compatible by executing a single shell per
 command" gives only a delicate hint, which is far from obvious. In my
 opinion "-j" part should mention it explicitly: "All commands associated
 with [particular? - fix style, please!] target are executed in single
 shell invocation."

 Why is it backwards compatible mode, which is on by default?
 Why don't make make run commands in single shell invocation
 and request explicit backward compatibility? Does it break
 too much code?


 -- 
 HE CE3OH...

From: christos@zoulas.com (Christos Zoulas)
To: Aleksej Saushev <asau@inbox.ru>, gnats-bugs@NetBSD.org
Cc: gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Subject: Re: bin/40115: make(1) behaviour is inconsistent across parallel and ordinary builds
Date: Sun, 7 Dec 2008 10:16:19 -0500

 On Dec 7, 11:02am, asau@inbox.ru (Aleksej Saushev) wrote:
 -- Subject: Re: bin/40115: make(1) behaviour is inconsistent across parallel 

 | christos@zoulas.com (Christos Zoulas) writes:
 | 
 | >  This is not a bug. When -j is present, make tries to execute multiple
 | >  shell commands in a single shell instance for efficiency. This is not
 | >  very well documented in the man page, but -B gives a hint about it.
 | >  If you want to execute each line in its own shell process, use -B.
 | >  Most shell snippets that don't cd or chdir, benefit from the new way
 | >  of execution.
 | 
 | I'd rather say, it isn't documented at all. The respective parts read:
 | 
 | -B
 |    Try to be backwards compatible by executing a single shell per
 |    command and by executing the commands to make the sources of a
 |    dependency line in sequence.
 | 
 | -j max_jobs
 |    Specify the maximum number of jobs that make may have running at
 |    any one time.  Turns compatibility mode off, unless the B flag is
 |    also specified.
 | 
 | That "try to be backwards compatible by executing a single shell per
 | command" gives only a delicate hint, which is far from obvious. In my
 | opinion "-j" part should mention it explicitly: "All commands associated
 | with [particular? - fix style, please!] target are executed in single
 | shell invocation."
 | 
 | Why is it backwards compatible mode, which is on by default?
 | Why don't make make run commands in single shell invocation
 | and request explicit backward compatibility? Does it break
 | too much code?

 pmake was the make front end used by Sprint. If -j was specified, make
 used "customs" a remote execution daemon to fork jobs on different
 machines. It would have been very inefficient and difficult to control
 to execute command by command on the remote system, so I guess they
 chose to execute all the commands for a specified target in one shot.

 christos

State-Changed-From-To: open->closed
State-Changed-By: jruoho@NetBSD.org
State-Changed-When: Tue, 03 May 2011 09:15:30 +0000
State-Changed-Why:

Let's trust christos@'s and close this as "not a bug".



From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/40115 CVS commit: src/usr.bin/make
Date: Wed, 4 May 2011 17:14:56 -0400

 Module Name:	src
 Committed By:	christos
 Date:		Wed May  4 21:14:56 UTC 2011

 Modified Files:
 	src/usr.bin/make: make.1

 Log Message:
 Document what I wrote for PR/40115


 To generate a diff of this commit:
 cvs rdiff -u -r1.189 -r1.190 src/usr.bin/make/make.1

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.