Module Name: src
Committed By: rillig
Date: Mon Dec 7 00:53:30 UTC 2020
Modified Files:
src/usr.bin/make: compat.c
src/usr.bin/make/unit-tests: dep-percent.exp deptgt-end-fail.exp
deptgt-end-fail.mk opt-debug-errors.exp opt-file.exp
opt-keep-going.exp opt-keep-going.mk posix.exp suff-add-later.exp
suff-clear-regular.exp suff-clear-regular.mk suff-clear-single.exp
suff-main-several.exp suff-self.exp suff-transform-endless.exp
suff-transform-expand.exp suff-transform-select.exp
use-inference.exp use-inference.mk
Log Message:
make(1): fix exit status in -k mode if a dependency fails
Whether in -k mode or not, the exit status tells whether all requested
targets were made or not. If a dependency could not be made, the main
target was not made as well, therefore the exit status must be nonzero
in such a case.
This part of the code lacked proper unit tests until today. The unit
test deptgt-end-fail.mk is compatible with make>=2003 at least, allowing
to compare the output over time.
In 2003, in the ok-ok-ok-ok case, "Making all from all-dep." was printed
twice in a row, for whatever reason ... (40 minutes later) ... If I had
just made the two commands for 'all' and '.END' more distinguishable.
Back in 2003, the local variables for .END had not been initialized,
instead the .END node was run with the local variables of the last
preceding node. In this case, that node was 'all', therefore ${.TARGET}
had obviously expanded to 'all'.
Somewhere in 2004, the shell commands were no longer run with the -e
flag, which resulted in the "exit status $?" line to be printed in cases
that had stopped early before.
Somewhere in 2005, the local variables for the .END node had been fixed.
The variable ${.TARGET} now had the value '.END', just as expected. In
addition, the dependencies for the .END node were made, although without
getting their proper local variables. This resulted in the output
"Making out of nothing" instead of the expected "Making end-dep out of
nothing".
Still in 2005, in the test case "all=ok all-dep=ok end=ok end-dep=ERR",
the error code of the failed 'end-dep' was first reported as "*** Error
code 1 (continuing)". To compensate for this improvement, a new bug had
been introduced. The test case "all=ok all-dep=ok end=ERR end-dep=ERR"
had properly exited with status 1 on 2005-01-01, but on 2006-01-01 it
exited with status 0, thereby ignoring errors in the .END node.
Somewhere in 2008, some of the error messages (but not all) were
directed to stderr instead of stdout. The actual output stayed the same
though.
Somewhere in 2011, the dependency of the .END node got its own local
variables, and ${.TARGET} now expanded to 'end-dep', as expected.
Somewhere in 2016, the two empty lines between the "*** Error code 1
(continuing)" and the "Stop." got compressed into a single empty line.
On 2020-12-07 (that is, today), the exit status 1 has been restored in
the error cases, after it had been wrong for at least 14 years.
To generate a diff of this commit:
cvs rdiff -u -r1.198 -r1.199 src/usr.bin/make/compat.c
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/dep-percent.exp \
src/usr.bin/make/unit-tests/posix.exp \
src/usr.bin/make/unit-tests/suff-clear-regular.exp \
src/usr.bin/make/unit-tests/suff-clear-regular.mk \
src/usr.bin/make/unit-tests/suff-clear-single.exp \
src/usr.bin/make/unit-tests/suff-self.exp \
src/usr.bin/make/unit-tests/suff-transform-expand.exp \
src/usr.bin/make/unit-tests/use-inference.exp
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/deptgt-end-fail.exp \
src/usr.bin/make/unit-tests/deptgt-end-fail.mk \
src/usr.bin/make/unit-tests/opt-file.exp
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/opt-debug-errors.exp \
src/usr.bin/make/unit-tests/use-inference.mk
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/opt-keep-going.exp \
src/usr.bin/make/unit-tests/suff-add-later.exp \
src/usr.bin/make/unit-tests/suff-main-several.exp \
src/usr.bin/make/unit-tests/suff-transform-endless.exp \
src/usr.bin/make/unit-tests/suff-transform-select.exp
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/opt-keep-going.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.198 src/usr.bin/make/compat.c:1.199
--- src/usr.bin/make/compat.c:1.198 Sun Dec 6 23:02:56 2020
+++ src/usr.bin/make/compat.c Mon Dec 7 00:53:30 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: compat.c,v 1.198 2020/12/06 23:02:56 rillig Exp $ */
+/* $NetBSD: compat.c,v 1.199 2020/12/07 00:53:30 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.198 2020/12/06 23:02:56 rillig Exp $");
+MAKE_RCSID("$NetBSD: compat.c,v 1.199 2020/12/07 00:53:30 rillig Exp $");
static GNode *curTarg = NULL;
static pid_t compatChild;
@@ -736,7 +736,7 @@ Compat_Run(GNodeList *targs)
} else
endError = FALSE;
- if (!mainDepError && (mainError || endError)) {
+ if (mainDepError || mainError || endError) {
PrintOnError(gn, "\nStop.");
exit(1);
}
Index: src/usr.bin/make/unit-tests/dep-percent.exp
diff -u src/usr.bin/make/unit-tests/dep-percent.exp:1.1 src/usr.bin/make/unit-tests/dep-percent.exp:1.2
--- src/usr.bin/make/unit-tests/dep-percent.exp:1.1 Fri Oct 23 19:54:35 2020
+++ src/usr.bin/make/unit-tests/dep-percent.exp Mon Dec 7 00:53:30 2020
@@ -1,3 +1,6 @@
make: don't know how to make dep-percent.o (continuing)
`all' not remade because of errors.
-exit status 0
+
+Stop.
+make: stopped in unit-tests
+exit status 1
Index: src/usr.bin/make/unit-tests/posix.exp
diff -u src/usr.bin/make/unit-tests/posix.exp:1.1 src/usr.bin/make/unit-tests/posix.exp:1.2
--- src/usr.bin/make/unit-tests/posix.exp:1.1 Thu Aug 21 13:44:51 2014
+++ src/usr.bin/make/unit-tests/posix.exp Mon Dec 7 00:53:30 2020
@@ -20,4 +20,7 @@ a command prefixed by '+' executes even
Now we expect an error...
*** Error code 1 (continuing)
`all' not remade because of errors.
-exit status 0
+
+Stop.
+make: stopped in unit-tests
+exit status 1
Index: src/usr.bin/make/unit-tests/suff-clear-regular.exp
diff -u src/usr.bin/make/unit-tests/suff-clear-regular.exp:1.1 src/usr.bin/make/unit-tests/suff-clear-regular.exp:1.2
--- src/usr.bin/make/unit-tests/suff-clear-regular.exp:1.1 Tue Oct 20 20:36:53 2020
+++ src/usr.bin/make/unit-tests/suff-clear-regular.exp Mon Dec 7 00:53:30 2020
@@ -2,4 +2,7 @@ make: don't know how to make .a (continu
make: don't know how to make .a.b (continuing)
make: don't know how to make .b.a (continuing)
`all' not remade because of errors.
-exit status 0
+
+Stop.
+make: stopped in unit-tests
+exit status 1
Index: src/usr.bin/make/unit-tests/suff-clear-regular.mk
diff -u src/usr.bin/make/unit-tests/suff-clear-regular.mk:1.1 src/usr.bin/make/unit-tests/suff-clear-regular.mk:1.2
--- src/usr.bin/make/unit-tests/suff-clear-regular.mk:1.1 Tue Oct 20 20:36:53 2020
+++ src/usr.bin/make/unit-tests/suff-clear-regular.mk Mon Dec 7 00:53:30 2020
@@ -1,4 +1,4 @@
-# $NetBSD: suff-clear-regular.mk,v 1.1 2020/10/20 20:36:53 rillig Exp $
+# $NetBSD: suff-clear-regular.mk,v 1.2 2020/12/07 00:53:30 rillig Exp $
#
# https://gnats.netbsd.org/49086, issue 4:
# Suffix rules do not become regular rules when .SUFFIXES is cleared.
@@ -27,5 +27,4 @@ all: .a .a.b .b.a
# XXX: don't know how to make .a
# XXX: don't know how to make .a.b
# XXX: don't know how to make .b.a
-# XXX: exit status 0
#.MAKEFLAGS: -dg1
Index: src/usr.bin/make/unit-tests/suff-clear-single.exp
diff -u src/usr.bin/make/unit-tests/suff-clear-single.exp:1.1 src/usr.bin/make/unit-tests/suff-clear-single.exp:1.2
--- src/usr.bin/make/unit-tests/suff-clear-single.exp:1.1 Tue Oct 20 20:36:53 2020
+++ src/usr.bin/make/unit-tests/suff-clear-single.exp Mon Dec 7 00:53:30 2020
@@ -1,3 +1,6 @@
make: don't know how to make issue3 (continuing)
`all' not remade because of errors.
-exit status 0
+
+Stop.
+make: stopped in unit-tests
+exit status 1
Index: src/usr.bin/make/unit-tests/suff-self.exp
diff -u src/usr.bin/make/unit-tests/suff-self.exp:1.1 src/usr.bin/make/unit-tests/suff-self.exp:1.2
--- src/usr.bin/make/unit-tests/suff-self.exp:1.1 Mon Nov 16 15:12:16 2020
+++ src/usr.bin/make/unit-tests/suff-self.exp Mon Dec 7 00:53:30 2020
@@ -1,3 +1,6 @@
make: Graph cycles through suff-self.suff
`all' not remade because of errors.
-exit status 0
+
+Stop.
+make: stopped in unit-tests
+exit status 1
Index: src/usr.bin/make/unit-tests/suff-transform-expand.exp
diff -u src/usr.bin/make/unit-tests/suff-transform-expand.exp:1.1 src/usr.bin/make/unit-tests/suff-transform-expand.exp:1.2
--- src/usr.bin/make/unit-tests/suff-transform-expand.exp:1.1 Tue Oct 20 20:36:53 2020
+++ src/usr.bin/make/unit-tests/suff-transform-expand.exp Mon Dec 7 00:53:30 2020
@@ -2,4 +2,7 @@
make: don't know how to make .first (continuing)
: 'Making issue11.second out of nothing.'
`all' not remade because of errors.
-exit status 0
+
+Stop.
+make: stopped in unit-tests
+exit status 1
Index: src/usr.bin/make/unit-tests/use-inference.exp
diff -u src/usr.bin/make/unit-tests/use-inference.exp:1.1 src/usr.bin/make/unit-tests/use-inference.exp:1.2
--- src/usr.bin/make/unit-tests/use-inference.exp:1.1 Sun Aug 9 16:32:28 2020
+++ src/usr.bin/make/unit-tests/use-inference.exp Mon Dec 7 00:53:30 2020
@@ -1,4 +1,7 @@
Building use-inference.from from nothing
make: don't know how to make use-inference.to (continuing)
`all' not remade because of errors.
-exit status 0
+
+Stop.
+make: stopped in unit-tests
+exit status 1
Index: src/usr.bin/make/unit-tests/deptgt-end-fail.exp
diff -u src/usr.bin/make/unit-tests/deptgt-end-fail.exp:1.4 src/usr.bin/make/unit-tests/deptgt-end-fail.exp:1.5
--- src/usr.bin/make/unit-tests/deptgt-end-fail.exp:1.4 Sun Dec 6 22:36:58 2020
+++ src/usr.bin/make/unit-tests/deptgt-end-fail.exp Mon Dec 7 00:53:30 2020
@@ -44,28 +44,40 @@ Test case all=ok all-dep=ERR end=ok end-
: Making all-dep out of nothing.
*** Error code 1 (continuing)
`all' not remade because of errors.
-exit status 0
+
+Stop.
+make: stopped in unit-tests
+exit status 1
Test case all=ok all-dep=ERR end=ok end-dep=ERR.
: Making all-dep out of nothing.
*** Error code 1 (continuing)
`all' not remade because of errors.
-exit status 0
+
+Stop.
+make: stopped in unit-tests
+exit status 1
Test case all=ok all-dep=ERR end=ERR end-dep=ok.
: Making all-dep out of nothing.
*** Error code 1 (continuing)
`all' not remade because of errors.
-exit status 0
+
+Stop.
+make: stopped in unit-tests
+exit status 1
Test case all=ok all-dep=ERR end=ERR end-dep=ERR.
: Making all-dep out of nothing.
*** Error code 1 (continuing)
`all' not remade because of errors.
-exit status 0
+
+Stop.
+make: stopped in unit-tests
+exit status 1
Test case all=ERR all-dep=ok end=ok end-dep=ok.
@@ -121,28 +133,40 @@ Test case all=ERR all-dep=ERR end=ok end
: Making all-dep out of nothing.
*** Error code 1 (continuing)
`all' not remade because of errors.
-exit status 0
+
+Stop.
+make: stopped in unit-tests
+exit status 1
Test case all=ERR all-dep=ERR end=ok end-dep=ERR.
: Making all-dep out of nothing.
*** Error code 1 (continuing)
`all' not remade because of errors.
-exit status 0
+
+Stop.
+make: stopped in unit-tests
+exit status 1
Test case all=ERR all-dep=ERR end=ERR end-dep=ok.
: Making all-dep out of nothing.
*** Error code 1 (continuing)
`all' not remade because of errors.
-exit status 0
+
+Stop.
+make: stopped in unit-tests
+exit status 1
Test case all=ERR all-dep=ERR end=ERR end-dep=ERR.
: Making all-dep out of nothing.
*** Error code 1 (continuing)
`all' not remade because of errors.
-exit status 0
+
+Stop.
+make: stopped in unit-tests
+exit status 1
exit status 0
Index: src/usr.bin/make/unit-tests/deptgt-end-fail.mk
diff -u src/usr.bin/make/unit-tests/deptgt-end-fail.mk:1.4 src/usr.bin/make/unit-tests/deptgt-end-fail.mk:1.5
--- src/usr.bin/make/unit-tests/deptgt-end-fail.mk:1.4 Sun Dec 6 22:36:58 2020
+++ src/usr.bin/make/unit-tests/deptgt-end-fail.mk Mon Dec 7 00:53:30 2020
@@ -1,4 +1,4 @@
-# $NetBSD: deptgt-end-fail.mk,v 1.4 2020/12/06 22:36:58 rillig Exp $
+# $NetBSD: deptgt-end-fail.mk,v 1.5 2020/12/07 00:53:30 rillig Exp $
#
# Tests for an errors in the main target, its dependencies,
# the .END node and its dependencies.
@@ -59,8 +59,9 @@ end-dep:
.endif
-# XXX: As of 2020-12-06, several of the test cases printed "`all' not remade
-# because of errors.", followed by "exit status 0". This doesn't match.
+# Until 2020-12-07, several of the test cases printed "`all' not remade
+# 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.
Index: src/usr.bin/make/unit-tests/opt-file.exp
diff -u src/usr.bin/make/unit-tests/opt-file.exp:1.4 src/usr.bin/make/unit-tests/opt-file.exp:1.5
--- src/usr.bin/make/unit-tests/opt-file.exp:1.4 Sun Dec 6 20:33:44 2020
+++ src/usr.bin/make/unit-tests/opt-file.exp Mon Dec 7 00:53:30 2020
@@ -4,4 +4,7 @@ make: Fatal errors encountered -- cannot
make: stopped in unit-tests
*** Error code 1 (continuing)
`all' not remade because of errors.
-exit status 0
+
+Stop.
+make: stopped in unit-tests
+exit status 1
Index: src/usr.bin/make/unit-tests/opt-debug-errors.exp
diff -u src/usr.bin/make/unit-tests/opt-debug-errors.exp:1.2 src/usr.bin/make/unit-tests/opt-debug-errors.exp:1.3
--- src/usr.bin/make/unit-tests/opt-debug-errors.exp:1.2 Sun Sep 6 04:35:03 2020
+++ src/usr.bin/make/unit-tests/opt-debug-errors.exp Mon Dec 7 00:53:30 2020
@@ -31,4 +31,7 @@ word1 word2
*** Failed command: echo 'word1' 'word2'; false
*** Error code 1 (continuing)
`all' not remade because of errors.
-exit status 0
+
+Stop.
+make: stopped in unit-tests
+exit status 1
Index: src/usr.bin/make/unit-tests/use-inference.mk
diff -u src/usr.bin/make/unit-tests/use-inference.mk:1.2 src/usr.bin/make/unit-tests/use-inference.mk:1.3
--- src/usr.bin/make/unit-tests/use-inference.mk:1.2 Thu Nov 5 00:41:04 2020
+++ src/usr.bin/make/unit-tests/use-inference.mk Mon Dec 7 00:53:30 2020
@@ -1,4 +1,4 @@
-# $NetBSD: use-inference.mk,v 1.2 2020/11/05 00:41:04 rillig Exp $
+# $NetBSD: use-inference.mk,v 1.3 2020/12/07 00:53:30 rillig Exp $
#
# Demonstrate that .USE rules do not have an effect on inference rules.
# At least not in the special case where the inference rule does not
@@ -34,5 +34,5 @@ use-inference.from: # assume it exists
# inference rule. But it seems to ignore it, maybe because it doesn't
# have any associated commands.
-# XXX: Despite the error message "don't know how to make", the exit status
-# is 0. This is inconsistent.
+# Until 2020-12-07, despite the error message "don't know how to make",
+# the exit status was 0. This was inconsistent.
Index: src/usr.bin/make/unit-tests/opt-keep-going.exp
diff -u src/usr.bin/make/unit-tests/opt-keep-going.exp:1.3 src/usr.bin/make/unit-tests/opt-keep-going.exp:1.4
--- src/usr.bin/make/unit-tests/opt-keep-going.exp:1.3 Sun Oct 18 18:12:42 2020
+++ src/usr.bin/make/unit-tests/opt-keep-going.exp Mon Dec 7 00:53:30 2020
@@ -3,4 +3,7 @@ dependency 1
other 1
*** Error code 1 (continuing)
`all' not remade because of errors.
-exit status 0
+
+Stop.
+make: stopped in unit-tests
+exit status 1
Index: src/usr.bin/make/unit-tests/suff-add-later.exp
diff -u src/usr.bin/make/unit-tests/suff-add-later.exp:1.3 src/usr.bin/make/unit-tests/suff-add-later.exp:1.4
--- src/usr.bin/make/unit-tests/suff-add-later.exp:1.3 Sat Nov 21 09:53:40 2020
+++ src/usr.bin/make/unit-tests/suff-add-later.exp Mon Dec 7 00:53:30 2020
@@ -15,4 +15,7 @@ make: don't know how to make issue5c (co
make: don't know how to make issue5d.e (continuing)
make: don't know how to make issue5e.d (continuing)
`all' not remade because of errors.
-exit status 0
+
+Stop.
+make: stopped in unit-tests
+exit status 1
Index: src/usr.bin/make/unit-tests/suff-main-several.exp
diff -u src/usr.bin/make/unit-tests/suff-main-several.exp:1.3 src/usr.bin/make/unit-tests/suff-main-several.exp:1.4
--- src/usr.bin/make/unit-tests/suff-main-several.exp:1.3 Fri Dec 4 14:28:50 2020
+++ src/usr.bin/make/unit-tests/suff-main-several.exp Mon Dec 7 00:53:30 2020
@@ -137,4 +137,7 @@ make: don't know how to make suff-main-s
make: don't know how to make suff-main-several.3 (continuing)
make: don't know how to make suff-main-several.4 (continuing)
`next-main' not remade because of errors.
-exit status 0
+
+Stop.
+make: stopped in unit-tests
+exit status 1
Index: src/usr.bin/make/unit-tests/suff-transform-endless.exp
diff -u src/usr.bin/make/unit-tests/suff-transform-endless.exp:1.3 src/usr.bin/make/unit-tests/suff-transform-endless.exp:1.4
--- src/usr.bin/make/unit-tests/suff-transform-endless.exp:1.3 Mon Nov 23 14:47:12 2020
+++ src/usr.bin/make/unit-tests/suff-transform-endless.exp Mon Dec 7 00:53:30 2020
@@ -40,4 +40,7 @@ SuffFindDeps "issue6.f"
suffix is ".e"...
make: Graph cycles through issue6.f
`all' not remade because of errors.
-exit status 0
+
+Stop.
+make: stopped in unit-tests
+exit status 1
Index: src/usr.bin/make/unit-tests/suff-transform-select.exp
diff -u src/usr.bin/make/unit-tests/suff-transform-select.exp:1.3 src/usr.bin/make/unit-tests/suff-transform-select.exp:1.4
--- src/usr.bin/make/unit-tests/suff-transform-select.exp:1.3 Mon Nov 23 14:47:12 2020
+++ src/usr.bin/make/unit-tests/suff-transform-select.exp Mon Dec 7 00:53:30 2020
@@ -41,4 +41,7 @@ suffix is ".d"...
: 'Making issue10.d out of nothing.'
make: don't know how to make issue10.e (continuing)
`all' not remade because of errors.
-exit status 0
+
+Stop.
+make: stopped in unit-tests
+exit status 1
Index: src/usr.bin/make/unit-tests/opt-keep-going.mk
diff -u src/usr.bin/make/unit-tests/opt-keep-going.mk:1.5 src/usr.bin/make/unit-tests/opt-keep-going.mk:1.6
--- src/usr.bin/make/unit-tests/opt-keep-going.mk:1.5 Mon Nov 9 20:50:56 2020
+++ src/usr.bin/make/unit-tests/opt-keep-going.mk Mon Dec 7 00:53:30 2020
@@ -1,8 +1,12 @@
-# $NetBSD: opt-keep-going.mk,v 1.5 2020/11/09 20:50:56 rillig Exp $
+# $NetBSD: opt-keep-going.mk,v 1.6 2020/12/07 00:53:30 rillig Exp $
#
# Tests for the -k command line option, which stops building a target as soon
# as an error is detected, but continues building the other, independent
# targets, as far as possible.
+#
+# Until 2020-12-07, if a dependency of the main target failed, the exit
+# status was nevertheless 0, which was wrong since the main targets could
+# not be made. This was only wrong in -k mode combined with compat mode.
.MAKEFLAGS: -d0 # switch stdout to being line-buffered
.MAKEFLAGS: -k