NetBSD Problem Report #51376

From dholland@macaran.eecs.harvard.edu  Fri Jul 29 20:24:38 2016
Return-Path: <dholland@macaran.eecs.harvard.edu>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(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 8A6EF7A1B7
	for <gnats-bugs@gnats.NetBSD.org>; Fri, 29 Jul 2016 20:24:38 +0000 (UTC)
Message-Id: <20160729202410.A91016E266@macaran.eecs.harvard.edu>
Date: Fri, 29 Jul 2016 16:24:10 -0400 (EDT)
From: dholland@eecs.harvard.edu
Reply-To: dholland@NetBSD.org
To: gnats-bugs@NetBSD.org
Subject: make(1) and deleting failed outputs
X-Send-Pr-Version: 3.95

>Number:         51376
>Category:       bin
>Synopsis:       make(1) and deleting failed outputs
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          closed
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Fri Jul 29 20:25:00 +0000 2016
>Closed-Date:    Fri Aug 26 23:31:49 +0000 2016
>Last-Modified:  Fri Aug 26 23:31:49 +0000 2016
>Originator:     David A. Holland
>Release:        NetBSD 7.99.30 (20160608)
>Organization:
>Environment:
System: NetBSD macaran 7.99.30 NetBSD 7.99.30 (MACARAN) #39: Tue Jun 7 15:26:15 EDT 2016 dholland@macaran:/usr/src/sys/arch/amd64/compile/MACARAN amd64
Architecture: x86_64
Machine: amd64
>Description:

Given a make rule of the form

	foo: bar
		./dostuff bar > foo

make exhibits the following behavior:

(1) if make receives a signal while the recipe is executing, foo is
removed on behalf of the interrupted recipe; but

(2) if the recipe fails, foo is *not* removed but is left in place,
and since it's now newer than bar it won't be rebuilt on the next run.

This behavior is traditional (gmake does the same by default) but not
optimal. The standard workaround is to write the rule as

	foo: bar
		./dostuff bar > foo.new
		mv -f foo.new foo

but this has multiple downsides:
   - it uses an extra filename undeclared to make
   - it does extra directory ops (of a type that's heavily
     synchronized) and generates unnecessary I/O overhead
   - it's easily overlooked when writing makefiles

gmake will delete targets after recipe failure if you put
	.DELETE_ON_ERROR:
in your makefile; this is kind of a hack (especially since it's a
global switch and not per-target) but maybe worthwhile.

Our make doesn't have anything for this, so I'm wondering if we should
adopt the gmake hack, or invent our own better thing, or even maybe
just make it the default behavior.

>How-To-Repeat:
n/a
>Fix:

please discuss...

>Release-Note:

>Audit-Trail:
From: christos@zoulas.com (Christos Zoulas)
To: gnats-bugs@NetBSD.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Cc: 
Subject: Re: bin/51376: make(1) and deleting failed outputs
Date: Sat, 30 Jul 2016 02:12:51 -0400

 I think we should adopt the same variable name for the same behavior.

 christos

From: matthew green <mrg@eterna.com.au>
To: christos@zoulas.com (Christos Zoulas)
Cc: gnats-bugs@NetBSD.org, gnats-admin@netbsd.org,
    netbsd-bugs@netbsd.org
Subject: re: bin/51376: make(1) and deleting failed outputs
Date: Thu, 04 Aug 2016 18:06:17 +1000

 > I think we should adopt the same variable name for the same behavior.

 me too.

From: "David A. Holland" <dholland@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/51376 CVS commit: src/usr.bin/make
Date: Fri, 26 Aug 2016 23:28:39 +0000

 Module Name:	src
 Committed By:	dholland
 Date:		Fri Aug 26 23:28:39 UTC 2016

 Modified Files:
 	src/usr.bin/make: compat.c job.c main.c make.h parse.c

 Log Message:
 Add a .DELETE_ON_ERROR: magic target that causes *failed* targets as
 well as *interrupted* targets to be deleted. The name and behavior of
 the variable matches gmake.

 Also fix a glitch in newline output on error in compat mode that I
 discovered while doing it.

 Closes PR 51376.


 To generate a diff of this commit:
 cvs rdiff -u -r1.105 -r1.106 src/usr.bin/make/compat.c
 cvs rdiff -u -r1.187 -r1.188 src/usr.bin/make/job.c
 cvs rdiff -u -r1.250 -r1.251 src/usr.bin/make/main.c
 cvs rdiff -u -r1.100 -r1.101 src/usr.bin/make/make.h
 cvs rdiff -u -r1.214 -r1.215 src/usr.bin/make/parse.c

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

State-Changed-From-To: open->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Fri, 26 Aug 2016 23:31:49 +0000
State-Changed-Why:
fixed


>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.