NetBSD Problem Report #49087

From jarmo.jaakkola@roskakori.fi  Thu Aug  7 16:19:54 2014
Return-Path: <jarmo.jaakkola@roskakori.fi>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 1C312AB8F6
	for <gnats-bugs@gnats.NetBSD.org>; Thu,  7 Aug 2014 16:19:54 +0000 (UTC)
Message-Id: <20140807161952.16A295312@roskakori.fi>
Date: Thu,  7 Aug 2014 19:19:52 +0300 (EEST)
From: Jarmo Jaakkola <jarmo.jaakkola@roskakori.fi>
Reply-To: Jarmo Jaakkola <jarmo.jaakkola@roskakori.fi>
To: gnats-bugs@gnats.NetBSD.org
Subject: some makefiles in src/ use $(.IMPSRC) in explicit rules
X-Send-Pr-Version: 3.95

>Number:         49087
>Category:       toolchain
>Synopsis:       $(.IMPSRC) is incorrectly used in some explicit rules
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    toolchain-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Aug 07 16:20:00 +0000 2014
>Last-Modified:  Thu Aug 21 08:55:00 +0000 2014
>Originator:     Jarmo Jaakkola <jarmo.jaakkola@roskakori.fi>
>Release:        NetBSD 6.1.2_PATCH
>Organization:
>Environment:
System: NetBSD kotoisa.roskakori.fi 6.1.2_PATCH NetBSD 6.1.2_PATCH (KOTOISA) #5: Mon Jan 20 17:01:44 EET 2014 jammuli@kotoisa.roskakori.fi:/usr/src/sys/arch/amd64/compile/KOTOISA amd64
Architecture: x86_64
Machine: amd64
>Description:

Two makefiles in the src/ tree use $(.IMPSRC) in rules which are not
suffix transformation rules.  This should not work as that variable
is not supposed to exist for explicit rules.

It happens to work because there is a bug in make(1), which causes
implicit and explicit dependencies from transformation rules to be
applied on all applicable explicit rules. (see PR ?????, issue 8)

The offending makefiles are:
	src/external/gpl3/gcc/lib/libgcc/Makefile.inc
	src/lib/libc/net/Makefile.inc

>How-To-Repeat:

N/A

>Fix:

Don't use ${.IMPSRC} in non-transformation rules.

This is most probably NOT a proper fix, only a quick workaround.
A proper fix should most likely utilize suffix transformation rules.
---
 external/gpl3/gcc/lib/libgcc/Makefile.inc | 11 +++++++----
 lib/libc/net/Makefile.inc                 |  2 +-
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/external/gpl3/gcc/lib/libgcc/Makefile.inc b/external/gpl3/gcc/lib/libgcc/Makefile.inc
index 4819914..645350f 100644
--- a/external/gpl3/gcc/lib/libgcc/Makefile.inc
+++ b/external/gpl3/gcc/lib/libgcc/Makefile.inc
@@ -149,21 +149,24 @@ ${LIB1ASMFUNCS}: ${.CURDIR}/Makefile
 	printf '#define L${.PREFIX}\n#include <${G_LIB1ASMSRC}>\n' >${.TARGET}
 .endif

+# XXX: this is ugly, can this be done with transformation rules?
+
 ${LIB2_EH:.c=.o}:
 	${_MKTARGET_COMPILE}
-	${COMPILE.c} -fexceptions ${COPTS.${.IMPSRC:T}} -o ${.TARGET} ${.IMPSRC}
+	${COMPILE.c} -fexceptions ${COPTS.${.TARGET:.o=.c}} -o ${.TARGET} ${.ALLSRC:M*${.TARGET:.o=.c}}
+

 ${LIB2_EH:.c=.pico}:
 	${_MKTARGET_COMPILE}
-	${COMPILE.c} ${CPICFLAGS} -fexceptions ${COPTS.${.IMPSRC:T}} -o ${.TARGET} ${.IMPSRC}
+	${COMPILE.c} ${CPICFLAGS} -fexceptions ${COPTS.${.TARGET:.pico=.c}} -o ${.TARGET} ${.ALLSRC:M*${.TARGET:.pico=.c}}

 ${G_LIB2_DIVMOD_FUNCS:=.o}:
 	${_MKTARGET_COMPILE}
-	${COMPILE.c} -fexceptions -fnon-call-exceptions ${COPTS.${.IMPSRC:T}} -o ${.TARGET} ${.IMPSRC}
+	${COMPILE.c} -fexceptions -fnon-call-exceptions ${COPTS.${.TARGET:.o=.c}} -o ${.TARGET} ${.ALLSRC:M*${.TARGET:.o=.c}}

 ${G_LIB2_DIVMOD_FUNCS:=.pico}:
 	${_MKTARGET_COMPILE}
-	${COMPILE.c} ${CPICFLAGS} -fexceptions -fnon-call-exceptions ${COPTS.${.IMPSRC:T}} -o ${.TARGET} ${.IMPSRC}
+	${COMPILE.c} ${CPICFLAGS} -fexceptions -fnon-call-exceptions ${COPTS.${.TARGET:.pico=.c}} -o ${.TARGET} ${.ALLSRC:M*${.TARGET:.pico=.c}}

 dp-bit.c: ${.CURDIR}/Makefile
 	${_MKTARGET_CREATE}
diff --git a/lib/libc/net/Makefile.inc b/lib/libc/net/Makefile.inc
index 08b3b66..7115871 100644
--- a/lib/libc/net/Makefile.inc
+++ b/lib/libc/net/Makefile.inc
@@ -36,7 +36,7 @@ CLEANFILES+=nsparser.c nslexer.c nsparser.h

 nslexer.c: nslexer.l nsparser.h
 	${_MKTARGET_LEX}
-	${LEX.l} -t ${.IMPSRC} | sed -e '/YY_BUF_SIZE/s/16384/1024/' >${.TARGET}
+	${LEX.l} -t ${.ALLSRC:M*nslexer.l} | sed -e '/YY_BUF_SIZE/s/16384/1024/' >${.TARGET}

 # machine-dependent net sources
 # m-d Makefile.inc must include sources for:

>Audit-Trail:
From: Jarmo Jaakkola <jarmo.jaakkola@roskakori.fi>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: toolchain/49087: some makefiles in src/ use $(.IMPSRC) in
	explicit rules
Date: Thu, 7 Aug 2014 19:26:46 +0300

 Sorry, I forgot to fill in the number of the referenced PR.

 It is PR 49086.

   http://gnats.netbsd.org/49086

 -- 
 Jarmo Jaakkola

From: Jarmo Jaakkola <jarmo.jaakkola@roskakori.fi>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: toolchain/49087: some makefiles in src/ use $(.IMPSRC) in
	explicit rules
Date: Tue, 19 Aug 2014 21:57:12 +0300

 After discussions on tech-toolchain (1), it was revealed to me that
 $(.IMPSRC) should be available like it is in gmake, not be unavailable
 like the manual page says.  The proper way of making $(.IMPSRC) available
 is now implemented in the patch for PR 49086.

 However, src/external/gpl3/gcc/lib/libgcc/Makefile.inc won't still work
 because its dependencies are not properly specified even for
 the improved functionality.  A proper patch for that file can be found from
     http://roskakori.fi/software/bugs/NetBSD/PR49087/patch
 (use dynamic sources to specify the C file dependency)

 src/lib/libc/net/Makefile.inc is fine.

 1) http://mail-index.netbsd.org/tech-toolchain/2014/08/18/msg002351.html

 -- 
 Jarmo Jaakkola

From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/49087 CVS commit: src/external/gpl3/gcc/lib/libgcc
Date: Thu, 21 Aug 2014 04:52:24 -0400

 Module Name:	src
 Committed By:	christos
 Date:		Thu Aug 21 08:52:24 UTC 2014

 Modified Files:
 	src/external/gpl3/gcc/lib/libgcc: Makefile.inc

 Log Message:
 PR/49087: Jarmo Jaakkola: Make sure that the first dependency is the C source
 file so ${.IMPSRC} gets set correctly.


 To generate a diff of this commit:
 cvs rdiff -u -r1.28 -r1.29 src/external/gpl3/gcc/lib/libgcc/Makefile.inc

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

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.