make: in parallel mode, print the directory in which a job failed

When multiple targets run in parallel, the "stopped in" line may be
several lines away from the "Failed target" line, making them hard to
correlate.
This commit is contained in:
rillig 2024-04-26 17:11:22 +00:00
parent 58b62ac6a6
commit 4da1077ff7
2 changed files with 9 additions and 2 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: job.c,v 1.468 2024/04/20 10:18:55 rillig Exp $ */
/* $NetBSD: job.c,v 1.469 2024/04/26 17:11:22 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -141,7 +141,7 @@
#include "trace.h"
/* "@(#)job.c 8.2 (Berkeley) 3/19/94" */
MAKE_RCSID("$NetBSD: job.c,v 1.468 2024/04/20 10:18:55 rillig Exp $");
MAKE_RCSID("$NetBSD: job.c,v 1.469 2024/04/26 17:11:22 rillig Exp $");
/*
* A shell defines how the commands are run. All commands for a target are
@ -1062,6 +1062,7 @@ DebugFailedJob(const Job *job)
debug_printf("\n");
debug_printf("*** Failed target: %s\n", job->node->name);
debug_printf("*** In directory: %s\n", curdir);
debug_printf("*** Failed commands:\n");
for (ln = job->node->commands.first; ln != NULL; ln = ln->next) {
const char *cmd = ln->datum;

View File

@ -2,6 +2,7 @@ echo '3 spaces'; false
3 spaces
*** Failed target: fail-spaces
*** In directory: <curdir>
*** Failed commands:
echo '3 spaces'; false
*** [fail-spaces] Error code 1
@ -11,6 +12,7 @@ echo \ indented; false
indented
*** Failed target: fail-escaped-space
*** In directory: <curdir>
*** Failed commands:
echo \ indented; false
*** [fail-escaped-space] Error code 1
@ -22,6 +24,7 @@ line1
line2
*** Failed target: fail-newline
*** In directory: <curdir>
*** Failed commands:
echo 'line1${.newline}line2'; false
=> echo 'line1
@ -33,6 +36,7 @@ echo 'line1 line2'; false
line1 line2
*** Failed target: fail-multiline
*** In directory: <curdir>
*** Failed commands:
echo 'line1 line2'; false
*** [fail-multiline] Error code 1
@ -42,6 +46,7 @@ echo 'word1' 'word2'; false
word1 word2
*** Failed target: fail-multiline-intention
*** In directory: <curdir>
*** Failed commands:
echo 'word1' 'word2'; false
*** [fail-multiline-intention] Error code 1
@ -49,6 +54,7 @@ word1 word2
make: stopped in unit-tests
*** Failed target: fail-vars
*** In directory: <curdir>
*** Failed commands:
@${COMPILE_C} ${COMPILE_C_FLAGS}
=> @false c-compiler flag1 -macro="several words"