NetBSD Problem Report #43534

From dholland@eecs.harvard.edu  Sun Jun 27 01:12:56 2010
Return-Path: <dholland@eecs.harvard.edu>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id EEF0263B873
	for <gnats-bugs@gnats.NetBSD.org>; Sun, 27 Jun 2010 01:12:55 +0000 (UTC)
Message-Id: <20100627011216.EEE04FA13@tanaqui.eecs.harvard.edu>
Date: Sat, 26 Jun 2010 21:12:16 -0400 (EDT)
From: dholland@eecs.harvard.edu
Reply-To: dholland@eecs.harvard.edu
To: gnats-bugs@gnats.NetBSD.org
Subject: make does not set $* for PHONY targets
X-Send-Pr-Version: 3.95

>Number:         43534
>Notify-List:    Wolfgang.Stukenbrock@nagler-company.com
>Category:       bin
>Synopsis:       make does not set $* for PHONY targets
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Jun 27 01:15:00 +0000 2010
>Last-Modified:  Tue Jul 06 04:00:04 +0000 2010
>Originator:     David A. Holland
>Release:        NetBSD 5.99.33 (20100627)
>Organization:
>Environment:
System: NetBSD tanaqui 5.99.22 NetBSD 5.99.22 (TANAQUI) #31: Tue Dec 8 22:53:35 EST 2009 dholland@tanaqui:/usr/src/sys/arch/i386/compile/TANAQUI i386
Architecture: i386
Machine: i386
>Description:

$* a.k.a. $(.PREFIX) is not set for targets marked .PHONY.

This problem was noted as part of PR 43502 from Wolfgang Stukenbrock,
but is a separable issue.

>How-To-Repeat:

   ---
foo bar:
	echo $*

.PHONY: bar
   ---

   % make foo
   echo foo
   foo
   % make bar
   echo 

   % 

>Fix:

Not entirely clear. If it's just a matter of setting it to $@ by
default, setting it along with .TARGET on/near line 1333 of make.c
should do the trick; an explicit suffix match later will replace that
setting with the right one.

However, if we want any suffix that may be present to be removed, it's
not so trivial.

Since a comment on line 2412 of suff.c says that suffix rules aren't
used with .PHONY, maybe the former is adequate. It isn't consistent
with gmake; however, gmake is hardly the gold standard and it varies
in some other ways as well.

I'd like a second opinion or two.

>Release-Note:

>Audit-Trail:
From: David Laight <david@l8s.co.uk>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/43534: make does not set $* for PHONY targets
Date: Sun, 27 Jun 2010 09:38:11 +0100

 On Sun, Jun 27, 2010 at 01:15:01AM +0000, dholland@eecs.harvard.edu wrote:
 > >Number:         43534
 > >Category:       bin
 > >Synopsis:       make does not set $* for PHONY targets
 ...
 > $* a.k.a. $(.PREFIX) is not set for targets marked .PHONY.

 Some of the make variables are only defined for 'inference rules'
 (IIRC the name correctly) which include the suffix rules.
 In other cases the actual value is known to the makefile writer.
 It is likely that $* is one of these.

 	David

 -- 
 David Laight: david@l8s.co.uk

From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/43534: make does not set $* for PHONY targets
Date: Sun, 27 Jun 2010 20:49:31 +0000

 On Sun, Jun 27, 2010 at 08:35:02AM +0000, David Laight wrote:
  >  > $* a.k.a. $(.PREFIX) is not set for targets marked .PHONY.
  >  
  >  Some of the make variables are only defined for 'inference rules'
  >  (IIRC the name correctly) which include the suffix rules.
  >  In other cases the actual value is known to the makefile writer.
  >  It is likely that $* is one of these.

 I thought this at first (see what I committed to make.1 last night...)
 but it's not.

 It works for everything that isn't declared .PHONY, and it's because
 of the logic I pointed to that returns early out of suff.c for phony
 targets.

 Anyway, do you have an opinion on whether $* for a phony target (given
 that it isn't going to match any suffix rules) should or should not
 have suffixes pruned from it?

 After sleeping on it I'm inclined to think it shouldn't.

 -- 
 David A. Holland
 dholland@netbsd.org

From: "David A. Holland" <dholland@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/43534 CVS commit: src/usr.bin/make
Date: Wed, 30 Jun 2010 00:25:04 +0000

 Module Name:	src
 Committed By:	dholland
 Date:		Wed Jun 30 00:25:04 UTC 2010

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

 Log Message:
 Set .PREFIX early the same place .TARGET is set. This makes sure it's
 defined even in cases where the suffix search logic is skipped, such
 as .PHONY targets, and fixes PR 43534.

 Note: because .PHONY targets do not get suffix searching, .PREFIX will
 not have any suffixes removed. This seems vaguely logical, although
 it's not the only reasonable interpretation.

 We may also want to reconsider whether suffix rules are skipped for
 phony targets, too. That behavior is somewhat counterintuitive.


 To generate a diff of this commit:
 cvs rdiff -u -r1.79 -r1.80 src/usr.bin/make/make.c

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

From: "David A. Holland" <dholland@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/43534 CVS commit: src/usr.bin/make
Date: Tue, 6 Jul 2010 03:57:00 +0000

 Module Name:	src
 Committed By:	dholland
 Date:		Tue Jul  6 03:56:59 UTC 2010

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

 Log Message:
 Revert 1.80, which somehow manages to produce different (wrong)
 behavior with -jN. Unfixes PR 43534. Need a different approach...


 To generate a diff of this commit:
 cvs rdiff -u -r1.80 -r1.81 src/usr.bin/make/make.c

 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.