From nobody@FreeBSD.org  Thu Mar  1 17:20:08 2012
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id A4480106567F
	for <freebsd-gnats-submit@FreeBSD.org>; Thu,  1 Mar 2012 17:20:08 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 897288FC0C
	for <freebsd-gnats-submit@FreeBSD.org>; Thu,  1 Mar 2012 17:20:08 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q21HK8Jq047420
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 1 Mar 2012 17:20:08 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id q21HK8xi047419;
	Thu, 1 Mar 2012 17:20:08 GMT
	(envelope-from nobody)
Message-Id: <201203011720.q21HK8xi047419@red.freebsd.org>
Date: Thu, 1 Mar 2012 17:20:08 GMT
From: Garrett Cooper <yaneurabeya@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] make pmake errors more apparent
X-Send-Pr-Version: www-3.1
X-GNATS-Notify: crees@FreeBSD.org

>Number:         165589
>Category:       bin
>Synopsis:       [patch] make make(1) errors more apparent
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    fjoe
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Mar 01 17:30:11 UTC 2012
>Closed-Date:    Wed Aug 29 10:29:42 UTC 2012
>Last-Modified:  Sun Feb 03 22:30:26 UTC 2013
>Originator:     Garrett Cooper
>Release:        9.0-STABLE
>Organization:
n/a
>Environment:
FreeBSD bayonetta.local 9.0-STABLE FreeBSD 9.0-STABLE #6 r231963M: Mon Feb 20 23:15:28 PST 2012     gcooper@bayonetta.local:/usr/obj/store/freebsd/stable/9/sys/BAYONETTA  amd64
>Description:
The attached patch makes pmake mimic gmake in the sense that the failing target is printed out in the error message. Example:

$ make -f ~/Makefile.bad
*** [all] Error code 1

Stop in /scratch/git/gitorious/freenas.

This makes life a lot easier for developers and end-users because then (if one's really slick, or just does manual inspection), it becomes really easy to determine the root cause of a build failure.

This is particularly important when dealing with -j > 1, as the output becomes interleaved and it becomes extremely hard to track down the exact source behind a given build failure.
>How-To-Repeat:
$ sh
$ cat > Makefile.bad <<EOF
all:
	@false
EOF
$ make -f Makefile.bad
>Fix:


Patch attached with submission follows:

Index: usr.bin/make/job.c
===================================================================
--- usr.bin/make/job.c	(revision 228107)
+++ usr.bin/make/job.c	(working copy)
@@ -954,17 +954,18 @@
 						lastNode = job->node;
 					}
 					fprintf(out,
-					    "*** Completed successfully\n");
+					    "*** [%s] Completed successfully\n",
+					    job->node->name);
 				}
 			} else {
 				if (usePipes && job->node != lastNode) {
-					MESSAGE(out, job->node);
 					lastNode = job->node;
 				}
-				fprintf(out, "*** Error code %d%s\n",
+				fprintf(out, "*** [%s] Error code %d%s\n",
+					job->node->name,
 					WEXITSTATUS(*status),
 					(job->flags & JOB_IGNERR) ?
-					"(ignored)" : "");
+					" (ignored)" : "");
 
 				if (job->flags & JOB_IGNERR) {
 					*status = 0;
@@ -1002,10 +1003,10 @@
 				 */
 				if (job->flags & (JOB_RESUME | JOB_RESTART)) {
 					if (usePipes && job->node != lastNode) {
-						MESSAGE(out, job->node);
 						lastNode = job->node;
 					}
-					fprintf(out, "*** Continued\n");
+					fprintf(out, "*** [%s] Continued\n",
+					    job->node->name);
 				}
 				if (!(job->flags & JOB_CONTINUING)) {
 					DEBUGF(JOB, ("Warning: process %jd was not "
@@ -1025,11 +1026,11 @@
 
 			} else {
 				if (usePipes && job->node != lastNode) {
-					MESSAGE(out, job->node);
 					lastNode = job->node;
 				}
 				fprintf(out,
-				    "*** Signal %d\n", WTERMSIG(*status));
+				    "*** [%s] Signal %d\n", job->node->name,
+				    WTERMSIG(*status));
 				fflush(out);
 			}
 		}
@@ -1053,10 +1054,10 @@
 
 		DEBUGF(JOB, ("Process %jd stopped.\n", (intmax_t) job->pid));
 		if (usePipes && job->node != lastNode) {
-			MESSAGE(out, job->node);
 			lastNode = job->node;
 		}
-		fprintf(out, "*** Stopped -- signal %d\n", WSTOPSIG(*status));
+		fprintf(out, "*** [%s] Stopped -- signal %d\n",
+		    job->node->name, WSTOPSIG(*status));
 		job->flags |= JOB_RESUME;
 		TAILQ_INSERT_TAIL(&stoppedJobs, job, link);
 		fflush(out);
@@ -3042,13 +3043,15 @@
 			if (status == 0) {
 				return (0);
   			} else {
-				printf("*** Error code %d", status);
+				printf("*** [%s] Error code %d",
+				    gn->name, status);
   			}
 		} else if (WIFSTOPPED(reason)) {
 			status = WSTOPSIG(reason);
 		} else {
 			status = WTERMSIG(reason);
-			printf("*** Signal %d", status);
+			printf("*** [%s] Signal %d",
+			    gn->name, status);
   		}
   
 		if (ps.errCheck) {


>Release-Note:
>Audit-Trail:

From: Eygene Ryabinkin <rea@freebsd.org>
To: FreeBSD GNATS followup <bug-followup@freebsd.org>
Cc:  
Subject: Re: bin/165589: [patch] make make(1) errors more apparent
Date: Fri, 2 Mar 2012 10:25:41 +0400

 --yhqQ34TVR4fE8mPU
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable
 
 The patch from mailing list was already committed to HEAD more than
 2 weeks ago,
   http://svnweb.freebsd.org/base?view=3Drevision&revision=3D231544
 --=20
 Eygene Ryabinkin                                        ,,,^..^,,,
 [ Life's unfair - but root password helps!           | codelabs.ru ]
 [ 82FE 06BC D497 C0DE 49EC  4FF0 16AF 9EAE 8152 ECFB | freebsd.org ]
 
 --yhqQ34TVR4fE8mPU
 Content-Type: application/pgp-signature
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.18 (FreeBSD)
 
 iF4EABEIAAYFAk9QZ+UACgkQFq+eroFS7PsLlQD/cmj03rhOq3Tv/TZqhTkpQNIC
 Mu7xoSXxr6kIar752/YA/3fntolbnjrbU4ymQAhZa8Ura51cA7FRCu38UTFoGK0B
 =l1ju
 -----END PGP SIGNATURE-----
 
 --yhqQ34TVR4fE8mPU--
State-Changed-From-To: open->patched 
State-Changed-By: linimon 
State-Changed-When: Fri Mar 2 07:51:09 UTC 2012 
State-Changed-Why:  
set as 'patched' 


Responsible-Changed-From-To: freebsd-bugs->fjoe 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Fri Mar 2 07:51:09 UTC 2012 
Responsible-Changed-Why:  

http://www.freebsd.org/cgi/query-pr.cgi?pr=165589 
State-Changed-From-To: patched->closed 
State-Changed-By: fjoe 
State-Changed-When: Wed Aug 29 10:28:20 UTC 2012 
State-Changed-Why:  
Merged to stable/9 in r236742 (Fri, 08 Jun 2012). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=165589 
>Unformatted:
