Module Name: src
Committed By: rillig
Date: Sun Dec 13 19:33:54 UTC 2020
Modified Files:
src/usr.bin/make: compat.c
src/usr.bin/make/unit-tests: compat-error.exp compat-error.mk
Log Message:
make(1): fix .ERROR_TARGET in compat -k mode (since 2010-04-07)
To generate a diff of this commit:
cvs rdiff -u -r1.214 -r1.215 src/usr.bin/make/compat.c
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/compat-error.exp \
src/usr.bin/make/unit-tests/compat-error.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.214 src/usr.bin/make/compat.c:1.215
--- src/usr.bin/make/compat.c:1.214 Sun Dec 13 18:57:44 2020
+++ src/usr.bin/make/compat.c Sun Dec 13 19:33:53 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: compat.c,v 1.214 2020/12/13 18:57:44 rillig Exp $ */
+/* $NetBSD: compat.c,v 1.215 2020/12/13 19:33:53 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.214 2020/12/13 18:57:44 rillig Exp $");
+MAKE_RCSID("$NetBSD: compat.c,v 1.215 2020/12/13 19:33:53 rillig Exp $");
static GNode *curTarg = NULL;
static pid_t compatChild;
@@ -706,8 +706,7 @@ InitSignals(void)
void
Compat_Run(GNodeList *targs)
{
- GNode *gn = NULL; /* Current root target */
- Boolean seenError;
+ GNode *errorNode = NULL;
if (!shellName)
Shell_Init();
@@ -728,9 +727,8 @@ Compat_Run(GNodeList *targs)
*/
Make_ExpandUse(targs);
- seenError = FALSE;
while (!Lst_IsEmpty(targs)) {
- gn = Lst_Dequeue(targs);
+ GNode *gn = Lst_Dequeue(targs);
Compat_Make(gn, gn);
if (gn->made == UPTODATE) {
@@ -739,26 +737,20 @@ Compat_Run(GNodeList *targs)
printf("`%s' not remade because of errors.\n",
gn->name);
}
- if (GNode_IsError(gn)) {
- seenError = TRUE;
- /* XXX: In case of error, set the error node. */
- }
+ if (GNode_IsError(gn) && errorNode == NULL)
+ errorNode = gn;
}
/* If the user has defined a .END target, run its commands. */
- if (!seenError) {
+ if (errorNode == NULL) {
GNode *endNode = Targ_GetEndNode();
Compat_Make(endNode, endNode);
- seenError = GNode_IsError(endNode);
- /* XXX: In case of error, set the error node. */
+ if (GNode_IsError(endNode))
+ errorNode = endNode;
}
- if (seenError) {
- /*
- * XXX: Instead of gn, it makes more sense to report the
- * first error node.
- */
- PrintOnError(gn, "\nStop.");
+ if (errorNode != NULL) {
+ PrintOnError(errorNode, "\nStop.");
exit(1);
}
}
Index: src/usr.bin/make/unit-tests/compat-error.exp
diff -u src/usr.bin/make/unit-tests/compat-error.exp:1.2 src/usr.bin/make/unit-tests/compat-error.exp:1.3
--- src/usr.bin/make/unit-tests/compat-error.exp:1.2 Sun Dec 13 19:08:20 2020
+++ src/usr.bin/make/unit-tests/compat-error.exp Sun Dec 13 19:33:53 2020
@@ -10,6 +10,6 @@ false 'fail2' '${.TARGET}' '$${.TARGET}'
Stop.
make: stopped in unit-tests
-.ERROR target: <success3>
+.ERROR target: <fail1>
.ERROR command: <>
exit status 1
Index: src/usr.bin/make/unit-tests/compat-error.mk
diff -u src/usr.bin/make/unit-tests/compat-error.mk:1.2 src/usr.bin/make/unit-tests/compat-error.mk:1.3
--- src/usr.bin/make/unit-tests/compat-error.mk:1.2 Sun Dec 13 19:08:20 2020
+++ src/usr.bin/make/unit-tests/compat-error.mk Sun Dec 13 19:33:53 2020
@@ -1,8 +1,12 @@
-# $NetBSD: compat-error.mk,v 1.2 2020/12/13 19:08:20 rillig Exp $
+# $NetBSD: compat-error.mk,v 1.3 2020/12/13 19:33:53 rillig Exp $
#
# Test detailed error handling in compat mode.
#
-# XXX: As of 2020-12-13, .ERROR_TARGET is success3, which is wrong.
+# Until 2020-12-13, .ERROR_TARGET was success3, which was wrong.
+# Since compat.c 1.215 from 2020-12-13, it is 'fail1', which is the first
+# failed top-level target. XXX: Even better would be if .ERROR_TARGET were
+# the smallest target that caused the build to fail, even if it were a
+# sub-sub-sub-dependency of a top-level target.
#
# XXX: As of 2020-12-13, .ERROR_CMD is empty, which is wrong.
#