Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make Avoid unnecessary noise when sub-make or siblin...



details:   https://anonhg.NetBSD.org/src/rev/9b5d88455d3c
branches:  trunk
changeset: 973099:9b5d88455d3c
user:      sjg <sjg%NetBSD.org@localhost>
date:      Fri Jun 19 21:17:48 2020 +0000

description:
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

diffstat:

 usr.bin/make/job.c  |  17 ++++++++++-------
 usr.bin/make/main.c |  33 ++++++++++++++++++++++++++++++---
 usr.bin/make/make.h |   3 ++-
 3 files changed, 42 insertions(+), 11 deletions(-)

diffs (143 lines):

diff -r 38c22e2b91af -r 9b5d88455d3c usr.bin/make/job.c
--- a/usr.bin/make/job.c        Fri Jun 19 19:32:03 2020 +0000
+++ b/usr.bin/make/job.c        Fri Jun 19 21:17:48 2020 +0000
@@ -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 @@
                    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 @@
        /* 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");
     }
 
diff -r 38c22e2b91af -r 9b5d88455d3c usr.bin/make/main.c
--- a/usr.bin/make/main.c       Fri Jun 19 19:32:03 2020 +0000
+++ b/usr.bin/make/main.c       Fri Jun 19 21:17:48 2020 +0000
@@ -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 @@
 #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 @@
 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 @@
     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 @@
     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);
        
diff -r 38c22e2b91af -r 9b5d88455d3c usr.bin/make/make.h
--- a/usr.bin/make/make.h       Fri Jun 19 19:32:03 2020 +0000
+++ b/usr.bin/make/make.h       Fri Jun 19 21:17:48 2020 +0000
@@ -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 @@
 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);



Home | Main Index | Thread Index | Old Index