NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

bin/51376: make(1) and deleting failed outputs



>Number:         51376
>Category:       bin
>Synopsis:       make(1) and deleting failed outputs
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Fri Jul 29 20:25:00 +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...



Home | Main Index | Thread Index | Old Index