Fri Apr 26 17:11:22 2024 UTC (13d)
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.


(rillig)
diff -r1.468 -r1.469 src/usr.bin/make/job.c
diff -r1.4 -r1.5 src/usr.bin/make/unit-tests/opt-debug-errors-jobs.exp

cvs diff -r1.468 -r1.469 src/usr.bin/make/job.c (expand / switch to unified diff)

--- src/usr.bin/make/job.c 2024/04/20 10:18:55 1.468
+++ src/usr.bin/make/job.c 2024/04/26 17:11:22 1.469
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: job.c,v 1.468 2024/04/20 10:18:55 rillig Exp $ */ 1/* $NetBSD: job.c,v 1.469 2024/04/26 17:11:22 rillig Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. 4 * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to Berkeley by 7 * This code is derived from software contributed to Berkeley by
8 * Adam de Boor. 8 * Adam de Boor.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -131,27 +131,27 @@ @@ -131,27 +131,27 @@
131#ifndef USE_SELECT 131#ifndef USE_SELECT
132#include <poll.h> 132#include <poll.h>
133#endif 133#endif
134#include <signal.h> 134#include <signal.h>
135#include <utime.h> 135#include <utime.h>
136 136
137#include "make.h" 137#include "make.h"
138#include "dir.h" 138#include "dir.h"
139#include "job.h" 139#include "job.h"
140#include "pathnames.h" 140#include "pathnames.h"
141#include "trace.h" 141#include "trace.h"
142 142
143/* "@(#)job.c 8.2 (Berkeley) 3/19/94" */ 143/* "@(#)job.c 8.2 (Berkeley) 3/19/94" */
144MAKE_RCSID("$NetBSD: job.c,v 1.468 2024/04/20 10:18:55 rillig Exp $"); 144MAKE_RCSID("$NetBSD: job.c,v 1.469 2024/04/26 17:11:22 rillig Exp $");
145 145
146/* 146/*
147 * A shell defines how the commands are run. All commands for a target are 147 * A shell defines how the commands are run. All commands for a target are
148 * written into a single file, which is then given to the shell to execute 148 * written into a single file, which is then given to the shell to execute
149 * the commands from it. The commands are written to the file using a few 149 * the commands from it. The commands are written to the file using a few
150 * templates for echo control and error control. 150 * templates for echo control and error control.
151 * 151 *
152 * The name of the shell is the basename for the predefined shells, such as 152 * The name of the shell is the basename for the predefined shells, such as
153 * "sh", "csh", "bash". For custom shells, it is the full pathname, and its 153 * "sh", "csh", "bash". For custom shells, it is the full pathname, and its
154 * basename is used to select the type of shell; the longest match wins. 154 * basename is used to select the type of shell; the longest match wins.
155 * So /usr/pkg/bin/bash has type sh, /usr/local/bin/tcsh has type csh. 155 * So /usr/pkg/bin/bash has type sh, /usr/local/bin/tcsh has type csh.
156 * 156 *
157 * The echoing of command lines is controlled using hasEchoCtl, echoOff, 157 * The echoing of command lines is controlled using hasEchoCtl, echoOff,
@@ -1052,26 +1052,27 @@ JobClosePipes(Job *job) @@ -1052,26 +1052,27 @@ JobClosePipes(Job *job)
1052 job->inPipe = -1; 1052 job->inPipe = -1;
1053} 1053}
1054 1054
1055static void 1055static void
1056DebugFailedJob(const Job *job) 1056DebugFailedJob(const Job *job)
1057{ 1057{
1058 const StringListNode *ln; 1058 const StringListNode *ln;
1059 1059
1060 if (!DEBUG(ERROR)) 1060 if (!DEBUG(ERROR))
1061 return; 1061 return;
1062 1062
1063 debug_printf("\n"); 1063 debug_printf("\n");
1064 debug_printf("*** Failed target: %s\n", job->node->name); 1064 debug_printf("*** Failed target: %s\n", job->node->name);
 1065 debug_printf("*** In directory: %s\n", curdir);
1065 debug_printf("*** Failed commands:\n"); 1066 debug_printf("*** Failed commands:\n");
1066 for (ln = job->node->commands.first; ln != NULL; ln = ln->next) { 1067 for (ln = job->node->commands.first; ln != NULL; ln = ln->next) {
1067 const char *cmd = ln->datum; 1068 const char *cmd = ln->datum;
1068 debug_printf("\t%s\n", cmd); 1069 debug_printf("\t%s\n", cmd);
1069 1070
1070 if (strchr(cmd, '$') != NULL) { 1071 if (strchr(cmd, '$') != NULL) {
1071 char *xcmd = Var_Subst(cmd, job->node, VARE_WANTRES); 1072 char *xcmd = Var_Subst(cmd, job->node, VARE_WANTRES);
1072 debug_printf("\t=> %s\n", xcmd); 1073 debug_printf("\t=> %s\n", xcmd);
1073 free(xcmd); 1074 free(xcmd);
1074 } 1075 }
1075 } 1076 }
1076} 1077}
1077 1078

cvs diff -r1.4 -r1.5 src/usr.bin/make/unit-tests/opt-debug-errors-jobs.exp (expand / switch to unified diff)

--- src/usr.bin/make/unit-tests/opt-debug-errors-jobs.exp 2021/11/28 00:02:07 1.4
+++ src/usr.bin/make/unit-tests/opt-debug-errors-jobs.exp 2024/04/26 17:11:22 1.5
@@ -1,58 +1,64 @@ @@ -1,58 +1,64 @@
1echo '3 spaces'; false 1echo '3 spaces'; false
23 spaces 23 spaces
3 3
4*** Failed target: fail-spaces 4*** Failed target: fail-spaces
 5*** In directory: <curdir>
5*** Failed commands: 6*** Failed commands:
6 echo '3 spaces'; false 7 echo '3 spaces'; false
7*** [fail-spaces] Error code 1 8*** [fail-spaces] Error code 1
8 9
9make: stopped in unit-tests 10make: stopped in unit-tests
10echo \ indented; false 11echo \ indented; false
11 indented 12 indented
12 13
13*** Failed target: fail-escaped-space 14*** Failed target: fail-escaped-space
 15*** In directory: <curdir>
14*** Failed commands: 16*** Failed commands:
15 echo \ indented; false 17 echo \ indented; false
16*** [fail-escaped-space] Error code 1 18*** [fail-escaped-space] Error code 1
17 19
18make: stopped in unit-tests 20make: stopped in unit-tests
19echo 'line1 21echo 'line1
20line2'; false 22line2'; false
21line1 23line1
22line2 24line2
23 25
24*** Failed target: fail-newline 26*** Failed target: fail-newline
 27*** In directory: <curdir>
25*** Failed commands: 28*** Failed commands:
26 echo 'line1${.newline}line2'; false 29 echo 'line1${.newline}line2'; false
27 => echo 'line1 30 => echo 'line1
28line2'; false 31line2'; false
29*** [fail-newline] Error code 1 32*** [fail-newline] Error code 1
30 33
31make: stopped in unit-tests 34make: stopped in unit-tests
32echo 'line1 line2'; false 35echo 'line1 line2'; false
33line1 line2 36line1 line2
34 37
35*** Failed target: fail-multiline 38*** Failed target: fail-multiline
 39*** In directory: <curdir>
36*** Failed commands: 40*** Failed commands:
37 echo 'line1 line2'; false 41 echo 'line1 line2'; false
38*** [fail-multiline] Error code 1 42*** [fail-multiline] Error code 1
39 43
40make: stopped in unit-tests 44make: stopped in unit-tests
41echo 'word1' 'word2'; false 45echo 'word1' 'word2'; false
42word1 word2 46word1 word2
43 47
44*** Failed target: fail-multiline-intention 48*** Failed target: fail-multiline-intention
 49*** In directory: <curdir>
45*** Failed commands: 50*** Failed commands:
46 echo 'word1' 'word2'; false 51 echo 'word1' 'word2'; false
47*** [fail-multiline-intention] Error code 1 52*** [fail-multiline-intention] Error code 1
48 53
49make: stopped in unit-tests 54make: stopped in unit-tests
50 55
51*** Failed target: fail-vars 56*** Failed target: fail-vars
 57*** In directory: <curdir>
52*** Failed commands: 58*** Failed commands:
53 @${COMPILE_C} ${COMPILE_C_FLAGS} 59 @${COMPILE_C} ${COMPILE_C_FLAGS}
54 => @false c-compiler flag1 -macro="several words" 60 => @false c-compiler flag1 -macro="several words"
55*** [fail-vars] Error code 1 61*** [fail-vars] Error code 1
56 62
57make: stopped in unit-tests 63make: stopped in unit-tests
58exit status 1 64exit status 1