NetBSD Problem Report #9618

Received: (qmail 24575 invoked from network); 14 Mar 2000 21:31:40 -0000
Message-Id: <200003142124.PAA14003@realms.nimenees.com>
Date: Tue, 14 Mar 2000 15:24:29 -0600 (CST)
From: erh@nimenees.com
Reply-To: erh@nimenees.com
To: gnats-bugs@gnats.netbsd.org
Subject: make depend fails to run mkdep sometimes.
X-Send-Pr-Version: 3.95

>Number:         9618
>Category:       toolchain
>Synopsis:       make depend fails to run mkdep sometimes.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    erh
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Mar 14 13:33:00 +0000 2000
>Closed-Date:    Mon Dec 01 01:35:12 +0000 2014
>Last-Modified:  Mon Dec 01 01:35:12 +0000 2014
>Originator:     Eric Haszlakiewicz
>Release:        NetBSD-current 20000313
>Organization:
>Environment:
System: NetBSD realms.nimenees.com 1.4T NetBSD 1.4T (REALMS) #0: Mon Feb 21 13:01:03 CST 2000 root@realms.nimenees.com:/usr/build/REALMS i386


>Description:
	Running a make depend isn't always enough to ensure that dependancies
get updated.  It is only correct in the case where included files don't
include another file themselves.  Since only the modification dates of
the .depend file and the original source file (the one on which mkdep is run)
are compared a change in an included file will not be noticed.
>How-To-Repeat:
File foo.c:
	#include "bar.h"

File bar.h:
	#include "bar2.h"

File bar2.h:
	... whatever ...

File bar3.h:
	... whatever ...

File Makefile:
	SRCS=foo.c
	.include <bsd.prog.mk>

run make depend.  Notice that .depend contains correct dependencies
	(bar.h and bar2.h)
edit bar.h and add #include "bar3.h"
run make depend.  Notice that mkdep isn't run and .depend is incorrect.
(This is more of a problem if an included file is removed but still
exists in .depend since an error will occur when trying to build)

>Fix:
	workaround: remove all .depend files before running make depend.
	fix: cause make to check modification times on all files in
		the dependancy list.  this seems like it would slow
		things down a lot.
>Release-Note:
>Audit-Trail:

From: Eric Haszlakiewicz <erh@nimenees.com>
To: gnats-bugs@netbsd.org
Cc:  
Subject: Re: toolchain/9618
Date: Mon, 15 Sep 2003 13:22:43 -0500

 	Here is a partial fix, which adds the .d to the .depend file in addition
 to the .o file (and .ln, etc...).  It doesn't work when a file gets removed.
 That could theoretically be solved by using .MADE, but that doesn't seem
 to work with suffix rules. e.g.:

 Makefile:
 	.SUFFIXES: .A .x

 	aaa.A: .MADE
 	aaa.A: aaa.x

 	.x.A:
 		touch $@

 "touch aaa.x ; make aaa.A" doesn't do anything unless the .MADE line is
 commented out.
 Adding -dm to make says that aaa.A is out of date, but then nothing gets
 done about it.

 Index: bsd.hostlib.mk
 ===================================================================
 RCS file: /cvsroot/src/share/mk/bsd.hostlib.mk,v
 retrieving revision 1.7
 diff -u -r1.7 bsd.hostlib.mk
 --- bsd.hostlib.mk	2003/08/01 17:04:01	1.7
 +++ bsd.hostlib.mk	2003/09/15 18:22:00
 @@ -54,7 +54,7 @@
  .if defined(SRCS)
  afterdepend: .depend
  	@(TMP=/tmp/_depend$$$$; trap 'rm -f $$TMP ; exit 1' 1 2 3 13 15; \
 -	    sed -e 's/^\([^\.]*\).o[ ]*:/\1.lo:/' \
 +	    sed -e 's/^\([^\.]*\).o[ ]*:/\1.lo \1.d:/' \
  	      < .depend > $$TMP; \
  	    mv $$TMP .depend)
  .endif
 Index: bsd.hostprog.mk
 ===================================================================
 RCS file: /cvsroot/src/share/mk/bsd.hostprog.mk,v
 retrieving revision 1.32
 diff -u -r1.32 bsd.hostprog.mk
 --- bsd.hostprog.mk	2003/08/01 17:04:01	1.32
 +++ bsd.hostprog.mk	2003/09/15 18:22:00
 @@ -98,7 +98,7 @@
  .if defined(SRCS)
  afterdepend: .depend
  	@(TMP=/tmp/_depend$$$$; trap 'rm -f $$TMP ; exit 1' 1 2 3 13 15; \
 -	    sed -e 's/^\([^\.]*\).o[ ]*:/\1.lo \1.ln:/' \
 +	    sed -e 's/^\([^\.]*\).o[ ]*:/\1.lo \1.ln \1.d:/' \
  	      < .depend > $$TMP; \
  	    mv $$TMP .depend)
  .endif
 Index: bsd.lib.mk
 ===================================================================
 RCS file: /cvsroot/src/share/mk/bsd.lib.mk,v
 retrieving revision 1.234
 diff -u -r1.234 bsd.lib.mk
 --- bsd.lib.mk	2003/09/13 19:08:27	1.234
 +++ bsd.lib.mk	2003/09/15 18:22:01
 @@ -433,7 +433,7 @@
  .if defined(SRCS)
  afterdepend: .depend
  	@(TMP=/tmp/_depend$$$$; trap 'rm -f $$TMP ; exit 1' 1 2 3 13 15; \
 -	    sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.po \1.so \1.ln:/' \
 +	    sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.po \1.so \1.ln \1.d:/' \
  	      < .depend > $$TMP && \
  	    mv $$TMP .depend)
  .endif
 Index: bsd.prog.mk
 ===================================================================
 RCS file: /cvsroot/src/share/mk/bsd.prog.mk,v
 retrieving revision 1.187
 diff -u -r1.187 bsd.prog.mk
 --- bsd.prog.mk	2003/09/14 22:36:55	1.187
 +++ bsd.prog.mk	2003/09/15 18:22:01
 @@ -208,7 +208,7 @@
  .if defined(SRCS) && !target(afterdepend)
  afterdepend: .depend
  	@(TMP=/tmp/_depend$$$$; trap 'rm -f $$TMP ; exit 1' 1 2 3 13 15; \
 -	    sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.ln:/' \
 +	    sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.ln \1.d:/' \
  	      < .depend > $$TMP; \
  	    mv $$TMP .depend)
  .endif
Responsible-Changed-From-To: misc-bug-people->erh 
Responsible-Changed-By: erh 
Responsible-Changed-When: Sat Sep 20 04:00:44 EDT 2003 
Responsible-Changed-Why:  
I'm working on this. 

From: Eric Haszlakiewicz <erh@nimenees.com>
To: gnats-bugs@netbsd.org
Cc:  
Subject: Re: toolchain/9618
Date: Sat, 20 Sep 2003 03:06:47 -0500

 Here's a better patch.  This one extends the .depend modifying sed command 
 to add dependencies for foo.d, and adds a .MADE attribute to the .d file
 so missing files aren't made, and unmakable files don't cause an error.
 This is needed to allow the .depend file to be rebuilt when files go away.
 Due to the increased complexity of the sed script, I put it in a variable
 (${__DPSED}) in bsd.dep.mk.
 	This depends on the fix in PR #22898 in order to work.

 Index: bsd.dep.mk
 ===================================================================
 RCS file: /cvsroot/src/share/mk/bsd.dep.mk,v
 retrieving revision 1.57
 diff -u -r1.57 bsd.dep.mk
 --- bsd.dep.mk	2003/08/11 09:59:43	1.57
 +++ bsd.dep.mk	2003/09/20 08:01:40
 @@ -32,6 +32,18 @@
  	@rm -f .depend
  	cat ${__DPSRCS.d} /dev/null > .depend

 +# These are sed scripts used to fiddle with the .depend file.
 +# They add additional dependencies for .ln and .d files, 
 +# and for libraries .po and .so files.
 +__DPSED='  \
 +	/^\([^\.]*\).o[ ]*:/ { \
 +		h ; \
 +		s/^\([^\.]*\).o[ ]*:/'${__DPSED_REPLACE}' \1.d:/ ; \
 +		x ; \
 +		s/^\([^\.]*\).o[ ]*:.*/\1.d: .MADE/ ; \
 +		G ; \
 +	} '
 +
  .SUFFIXES: .d .s .S .c .C .cc .cpp .cxx .m

  .c.d:
 Index: bsd.hostlib.mk
 ===================================================================
 RCS file: /cvsroot/src/share/mk/bsd.hostlib.mk,v
 retrieving revision 1.7
 diff -u -r1.7 bsd.hostlib.mk
 --- bsd.hostlib.mk	2003/08/01 17:04:01	1.7
 +++ bsd.hostlib.mk	2003/09/20 08:01:40
 @@ -52,9 +52,10 @@
  CPPFLAGS:=	${HOST_CPPFLAGS}

  .if defined(SRCS)
 +__DPSED_REPLACE='\1.lo'
  afterdepend: .depend
  	@(TMP=/tmp/_depend$$$$; trap 'rm -f $$TMP ; exit 1' 1 2 3 13 15; \
 -	    sed -e 's/^\([^\.]*\).o[ ]*:/\1.lo:/' \
 +	    sed -e ${__DPSED} \
  	      < .depend > $$TMP; \
  	    mv $$TMP .depend)
  .endif
 Index: bsd.hostprog.mk
 ===================================================================
 RCS file: /cvsroot/src/share/mk/bsd.hostprog.mk,v
 retrieving revision 1.32
 diff -u -r1.32 bsd.hostprog.mk
 --- bsd.hostprog.mk	2003/08/01 17:04:01	1.32
 +++ bsd.hostprog.mk	2003/09/20 08:01:40
 @@ -96,9 +96,10 @@
  CPPFLAGS:=	${HOST_CPPFLAGS}

  .if defined(SRCS)
 +__DPSED_REPLACE='\1.lo \1.ln'
  afterdepend: .depend
  	@(TMP=/tmp/_depend$$$$; trap 'rm -f $$TMP ; exit 1' 1 2 3 13 15; \
 -	    sed -e 's/^\([^\.]*\).o[ ]*:/\1.lo \1.ln:/' \
 +	    sed -e ${__DPSED} \
  	      < .depend > $$TMP; \
  	    mv $$TMP .depend)
  .endif
 Index: bsd.lib.mk
 ===================================================================
 RCS file: /cvsroot/src/share/mk/bsd.lib.mk,v
 retrieving revision 1.234
 diff -u -r1.234 bsd.lib.mk
 --- bsd.lib.mk	2003/09/13 19:08:27	1.234
 +++ bsd.lib.mk	2003/09/20 08:01:40
 @@ -431,9 +431,10 @@
  	rm -f llib-l${LIB}.ln ${LOBJS}

  .if defined(SRCS)
 +__DPSED_REPLACE='\1.o \1.po \1.so \1.ln'
  afterdepend: .depend
  	@(TMP=/tmp/_depend$$$$; trap 'rm -f $$TMP ; exit 1' 1 2 3 13 15; \
 -	    sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.po \1.so \1.ln:/' \
 +	    sed -e ${__DPSED} \
  	      < .depend > $$TMP && \
  	    mv $$TMP .depend)
  .endif
 Index: bsd.prog.mk
 ===================================================================
 RCS file: /cvsroot/src/share/mk/bsd.prog.mk,v
 retrieving revision 1.188
 diff -u -r1.188 bsd.prog.mk
 --- bsd.prog.mk	2003/09/19 16:32:10	1.188
 +++ bsd.prog.mk	2003/09/20 08:01:40
 @@ -203,9 +203,10 @@
  .endif

  .if defined(SRCS) && !target(afterdepend)
 +__DPSED_REPLACE='\1.o \1.ln'
  afterdepend: .depend
  	@(TMP=/tmp/_depend$$$$; trap 'rm -f $$TMP ; exit 1' 1 2 3 13 15; \
 -	    sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.ln:/' \
 +		sed -e ${__DPSED} \
  	      < .depend > $$TMP; \
  	    mv $$TMP .depend)
  .endif
State-Changed-From-To: open->closed
State-Changed-By: erh@NetBSD.org
State-Changed-When: Mon, 01 Dec 2014 01:35:12 +0000
State-Changed-Why:
Fix committed.


>Unformatted:

 Here's a final patch that applies to the current state of the mk files.
 This does not depend on the .MADE bug being fixed, although that is still
 a problem.
 I noticed minimal performance difference buildind with or without these
 changes (30s in 1.5 hr build).

 Index: share/mk/bsd.dep.mk
 ===================================================================
 RCS file: /cvsroot/src/share/mk/bsd.dep.mk,v
 retrieving revision 1.81
 diff -u -r1.81 bsd.dep.mk
 --- share/mk/bsd.dep.mk	19 Jul 2014 17:19:22 -0000	1.81
 +++ share/mk/bsd.dep.mk	30 Nov 2014 22:50:40 -0000
 @@ -9,7 +9,7 @@
 ##### Default values
 MKDEP?=			mkdep
 MKDEPCXX?=		mkdep
 -MKDEP_SUFFIXES?=	.o
 +MKDEP_SUFFIXES?=	.o .d

 ##### Build rules
 # some of the rules involve .h sources, so remove them from mkdep line
 Index: share/mk/bsd.hostlib.mk
 ===================================================================
 RCS file: /cvsroot/src/share/mk/bsd.hostlib.mk,v
 retrieving revision 1.18
 diff -u -r1.18 bsd.hostlib.mk
 --- share/mk/bsd.hostlib.mk	10 Apr 2014 19:02:18 -0000	1.18
 +++ share/mk/bsd.hostlib.mk	30 Nov 2014 22:50:40 -0000
 @@ -7,7 +7,7 @@

 ##### Default values
 CFLAGS+=	${COPTS}
 -MKDEP_SUFFIXES?=	.o .lo
 +MKDEP_SUFFIXES?=	.o .lo .d

 # Override these:
 MKDEP:=		${HOST_MKDEP}
 Index: share/mk/bsd.hostprog.mk
 ===================================================================
 RCS file: /cvsroot/src/share/mk/bsd.hostprog.mk,v
 retrieving revision 1.73
 diff -u -r1.73 bsd.hostprog.mk
 --- share/mk/bsd.hostprog.mk	10 Apr 2014 19:02:18 -0000	1.73
 +++ share/mk/bsd.hostprog.mk	30 Nov 2014 22:50:40 -0000
 @@ -81,7 +81,7 @@
 LIBRUMPFS_UDF?=		/usr/lib/librumpfs_udf.a
 LIBRUMPFS_UFS?=		/usr/lib/librumpfs_ufs.a

 -MKDEP_SUFFIXES?=	.lo .ln
 +MKDEP_SUFFIXES?=	.lo .ln .d

 # Override these:
 INSTALL:=	${INSTALL:NSTRIP=*}
 Index: share/mk/bsd.lib.mk
 ===================================================================
 RCS file: /cvsroot/src/share/mk/bsd.lib.mk,v
 retrieving revision 1.355
 diff -u -r1.355 bsd.lib.mk
 --- share/mk/bsd.lib.mk	13 Jun 2014 01:17:45 -0000	1.355
 +++ share/mk/bsd.lib.mk	30 Nov 2014 22:50:40 -0000
 @@ -64,7 +64,7 @@
 .endif									# }

 ##### Build and install rules
 -MKDEP_SUFFIXES?=	.o .po .pico .go .ln
 +MKDEP_SUFFIXES?=	.o .po .pico .go .ln .d

 .if !defined(SHLIB_MAJOR) && exists(${SHLIB_VERSION_FILE})		# {
 SHLIB_MAJOR != . ${SHLIB_VERSION_FILE} ; echo $$major
 Index: share/mk/bsd.prog.mk
 ===================================================================
 RCS file: /cvsroot/src/share/mk/bsd.prog.mk,v
 retrieving revision 1.290
 diff -u -r1.290 bsd.prog.mk
 --- share/mk/bsd.prog.mk	25 Mar 2014 09:52:55 -0000	1.290
 +++ share/mk/bsd.prog.mk	30 Nov 2014 22:50:40 -0000
 @@ -59,7 +59,7 @@
 CFLAGS+=	-g
 .endif
 OBJCFLAGS+=	${OBJCOPTS}
 -MKDEP_SUFFIXES?=	.o .ln
 +MKDEP_SUFFIXES?=	.o .ln .d

 # CTF preserve debug symbols
 .if (${MKCTF:Uno} != "no") && (${CFLAGS:M-g} != "")

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.