Module Name: src
Committed By: rillig
Date: Mon Dec 7 01:04:07 UTC 2020
Modified Files:
src/usr.bin/make: compat.c
src/usr.bin/make/unit-tests: deptgt-end-fail-all.exp
deptgt-end-fail-all.mk deptgt-end-fail.exp deptgt-end-fail.mk
Log Message:
make(1): don't make .END if the main targets already failed
This only applies to -k mode. By default, make exits earlier and skips
the .END node as well if an error occurs.
To generate a diff of this commit:
cvs rdiff -u -r1.199 -r1.200 src/usr.bin/make/compat.c
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/deptgt-end-fail-all.exp \
src/usr.bin/make/unit-tests/deptgt-end-fail-all.mk
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/deptgt-end-fail.exp \
src/usr.bin/make/unit-tests/deptgt-end-fail.mk
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/make/compat.c
diff -u src/usr.bin/make/compat.c:1.199 src/usr.bin/make/compat.c:1.200
--- src/usr.bin/make/compat.c:1.199 Mon Dec 7 00:53:30 2020
+++ src/usr.bin/make/compat.c Mon Dec 7 01:04:06 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: compat.c,v 1.199 2020/12/07 00:53:30 rillig Exp $ */
+/* $NetBSD: compat.c,v 1.200 2020/12/07 01:04:06 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -96,7 +96,7 @@
#include "pathnames.h"
/* "@(#)compat.c 8.2 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: compat.c,v 1.199 2020/12/07 00:53:30 rillig Exp $");
+MAKE_RCSID("$NetBSD: compat.c,v 1.200 2020/12/07 01:04:06 rillig Exp $");
static GNode *curTarg = NULL;
static pid_t compatChild;
@@ -729,7 +729,7 @@ Compat_Run(GNodeList *targs)
/*
* If the user has defined a .END target, run its commands.
*/
- if (!mainDepError) {
+ if (!mainError && !mainDepError) {
GNode *endNode = Targ_GetEndNode();
Compat_Make(endNode, endNode);
endError = GNode_IsError(endNode);
Index: src/usr.bin/make/unit-tests/deptgt-end-fail-all.exp
diff -u src/usr.bin/make/unit-tests/deptgt-end-fail-all.exp:1.1 src/usr.bin/make/unit-tests/deptgt-end-fail-all.exp:1.2
--- src/usr.bin/make/unit-tests/deptgt-end-fail-all.exp:1.1 Sun Dec 6 21:22:04 2020
+++ src/usr.bin/make/unit-tests/deptgt-end-fail-all.exp Mon Dec 7 01:04:06 2020
@@ -1,9 +1,6 @@
: Making all out of nothing.
false
*** Error code 1 (continuing)
-: Making .END out of nothing.
-false
-*** Error code 1 (continuing)
Stop.
make: stopped in unit-tests
Index: src/usr.bin/make/unit-tests/deptgt-end-fail-all.mk
diff -u src/usr.bin/make/unit-tests/deptgt-end-fail-all.mk:1.1 src/usr.bin/make/unit-tests/deptgt-end-fail-all.mk:1.2
--- src/usr.bin/make/unit-tests/deptgt-end-fail-all.mk:1.1 Sun Dec 6 21:22:04 2020
+++ src/usr.bin/make/unit-tests/deptgt-end-fail-all.mk Mon Dec 7 01:04:07 2020
@@ -1,8 +1,14 @@
-# $NetBSD: deptgt-end-fail-all.mk,v 1.1 2020/12/06 21:22:04 rillig Exp $
+# $NetBSD: deptgt-end-fail-all.mk,v 1.2 2020/12/07 01:04:07 rillig Exp $
#
# Test whether the commands from the .END target are run even if there is
# an error before. The manual page says "after everything else is done",
# which leaves room for interpretation.
+#
+# Until 2020-12-07, the .END node was made even if the main nodes had failed.
+# This was not intended since the .END node had already been skipped if a
+# dependency of the main nodes had failed, just not if one of the main nodes
+# themselves had failed. This inconsistency was not worth keeping. To run
+# some commands on error, use the .ERROR target instead, see deptgt-error.mk.
all: .PHONY
: Making ${.TARGET} out of nothing.
Index: src/usr.bin/make/unit-tests/deptgt-end-fail.exp
diff -u src/usr.bin/make/unit-tests/deptgt-end-fail.exp:1.5 src/usr.bin/make/unit-tests/deptgt-end-fail.exp:1.6
--- src/usr.bin/make/unit-tests/deptgt-end-fail.exp:1.5 Mon Dec 7 00:53:30 2020
+++ src/usr.bin/make/unit-tests/deptgt-end-fail.exp Mon Dec 7 01:04:07 2020
@@ -84,8 +84,6 @@ Test case all=ERR all-dep=ok end=ok end-
: Making all-dep out of nothing.
: Making all from all-dep.
*** Error code 1 (continuing)
-: Making end-dep out of nothing.
-: Making .END from end-dep.
Stop.
make: stopped in unit-tests
@@ -96,8 +94,6 @@ Test case all=ERR all-dep=ok end=ok end-
: Making all-dep out of nothing.
: Making all from all-dep.
*** Error code 1 (continuing)
-: Making end-dep out of nothing.
-*** Error code 1 (continuing)
Stop.
make: stopped in unit-tests
@@ -108,9 +104,6 @@ Test case all=ERR all-dep=ok end=ERR end
: Making all-dep out of nothing.
: Making all from all-dep.
*** Error code 1 (continuing)
-: Making end-dep out of nothing.
-: Making .END from end-dep.
-*** Error code 1 (continuing)
Stop.
make: stopped in unit-tests
@@ -121,8 +114,6 @@ Test case all=ERR all-dep=ok end=ERR end
: Making all-dep out of nothing.
: Making all from all-dep.
*** Error code 1 (continuing)
-: Making end-dep out of nothing.
-*** Error code 1 (continuing)
Stop.
make: stopped in unit-tests
Index: src/usr.bin/make/unit-tests/deptgt-end-fail.mk
diff -u src/usr.bin/make/unit-tests/deptgt-end-fail.mk:1.5 src/usr.bin/make/unit-tests/deptgt-end-fail.mk:1.6
--- src/usr.bin/make/unit-tests/deptgt-end-fail.mk:1.5 Mon Dec 7 00:53:30 2020
+++ src/usr.bin/make/unit-tests/deptgt-end-fail.mk Mon Dec 7 01:04:07 2020
@@ -1,4 +1,4 @@
-# $NetBSD: deptgt-end-fail.mk,v 1.5 2020/12/07 00:53:30 rillig Exp $
+# $NetBSD: deptgt-end-fail.mk,v 1.6 2020/12/07 01:04:07 rillig Exp $
#
# Tests for an errors in the main target, its dependencies,
# the .END node and its dependencies.
@@ -63,5 +63,7 @@ end-dep:
# because of errors.", followed by "exit status 0", which contradicted
# each other.
-# XXX: As of 2020-12-06, '.END' is made if 'all' fails, but if a dependency
-# of 'all' fails, it is skipped. This is inconsistent.
+# Until 2020-12-07, '.END' was even made if 'all' failed, but if a dependency
+# of 'all' failed, it was skipped. This inconsistency was not needed for
+# anything and thus has been dropped. To run some commands on error, use the
+# .ERROR target instead, see deptgt-error.mk.