From nobody@FreeBSD.org  Sun Jan 18 06:03:46 2004
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id CCC2F16A4CE
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 18 Jan 2004 06:03:46 -0800 (PST)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 2E5CF43D4C
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 18 Jan 2004 06:03:42 -0800 (PST)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.12.10/8.12.10) with ESMTP id i0IE3fdL030453
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 18 Jan 2004 06:03:41 -0800 (PST)
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.12.10/8.12.10/Submit) id i0IE3fEh030451;
	Sun, 18 Jan 2004 06:03:41 -0800 (PST)
	(envelope-from nobody)
Message-Id: <200401181403.i0IE3fEh030451@www.freebsd.org>
Date: Sun, 18 Jan 2004 06:03:41 -0800 (PST)
From: Albert Hofkamp <a.t.hofkamp@tue.nl>
To: freebsd-gnats-submit@FreeBSD.org
Subject: make -j2 changes $*
X-Send-Pr-Version: www-2.0

>Number:         61527
>Category:       bin
>Synopsis:       make -j2 changes $*
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jan 18 06:10:09 PST 2004
>Closed-Date:    Thu Jan 22 02:06:02 PST 2004
>Last-Modified:  Thu Jan 22 02:06:02 PST 2004
>Originator:     Albert Hofkamp
>Release:        4.7
>Organization:
>Environment:
>Description:
with a make rule like

foo/bar.o: foo/bar.cc
        echo CC -o $*.o $<

(and an existing foo/bar.cc
'make' ouputs 'CC -o foo/bar.o foo/bar.cc' while
'make -j2' outputs 'CC -o bar.o foo/bar.cc', ie the target misses the directory part in parallel make

>How-To-Repeat:
construct a makefile like above, create a dummy foo/bar.cc, then type 'make' or 'make -j2'

>Fix:
Other than not using directories in targets or not using -j2, none

>Release-Note:
>Audit-Trail:

From: Ruslan Ermilov <ru@freebsd.org>
To: Albert Hofkamp <a.t.hofkamp@tue.nl>
Cc: freebsd-gnats-submit@freebsd.org
Subject: Re: bin/61527: make -j2 changes $*
Date: Sun, 18 Jan 2004 16:35:15 +0200

 On Sun, Jan 18, 2004 at 06:03:41AM -0800, Albert Hofkamp wrote:
 > 
 > with a make rule like
 > 
 > foo/bar.o: foo/bar.cc
 >         echo CC -o $*.o $<
 > 
 > (and an existing foo/bar.cc
 > 'make' ouputs 'CC -o foo/bar.o foo/bar.cc' while
 > 'make -j2' outputs 'CC -o bar.o foo/bar.cc', ie the target misses the directory part in parallel make
 > 
 The results will be even more surprising (at a glance) if you try
 this with ``make -r'' and ``make -r -j2''.  This is because you're
 misusing the inference rules in sys.mk and ${.PREFIX} (aka $*) and
 ${.IMPSRC} (aka $<) macros which are defined only for inference rules.
 The corrected makefile would look like this:
 
 : foo/bar.o: foo/bar.cc
 : 	@echo CC -o $@ $>
 
 or better yet:
 
 : foo/bar.o: foo/bar.cc
 : 	@echo CC -o ${.TARGET} ${.ALLSRC}
 
 which gives the same results in all four make(1) invocations.
 But please be aware that ${.ALLSRC} is dangerous because once
 you create a .depend file, there might be a dependency of the
 form ``bar.o: bar.h'' in it, and bar.h will become part of
 ${.ALLSRC}.  So the safe version would look like this:
 
 : foo/bar.o: foo/bar.cc
 : 	@echo CC -o ${.TARGET} foo/bar.cc
 
 If you need lot of such rules, you may start using the inference rule:
 
 : $ cat Makefile
 : .SUFFIXES: .cc .o
 : .cc.o:
 : 	@echo CC -o ${.TARGET} ${.IMPSRC}
 : $ make foo/bar.o
 : CC -o foo/bar.o foo/bar.cc
 : $ make -j2 foo/bar.o
 : CC -o foo/bar.o foo/bar.cc
 : $ make -r foo/bar.o
 : CC -o foo/bar.o foo/bar.cc
 : $ make -r -j2 foo/bar.o
 : CC -o foo/bar.o foo/bar.cc
 
 
 Cheers,
 -- 
 Ruslan Ermilov
 FreeBSD committer
 ru@FreeBSD.org
State-Changed-From-To: open->closed 
State-Changed-By: ru 
State-Changed-When: Thu Jan 22 02:05:31 PST 2004 
State-Changed-Why:  
Not a bug. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=61527 
>Unformatted:
