NetBSD Problem Report #22868

Received: (qmail 2465 invoked by uid 605); 20 Sep 2003 06:31:18 -0000
Message-Id: <200309200631.h8K6VGQo024086@diana.nimenees.com>
Date: Sat, 20 Sep 2003 01:31:16 -0500 (CDT)
From: Eric Haszlakiewicz <erh@nimenees.com>
Sender: gnats-bugs-owner@NetBSD.org
Reply-To: erh@nimenees.com
To: gnats-bugs@gnats.netbsd.org
Subject: .MADE doesn't work with suffix rules
X-Send-Pr-Version: 3.95

>Number:         22868
>Category:       toolchain
>Synopsis:       .MADE doesn't work with suffix rules
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    dholland
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Sep 20 06:32:00 +0000 2003
>Closed-Date:    
>Last-Modified:  Fri Oct 14 16:29:00 +0000 2016
>Originator:     Eric Haszlakiewicz
>Release:        NetBSD 1.6X
>Organization:
>Environment:
System: NetBSD diana.nimenees.com 1.6X NetBSD 1.6X (DIANA) #46: Fri Sep 12 02:08:14 CDT 2003 root@diana.nimenees.com:/usr/build/DIANA i386
Architecture: i386
Machine: i386
>Description:
	The use of .MADE and suffix rules doesn't work because the commands
from the suffix rule are never added to the command list for the target
being made.  It looks like the code also needs some fixups to get a few
variables (like IMPSRC and PREFIX) set correctly.
	This is the same problem described in PR #9618, but I'm creating a
separate PR b/c it's really its own bug.

>How-To-Repeat:
	See part of 9618 that complains about this problem.
>Fix:
	I'll have a fix soon.
>Release-Note:
>Audit-Trail:

From: Eric Haszlakiewicz <erh@nimenees.com>
To: gnats-admin@netbsd.org
Cc:  
Subject: Re: toolchain/22868: .MADE doesn't work with suffix rules
Date: Sat, 20 Sep 2003 01:49:02 -0500

 As promised, patch:

 Index: make.c
 ===================================================================
 RCS file: /cvsroot/src/usr.bin/make/make.c,v
 retrieving revision 1.51
 diff -u -r1.51 make.c
 --- make.c	2003/08/07 11:14:54	1.51
 +++ make.c	2003/09/20 06:47:25
 @@ -130,6 +130,7 @@
  				 * is non-zero when Job_Empty() returns
  				 * TRUE, there's a cycle in the graph */

 +static void MakeSetParentVars(GNode *);
  static int MakeAddChild(ClientData, ClientData);
  static int MakeFindChild(ClientData, ClientData);
  static int MakeUnmark(ClientData, ClientData);
 @@ -362,11 +363,12 @@
  /*-
   *-----------------------------------------------------------------------
   * MakeFindChild  --
 - *	Function used by Make_Run to find the pathname of a child
 - *	that was already made.
 + *	Function used by Make_ExpandUse to pretend that the children of
 + *      a target have been made.
   *
   * Input:
 - *	gnp		the node to find
 + *	gnp		the child node
 + *      pgnp            the parent node
   *
   * Results:
   *	Always returns 0
 @@ -374,6 +376,15 @@
   * Side Effects:
   *	The path and mtime of the node and the cmtime of the parent are
   *	updated; the unmade children count of the parent is decremented.
 + *
 + *      If OP_MADE is set on the parent, and the child does not exist,
 + *	set the FORCE flag on the parents.
 + *
 + *      The TARGET variable is set on the child.
 + *
 + *      The IMPSRC and PREFIX variables are set on all implied parents
 + *      of the child.
 + *
   *-----------------------------------------------------------------------
   */
  static int
 @@ -384,6 +395,18 @@

      (void) Dir_MTime(gn);
      Make_TimeStamp(pgn, gn);
 +
 +    if (pgn->type & OP_MADE && gn->mtime == 0)
 +    {
 +	// If the child doesn't exist, and won't be made
 +	// because .MADE was specified on the parent, force
 +	// the parent to be made.
 +	pgn->flags |= FORCE;
 +    }
 +
 +    Var_Set (TARGET, gn->path ? gn->path : gn->name, gn, 0);
 +    MakeSetParentVars(gn);
 +
      pgn->unmade--;

      return (0);
 @@ -657,14 +680,12 @@
  Make_Update(GNode *cgn)
  {
      GNode 	*pgn;	/* the parent node */
 -    char  	*cname;	/* the child's name */
      LstNode	ln; 	/* Element in parents and iParents lists */
      time_t	mtime = -1;
      char	*p1;
      Lst		parents;
      GNode	*centurion;

 -    cname = Var_Value (TARGET, cgn, &p1);
      if (p1)
  	free(p1);

 @@ -750,12 +771,38 @@
  	}
      }

 +    MakeSetParentVars(cgn);
 +}
 +
 +/*-
 + *-----------------------------------------------------------------------
 + * MakeSetParentVars --
 + *      
 + *      Set the .PREFIX and .IMPSRC variables for all the implied parents
 + *      of this node.
 + *
 + * Input:
 + *	cgn		the child node
 + *
 + * Results:
 + *	None
 + *
 + *-----------------------------------------------------------------------
 + */
 +static void
 +MakeSetParentVars(GNode *cgn)
 +{
 +    char *p1;
 +    GNode *pgn;
 +    LstNode	ln; 	/* Element in parents and iParents lists */
 +
      /*
       * Set the .PREFIX and .IMPSRC variables for all the implied parents
       * of this node.
       */
      if (Lst_Open (cgn->iParents) == SUCCESS) {
  	char	*cpref = Var_Value(PREFIX, cgn, &p1);
 +	char *cname = Var_Value (TARGET, cgn, &p1);

  	while ((ln = Lst_Next (cgn->iParents)) != NILLNODE) {
  	    pgn = (GNode *)Lst_Datum (ln);
 @@ -1132,10 +1179,10 @@
  	    Var_Set (TARGET, gn->path ? gn->path : gn->name, gn, 0);
  	    Lst_ForEach (gn->children, MakeUnmark, (ClientData)gn);
  	    Lst_ForEach (gn->children, MakeHandleUse, (ClientData)gn);
 +
 +	    Suff_FindDeps (gn);

 -	    if ((gn->type & OP_MADE) == 0)
 -		Suff_FindDeps (gn);
 -	    else {
 +	    if (gn->type & OP_MADE) {
  		/* Pretend we made all this node's children */
  		Lst_ForEach (gn->children, MakeFindChild, (ClientData)gn);
  		if (gn->unmade != 0)
Responsible-Changed-From-To: toolchain-manager->erh 
Responsible-Changed-By: erh 
Responsible-Changed-When: Sat Sep 20 03:51:32 EDT 2003 
Responsible-Changed-Why:  
I'm working on this. 
Responsible-Changed-From-To: erh->dholland
Responsible-Changed-By: dholland@NetBSD.org
Responsible-Changed-When: Fri, 14 Oct 2016 16:29:00 +0000
Responsible-Changed-Why:
(1) erh's mail is bouncing and (2) he's not done anything on this in > 10
years. and it's a make issue, so I'll try to find time to look at it.


>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-2014 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.