Skip to content

Commit

Permalink
Print -de error information when running multiple jobs
Browse files Browse the repository at this point in the history
Problem and patch description from https://reviews.freebsd.org/D29647:

When running `make -de` (without any -j flag) bmake prints which command
failed. However, when using the -j flag the -de flag is ignored. This can
make it rather difficult to determine which command failed in an very
parallel build (especially when combined with the -s flag to avoid
ridiculously large logfiles). For single-threaded builds we can combine
-s with -de to get the failed command but this does not work with -jN
(even with -j1). This patch prints the failed shell script with -de in the
multiple jobs mode as well.

From Alexander Richardson @ FreeBSD
  • Loading branch information
zoulasc committed Apr 27, 2021
1 parent a53449c commit 0a66e58
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions usr.bin/make/job.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $NetBSD: job.c,v 1.429 2021/04/16 16:49:27 rillig Exp $ */
/* $NetBSD: job.c,v 1.430 2021/04/27 15:21:42 christos Exp $ */

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

/* "@(#)job.c 8.2 (Berkeley) 3/19/94" */
MAKE_RCSID("$NetBSD: job.c,v 1.429 2021/04/16 16:49:27 rillig Exp $");
MAKE_RCSID("$NetBSD: job.c,v 1.430 2021/04/27 15:21:42 christos Exp $");

/*
* A shell defines how the commands are run. All commands for a target are
Expand Down Expand Up @@ -1060,6 +1060,21 @@ JobClosePipes(Job *job)
job->inPipe = -1;
}

static void
DebugFailedJob(const Job *job)
{
const ListNode *l;

if (!DEBUG(ERROR))
return;

debug_printf("\n*** Failed target: %s\n*** Failed commands:\n",
job->node->name);
for (l = job->node->commands.first; l != NULL; l = l->next) {
debug_printf("\t%s\n", (const char *)l->datum);
}
}

static void
JobFinishDoneExitedError(Job *job, int *inout_status)
{
Expand All @@ -1071,6 +1086,7 @@ JobFinishDoneExitedError(Job *job, int *inout_status)
}
#endif
if (!shouldDieQuietly(job->node, -1)) {
DebugFailedJob(job);
(void)printf("*** [%s] Error code %d%s\n",
job->node->name, WEXITSTATUS(*inout_status),
job->ignerr ? " (ignored)" : "");
Expand Down Expand Up @@ -1103,6 +1119,7 @@ static void
JobFinishDoneSignaled(Job *job, int status)
{
SwitchOutputTo(job->node);
DebugFailedJob(job);
(void)printf("*** [%s] Signal %d\n", job->node->name, WTERMSIG(status));
if (deleteOnError)
JobDeleteTarget(job->node);
Expand Down

0 comments on commit 0a66e58

Please sign in to comment.