Skip to content

Commit

Permalink
make: handle .PHONY consitently on interrupt
Browse files Browse the repository at this point in the history
JobDeleteTarget skips .PHONY targets
CompatDeleteTarget should do the same

This addresses https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=269663
  • Loading branch information
sjg authored and sjg committed Mar 18, 2023
1 parent 7a85a2f commit 6330c5d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
7 changes: 4 additions & 3 deletions usr.bin/make/compat.c
@@ -1,4 +1,4 @@
/* $NetBSD: compat.c,v 1.245 2023/02/14 21:38:31 rillig Exp $ */
/* $NetBSD: compat.c,v 1.246 2023/03/18 22:20:11 sjg Exp $ */

/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
Expand Down Expand Up @@ -91,7 +91,7 @@
#include "pathnames.h"

/* "@(#)compat.c 8.2 (Berkeley) 3/19/94" */
MAKE_RCSID("$NetBSD: compat.c,v 1.245 2023/02/14 21:38:31 rillig Exp $");
MAKE_RCSID("$NetBSD: compat.c,v 1.246 2023/03/18 22:20:11 sjg Exp $");

static GNode *curTarg = NULL;
static pid_t compatChild;
Expand All @@ -104,7 +104,8 @@ static int compatSigno;
static void
CompatDeleteTarget(GNode *gn)
{
if (gn != NULL && !GNode_IsPrecious(gn)) {
if (gn != NULL && !GNode_IsPrecious(gn) &&
(gn->type & OP_PHONY) == 0) {
const char *file = GNode_VarTarget(gn);

if (!opts.noExecute && unlink_file(file) == 0) {
Expand Down
1 change: 0 additions & 1 deletion usr.bin/make/unit-tests/cmd-interrupt.exp
Expand Up @@ -2,7 +2,6 @@
make: *** cmd-interrupt-ordinary removed
interrupt-ordinary: ok
> cmd-interrupt-phony
make: *** cmd-interrupt-phony removed
interrupt-phony: ok
> cmd-interrupt-precious
interrupt-precious: ok
Expand Down
4 changes: 2 additions & 2 deletions usr.bin/make/unit-tests/cmd-interrupt.mk
@@ -1,4 +1,4 @@
# $NetBSD: cmd-interrupt.mk,v 1.3 2020/11/15 14:07:53 rillig Exp $
# $NetBSD: cmd-interrupt.mk,v 1.4 2023/03/18 22:20:12 sjg Exp $
#
# Tests for interrupting a command.
#
Expand Down Expand Up @@ -30,7 +30,7 @@ interrupt-ordinary:
interrupt-phony: .PHONY
@${.MAKE} ${MAKEFLAGS} -f ${MAKEFILE} cmd-interrupt-phony || true
# The ././ is necessary to work around the file cache.
@echo ${.TARGET}: ${exists(././cmd-interrupt-phony) :? error : ok }
@echo ${.TARGET}: ${exists(././cmd-interrupt-phony) :? ok : error }

interrupt-precious: .PRECIOUS
@${.MAKE} ${MAKEFLAGS} -f ${MAKEFILE} cmd-interrupt-precious || true
Expand Down
2 changes: 0 additions & 2 deletions usr.bin/make/unit-tests/deptgt-delete_on_error.exp
Expand Up @@ -7,10 +7,8 @@ make: *** deptgt-delete_on_error-regular removed
make: *** deptgt-delete_on_error-regular-delete removed
> deptgt-delete_on_error-phony; false
*** Error code 1 (continuing)
make: *** deptgt-delete_on_error-phony removed
> deptgt-delete_on_error-phony-delete; false
*** Error code 1 (continuing)
make: *** deptgt-delete_on_error-phony-delete removed
> deptgt-delete_on_error-precious; false
*** Error code 1 (continuing)
> deptgt-delete_on_error-precious-delete; false
Expand Down

0 comments on commit 6330c5d

Please sign in to comment.