From ea51e814f205800ca961369dd70257601d608322 Mon Sep 17 00:00:00 2001 From: rillig Date: Mon, 7 Dec 2020 01:04:06 +0000 Subject: [PATCH] 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. --- usr.bin/make/compat.c | 6 +++--- usr.bin/make/unit-tests/deptgt-end-fail-all.exp | 3 --- usr.bin/make/unit-tests/deptgt-end-fail-all.mk | 8 +++++++- usr.bin/make/unit-tests/deptgt-end-fail.exp | 9 --------- usr.bin/make/unit-tests/deptgt-end-fail.mk | 8 +++++--- 5 files changed, 15 insertions(+), 19 deletions(-) diff --git a/usr.bin/make/compat.c b/usr.bin/make/compat.c index 958f1c610269..414b02d266f5 100644 --- a/usr.bin/make/compat.c +++ b/usr.bin/make/compat.c @@ -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); diff --git a/usr.bin/make/unit-tests/deptgt-end-fail-all.exp b/usr.bin/make/unit-tests/deptgt-end-fail-all.exp index 0df59a0d953a..2e2ee11f481a 100644 --- a/usr.bin/make/unit-tests/deptgt-end-fail-all.exp +++ b/usr.bin/make/unit-tests/deptgt-end-fail-all.exp @@ -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 diff --git a/usr.bin/make/unit-tests/deptgt-end-fail-all.mk b/usr.bin/make/unit-tests/deptgt-end-fail-all.mk index 38e21e1ee28d..4bf160d480f6 100644 --- a/usr.bin/make/unit-tests/deptgt-end-fail-all.mk +++ b/usr.bin/make/unit-tests/deptgt-end-fail-all.mk @@ -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. diff --git a/usr.bin/make/unit-tests/deptgt-end-fail.exp b/usr.bin/make/unit-tests/deptgt-end-fail.exp index 14be1056e534..9db907c209d5 100644 --- a/usr.bin/make/unit-tests/deptgt-end-fail.exp +++ b/usr.bin/make/unit-tests/deptgt-end-fail.exp @@ -84,8 +84,6 @@ Test case all=ERR all-dep=ok end=ok end-dep=ok. : 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-dep=ERR. : 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-dep=ok. : 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-dep=ERR. : 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 diff --git a/usr.bin/make/unit-tests/deptgt-end-fail.mk b/usr.bin/make/unit-tests/deptgt-end-fail.mk index b3eb41550ae0..57cdc7da8679 100644 --- a/usr.bin/make/unit-tests/deptgt-end-fail.mk +++ b/usr.bin/make/unit-tests/deptgt-end-fail.mk @@ -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.