Module Name: src
Committed By: rillig
Date: Tue Nov 24 18:17:45 UTC 2020
Modified Files:
src/usr.bin/make: compat.c job.c make.h
src/usr.bin/make/unit-tests: deptgt-end-fail-indirect.exp
Log Message:
make(1): fix error handling for dependency of .END in -k mode
Fix one bug, find 4 new ones. All these bugs have been around since
2005-05-08, when dependencies on the .BEGIN, .END and .INTERRUPT nodes
were implemented. Before that, checking gn->made == ERROR was
appropriate, but adding the dependencies made ABORTED a new possible
error value from Compat_Make.
To generate a diff of this commit:
cvs rdiff -u -r1.190 -r1.191 src/usr.bin/make/compat.c
cvs rdiff -u -r1.328 -r1.329 src/usr.bin/make/job.c
cvs rdiff -u -r1.216 -r1.217 src/usr.bin/make/make.h
cvs rdiff -u -r1.1 -r1.2 \
src/usr.bin/make/unit-tests/deptgt-end-fail-indirect.exp
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.190 src/usr.bin/make/compat.c:1.191
--- src/usr.bin/make/compat.c:1.190 Tue Nov 24 17:42:31 2020
+++ src/usr.bin/make/compat.c Tue Nov 24 18:17:45 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: compat.c,v 1.190 2020/11/24 17:42:31 rillig Exp $ */
+/* $NetBSD: compat.c,v 1.191 2020/11/24 18:17:45 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.190 2020/11/24 17:42:31 rillig Exp $");
+MAKE_RCSID("$NetBSD: compat.c,v 1.191 2020/11/24 18:17:45 rillig Exp $");
static GNode *curTarg = NULL;
static pid_t compatChild;
@@ -639,6 +639,8 @@ Compat_Make(GNode *gn, GNode *pgn)
if (gn->made == UNMADE && (gn == pgn || !(pgn->type & OP_MADE))) {
if (!MakeUnmade(gn, pgn))
goto cohorts;
+
+ /* XXX: Replace with GNode_IsError(gn) */
} else if (gn->made == ERROR) {
/*
* Already had an error when making this.
@@ -689,6 +691,7 @@ Compat_Run(GNodeList *targs)
gn = Targ_FindNode(".BEGIN");
if (gn != NULL) {
Compat_Make(gn, gn);
+ /* XXX: Replace with GNode_IsError(gn) */
if (gn->made == ERROR) {
PrintOnError(gn, "\nStop.");
exit(1);
@@ -722,7 +725,7 @@ Compat_Run(GNodeList *targs)
if (indirectErrors == 0) {
GNode *endNode = Targ_GetEndNode();
Compat_Make(endNode, endNode);
- if (gn->made == ERROR || endNode->made == ERROR) {
+ if (GNode_IsError(gn) || GNode_IsError(endNode)) {
PrintOnError(gn, "\nStop.");
exit(1);
}
Index: src/usr.bin/make/job.c
diff -u src/usr.bin/make/job.c:1.328 src/usr.bin/make/job.c:1.329
--- src/usr.bin/make/job.c:1.328 Mon Nov 23 23:41:11 2020
+++ src/usr.bin/make/job.c Tue Nov 24 18:17:45 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: job.c,v 1.328 2020/11/23 23:41:11 rillig Exp $ */
+/* $NetBSD: job.c,v 1.329 2020/11/24 18:17:45 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -143,7 +143,7 @@
#include "trace.h"
/* "@(#)job.c 8.2 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: job.c,v 1.328 2020/11/23 23:41:11 rillig Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.329 2020/11/24 18:17:45 rillig Exp $");
/* A shell defines how the commands are run. All commands for a target are
* written into a single file, which is then given to the shell to execute
@@ -1843,6 +1843,7 @@ JobRun(GNode *targ)
}
#else
Compat_Make(targ, targ);
+ /* XXX: Replace with GNode_IsError(gn) */
if (targ->made == ERROR) {
PrintOnError(targ, "\n\nStop.");
exit(1);
@@ -2739,6 +2740,7 @@ Job_RunTarget(const char *target, const
Var_Set(ALLSRC, fname, gn);
JobRun(gn);
+ /* XXX: Replace with GNode_IsError(gn) */
if (gn->made == ERROR) {
PrintOnError(gn, "\n\nStop.");
exit(1);
Index: src/usr.bin/make/make.h
diff -u src/usr.bin/make/make.h:1.216 src/usr.bin/make/make.h:1.217
--- src/usr.bin/make/make.h:1.216 Tue Nov 24 17:42:31 2020
+++ src/usr.bin/make/make.h Tue Nov 24 18:17:45 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: make.h,v 1.216 2020/11/24 17:42:31 rillig Exp $ */
+/* $NetBSD: make.h,v 1.217 2020/11/24 18:17:45 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -701,6 +701,12 @@ GNode_Path(const GNode *gn)
return gn->path != NULL ? gn->path : gn->name;
}
+MAKE_INLINE Boolean
+GNode_IsError(const GNode *gn)
+{
+ return gn->made == ERROR || gn->made == ABORTED;
+}
+
MAKE_INLINE const char *
GNode_VarTarget(GNode *gn) { return Var_ValueDirect(TARGET, gn); }
MAKE_INLINE const char *
Index: src/usr.bin/make/unit-tests/deptgt-end-fail-indirect.exp
diff -u src/usr.bin/make/unit-tests/deptgt-end-fail-indirect.exp:1.1 src/usr.bin/make/unit-tests/deptgt-end-fail-indirect.exp:1.2
--- src/usr.bin/make/unit-tests/deptgt-end-fail-indirect.exp:1.1 Tue Nov 24 17:59:42 2020
+++ src/usr.bin/make/unit-tests/deptgt-end-fail-indirect.exp Tue Nov 24 18:17:45 2020
@@ -1,4 +1,7 @@
: all
false
*** Error code 1 (continuing)
-exit status 0
+
+Stop.
+make: stopped in unit-tests
+exit status 1