Module Name: src Committed By: sjg Date: Fri Jun 19 21:17:48 UTC 2020
Modified Files: src/usr.bin/make: job.c main.c make.h Log Message: Avoid unnecessary noise when sub-make or sibling dies When analyzing a build log, the first 'stopped' output from make, is the end of interesting output. Normally when a build fails deep down in a parallel build the log ends with many blockes of error output from make, with all but the fist being unhelpful. We add a function dieQuietly() which will return true if we should supress the error output from make. If the failing node was a sub-make, we want to die quietly. Also when we read an abort token we call dieQuietly telling we want to die quietly. This behavior is suppressed by -dj or setting .MAKE.DIE_QUIETLY=no Reviewed by: christos To generate a diff of this commit: cvs rdiff -u -r1.197 -r1.198 src/usr.bin/make/job.c cvs rdiff -u -r1.274 -r1.275 src/usr.bin/make/main.c cvs rdiff -u -r1.107 -r1.108 src/usr.bin/make/make.h 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.197 src/usr.bin/make/job.c:1.198 --- src/usr.bin/make/job.c:1.197 Thu Feb 6 01:13:19 2020 +++ src/usr.bin/make/job.c Fri Jun 19 21:17:48 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: job.c,v 1.197 2020/02/06 01:13:19 sjg Exp $ */ +/* $NetBSD: job.c,v 1.198 2020/06/19 21:17:48 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -70,14 +70,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: job.c,v 1.197 2020/02/06 01:13:19 sjg Exp $"; +static char rcsid[] = "$NetBSD: job.c,v 1.198 2020/06/19 21:17:48 sjg Exp $"; #else #include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)job.c 8.2 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: job.c,v 1.197 2020/02/06 01:13:19 sjg Exp $"); +__RCSID("$NetBSD: job.c,v 1.198 2020/06/19 21:17:48 sjg Exp $"); #endif #endif /* not lint */ #endif @@ -1042,10 +1042,11 @@ JobFinish(Job *job, int status) meta_job_error(job, job->node, job->flags, WEXITSTATUS(status)); } #endif - (void)printf("*** [%s] Error code %d%s\n", - job->node->name, - WEXITSTATUS(status), - (job->flags & JOB_IGNERR) ? " (ignored)" : ""); + if (!dieQuietly(job->node, -1)) + (void)printf("*** [%s] Error code %d%s\n", + job->node->name, + WEXITSTATUS(status), + (job->flags & JOB_IGNERR) ? " (ignored)" : ""); if (job->flags & JOB_IGNERR) { status = 0; } else { @@ -3020,6 +3021,8 @@ Job_TokenWithdraw(void) /* And put the stopper back */ while (write(tokenWaitJob.outPipe, &tok, 1) == -1 && errno == EAGAIN) continue; + if (dieQuietly(NULL, 1)) + exit(2); Fatal("A failure has been detected in another branch of the parallel make"); } Index: src/usr.bin/make/main.c diff -u src/usr.bin/make/main.c:1.274 src/usr.bin/make/main.c:1.275 --- src/usr.bin/make/main.c:1.274 Mon Mar 30 02:41:06 2020 +++ src/usr.bin/make/main.c Fri Jun 19 21:17:48 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.274 2020/03/30 02:41:06 sjg Exp $ */ +/* $NetBSD: main.c,v 1.275 2020/06/19 21:17:48 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,7 +69,7 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: main.c,v 1.274 2020/03/30 02:41:06 sjg Exp $"; +static char rcsid[] = "$NetBSD: main.c,v 1.275 2020/06/19 21:17:48 sjg Exp $"; #else #include <sys/cdefs.h> #ifndef lint @@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19 #if 0 static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: main.c,v 1.274 2020/03/30 02:41:06 sjg Exp $"); +__RCSID("$NetBSD: main.c,v 1.275 2020/06/19 21:17:48 sjg Exp $"); #endif #endif /* not lint */ #endif @@ -1855,6 +1855,8 @@ void Finish(int errors) /* number of errors encountered in Make_Make */ { + if (dieQuietly(NULL, -1)) + exit(2); Fatal("%d error%s", errors, errors == 1 ? "" : "s"); } @@ -2009,6 +2011,27 @@ addErrorCMD(void *cmdp, void *gnp) return 0; } +/* + * Return true if we should die without noise. + * For example our failing child was a sub-make + * or failure happend elsewhere. + */ +int +dieQuietly(GNode *gn, int bf) +{ + static int quietly = -1; + + if (quietly < 0) { + if (DEBUG(JOB) || getBoolean(".MAKE.DIE_QUIETLY", 1) == 0) + quietly = 0; + else if (bf >= 0) + quietly = bf; + else + quietly = (gn) ? ((gn->type & (OP_MAKE|OP_SUBMAKE)) != 0) : 0; + } + return quietly; +} + void PrintOnError(GNode *gn, const char *s) { @@ -2016,6 +2039,10 @@ PrintOnError(GNode *gn, const char *s) char tmp[64]; char *cp; + /* we generally want to keep quiet if a sub-make died */ + if (dieQuietly(gn, -1)) + return; + if (s) printf("%s", s); Index: src/usr.bin/make/make.h diff -u src/usr.bin/make/make.h:1.107 src/usr.bin/make/make.h:1.108 --- src/usr.bin/make/make.h:1.107 Fri Apr 3 03:35:16 2020 +++ src/usr.bin/make/make.h Fri Jun 19 21:17:48 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: make.h,v 1.107 2020/04/03 03:35:16 sjg Exp $ */ +/* $NetBSD: make.h,v 1.108 2020/06/19 21:17:48 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -487,6 +487,7 @@ void Make_DoAllVar(GNode *); Boolean Make_Run(Lst); char * Check_Cwd_Cmd(const char *); void Check_Cwd(const char **); +int dieQuietly(GNode *, int); void PrintOnError(GNode *, const char *); void Main_ExportMAKEFLAGS(Boolean); Boolean Main_SetObjdir(const char *, ...) MAKE_ATTR_PRINTFLIKE(1, 2);