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:       make: .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:  Mon May 09 23:39:05 +0000 2022
>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.


From: Roland Illig <roland.illig@gmx.de>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: toolchain/22868
Date: Tue, 22 Jun 2021 15:29:56 +0200

 This is a multi-part message in MIME format.
 --------------62D69E7BA6E1A281715D8872
 Content-Type: text/plain; charset=utf-8
 Content-Transfer-Encoding: 7bit

 Here is the patch from 2003, updated to apply to current make.

 Since the patch affects an area of make that I'm not familiar with, I
 will not commit it myself as-is.  There are a lot of tricky edge cases
 in suffix handling, as well as a few remaining bugs, and there should be
 more unit tests.

 The existing tests named suff-*.mk already cover some parts of the code,
 but there should be a new test that clearly demonstrates what this patch
 does.


 --------------62D69E7BA6E1A281715D8872
 Content-Type: text/plain; charset=UTF-8;
  name="pr-22868.patch"
 Content-Transfer-Encoding: base64
 Content-Disposition: attachment;
  filename="pr-22868.patch"

 SW5kZXg6IG1ha2UuYwo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
 PT09PT09PT09PT09PT09PT09PT09PT09PT09ClJDUyBmaWxlOiAvY3Zzcm9vdC9zcmMvdXNy
 LmJpbi9tYWtlL21ha2UuYyx2CnJldHJpZXZpbmcgcmV2aXNpb24gMS4yNDQKZGlmZiAtdSAt
 cCAtcjEuMjQ0IG1ha2UuYwotLS0gbWFrZS5jCTQgQXByIDIwMjEgMTA6MDU6MDggLTAwMDAJ
 MS4yNDQKKysrIG1ha2UuYwkyMSBKdW4gMjAyMSAwOTo1Mjo1MiAtMDAwMApAQCAtMTE3LDYg
 KzExNyw5IEBAIHN0YXRpYyB1bnNpZ25lZCBpbnQgY2hlY2tlZF9zZXFubyA9IDE7CiBzdGF0
 aWMgR05vZGVMaXN0IHRvQmVNYWRlID0gTFNUX0lOSVQ7CiAKIAorc3RhdGljIHZvaWQgVXBk
 YXRlSW1wbGljaXRQYXJlbnRzVmFycyhHTm9kZSAqLCBjb25zdCBjaGFyICopOworCisKIHZv
 aWQKIGRlYnVnX3ByaW50Zihjb25zdCBjaGFyICpmbXQsIC4uLikKIHsKQEAgLTM1NCw2ICsz
 NTcsMTggQEAgUHJldGVuZEFsbENoaWxkcmVuQXJlTWFkZShHTm9kZSAqcGduKQogCQkvKiBU
 aGlzIG1heSBhbHNvIHVwZGF0ZS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
 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
 PT09ClJDUyBmaWxlOiAvY3Zzcm9vdC9zcmMvdXNyLmJpbi9tYWtlL3VuaXQtdGVzdHMvYXJj
 aGl2ZS1zdWZmaXguZXhwLHYKcmV0cmlldmluZyByZXZpc2lvbiAxLjEKZGlmZiAtdSAtcCAt
 cjEuMSBhcmNoaXZlLXN1ZmZpeC5leHAKLS0tIHVuaXQtdGVzdHMvYXJjaGl2ZS1zdWZmaXgu
 ZXhwCTI5IEF1ZyAyMDIwIDE0OjQ3OjI2IC0wMDAwCTEuMQorKysgdW5pdC10ZXN0cy9hcmNo
 aXZlLXN1ZmZpeC5leHAJMjEgSnVuIDIwMjEgMDk6NTI6NTIgLTAwMDAKQEAgLTEsMiArMSwy
 IEBACi1gYWxsJyBpcyB1cCB0byBkYXRlLgorOiBtYWtpbmcgb2JqMS5jCiBleGl0IHN0YXR1
 cyAwCg==
 --------------62D69E7BA6E1A281715D8872--

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.