Module Name: src Committed By: christos Date: Tue Apr 27 15:21:42 UTC 2021
Modified Files: src/usr.bin/make: job.c Log Message: Print -de error information when running multiple jobs 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 To generate a diff of this commit: cvs rdiff -u -r1.429 -r1.430 src/usr.bin/make/job.c 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/job.c diff -u src/usr.bin/make/job.c:1.429 src/usr.bin/make/job.c:1.430 --- src/usr.bin/make/job.c:1.429 Fri Apr 16 12:49:27 2021 +++ src/usr.bin/make/job.c Tue Apr 27 11:21:42 2021 @@ -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. @@ -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 @@ -1061,6 +1061,21 @@ JobClosePipes(Job *job) } 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) { SwitchOutputTo(job->node); @@ -1071,6 +1086,7 @@ JobFinishDoneExitedError(Job *job, int * } #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)" : ""); @@ -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);