From nobody@FreeBSD.org  Sun Oct  7 07:01:08 2012
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 29D84106566B
	for <freebsd-gnats-submit@FreeBSD.org>; Sun,  7 Oct 2012 07:01: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 EF9C38FC19
	for <freebsd-gnats-submit@FreeBSD.org>; Sun,  7 Oct 2012 07:01:07 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.5/8.14.5) with ESMTP id q97717m9033551
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 7 Oct 2012 07:01:07 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.5/8.14.5/Submit) id q977170a033550;
	Sun, 7 Oct 2012 07:01:07 GMT
	(envelope-from nobody)
Message-Id: <201210070701.q977170a033550@red.freebsd.org>
Date: Sun, 7 Oct 2012 07:01:07 GMT
From: Garrett Cooper <yaneurabeya@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] [build] fix broken CTFCONVERT_CMD call
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         172440
>Category:       misc
>Synopsis:       [patch] [build] fix broken CTFCONVERT_CMD call
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    sjg
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Oct 07 07:10:09 UTC 2012
>Closed-Date:    Tue Apr 09 18:53:03 UTC 2013
>Last-Modified:  Tue Apr 09 18:53:03 UTC 2013
>Originator:     Garrett Cooper
>Release:        
>Organization:
EMC Isilon
>Environment:
>Description:
The MAKE_VERSION check is broken in bsd.own.mk and generates a lot of warnings when compiling CURRENT as CTFCONVERT_CMD evaluates to a NUL string.

$ make -VMAKE_VERSION
9201120530
$ make -f /store/freebsd/atf-head/share/mk/bsd.own.mk COMPILER_FEATURES= -VCTFCONVERT_CMD
$ uname -a
FreeBSD bayonetta.local 9.1-PRERELEASE FreeBSD 9.1-PRERELEASE #0 r240836M: Sat Sep 22 12:30:11 PDT 2012     gcooper@bayonetta.local:/usr/obj/store/freebsd/stable/9/sys/BAYONETTA  amd64

The attached patch does the right thing for <= 9.x versions of pmake, 10.x <= versions of pmake, and bmake (bmake doesn't care about NUL commands).

$ FreeBSD bayonetta.local 9.1-PRERELEASE FreeBSD 9.1-PRERELEASE #0 r240836M: Sat Sep 22 12:30:11 PDT 2012     gcooper@bayonetta.local:/usr/obj/store/freebsd/stable/9/sys/BAYONETTA  amd64
$ make -f share/mk/bsd.own.mk COMPILER_FEATURES= -VCTFCONVERT_CMD
@:

# uname -a
FreeBSD fallout-freebsd-current.local 10.0-CURRENT FreeBSD 10.0-CURRENT #10: Sat Aug  4 12:02:44 PDT 2012     root@fallout-freebsd-current.local:/usr/obj/nfs/bayonetta/scratch/p4/user/gcooper/atf-head/src/sys/GENERIC  i386
# `make -V.OBJDIR`/make -f ../../share/mk/bsd.own.mk -VCTFCONVERT_CMD

# bmake -f ../../share/mk/bsd.own.mk -VCTFCONVERT_CMD

# `make -V.OBJDIR`/make -VMAKE_VERSION
10201205300
>How-To-Repeat:
Build something using bsd.prog.mk with -DWITHOUT_CTF defined using the 9.x version of pmake and 10.x copy of bsd.own.mk .
>Fix:


Patch attached with submission follows:

Index: share/mk/bsd.own.mk
===================================================================
--- share/mk/bsd.own.mk	(revision 241309)
+++ share/mk/bsd.own.mk	(working copy)
@@ -671,7 +672,8 @@
 
 .if ${MK_CTF} != "no"
 CTFCONVERT_CMD=	${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
-.elif defined(MAKE_VERSION) && ${MAKE_VERSION} >= 5201111300
+.elif defined(WITH_BMAKE) || \
+      (defined(MAKE_VERSION) && ${MAKE_VERSION} >= 10201205300)
 CTFCONVERT_CMD=
 .else
 CTFCONVERT_CMD=	@:


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->sjg 
Responsible-Changed-By: obrien 
Responsible-Changed-When: Wed Oct 24 06:00:00 UTC 2012 
Responsible-Changed-Why:  
bmake related 

http://www.freebsd.org/cgi/query-pr.cgi?pr=172440 
State-Changed-From-To: open->closed 
State-Changed-By: sjg 
State-Changed-When: Tue Apr 9 18:52:36 UTC 2013 
State-Changed-Why:  
Modified patch applied. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=172440 
>Unformatted:
Not sure why this didn't make it into the PR...

  In-Reply-To: <201210070710.q977A9p8087371@freefall.freebsd.org>
  References: <201210070701.q977170a033550@red.freebsd.org>
	  <201210070710.q977A9p8087371@freefall.freebsd.org>
  Date: Sun, 7 Oct 2012 01:48:35 -0700
  Message-ID: <CAGH67wR9P_QzR0Wd8EUd5EQ0xuLqVssGjsmZNEt+-7iiL1DGXg@mail.gmail.com>
  From: Garrett Cooper <yaneurabeya@gmail.com>

      Correction -- bmake hates empty strings for commands too...

  bmake: ${CTFCONVERT_CMD} expands to empty string
  cc  -O2 -pipe -DMALLOC_PRODUCTION -march=prescott -I/usr/src/lib/libmd
  -DSHA1_ASM -DRMD160_ASM -std=gnu99 -fstack-protector -Wno-pointer-sign
  -c sha1hl.c -o sha1hl.o
  bmake: ${CTFCONVERT_CMD} expands to empty string
  cc  -O2 -pipe -DMALLOC_PRODUCTION -march=prescott -I/usr/src/lib/libmd
  -DSHA1_ASM -DRMD160_ASM -std=gnu99 -fstack-protector -Wno-pointer-sign
  -c /usr/src/lib/libmd/sha256c.c -o sha256c.o
  bmake: ${CTFCONVERT_CMD} expands to empty string
  cc  -O2 -pipe -DMALLOC_PRODUCTION -march=prescott -I/usr/src/lib/libmd
  -DSHA1_ASM -DRMD160_ASM -std=gnu99 -fstack-protector -Wno-pointer-sign
  -c sha256hl.c -o sha256hl.o
  bmake: ${CTFCONVERT_CMD} expands to empty string
  cc  -O2 -pipe -DMALLOC_PRODUCTION -march=prescott -I/usr/src/lib/libmd
  -DSHA1_ASM -DRMD160_ASM -std=gnu99 -fstack-protector -Wno-pointer-sign
  -c /usr/src/lib/libmd/sha512c.c -o sha512c.o
  bmake: ${CTFCONVERT_CMD} expands to empty string
  cc  -O2 -pipe -DMALLOC_PRODUCTION -march=prescott -I/usr/src/lib/libmd
  -DSHA1_ASM -DRMD160_ASM -std=gnu99 -fstack-protector -Wno-pointer-sign
  -c sha512hl.c -o sha512hl.o
  bmake: ${CTFCONVERT_CMD} expands to empty string
  cc -O2 -pipe -DMALLOC_PRODUCTION -march=prescott -I/usr/src/lib/libmd
  -DSHA1_ASM -DRMD160_ASM -std=gnu99 -fstack-protector -Wno-pointer-sign
   -DELF -Wa,--noexecstack -c /usr/src/lib/libmd/i386/sha.S
  bmake: ${CTFCONVERT_CMD} expands to empty string
  cc -O2 -pipe -DMALLOC_PRODUCTION -march=prescott -I/usr/src/lib/libmd
  -DSHA1_ASM -DRMD160_ASM -std=gnu99 -fstack-protector -Wno-pointer-sign
   -DELF -Wa,--noexecstack -c /usr/src/lib/libmd/i386/rmd160.S
  bmake: ${CTFCONVERT_CMD} expands to empty string
  building static md library
  ranlib libmd.a
  cc -pg  -O2 -pipe -DMALLOC_PRODUCTION -march=prescott
  -I/usr/src/lib/libmd -DSHA1_ASM -DRMD160_ASM -std=gnu99
  -fstack-protector -Wno-pointer-sign -c /usr/src/lib/libmd/md4c.c -o
  md4c.po
  bmake: ${CTFCONVERT_CMD} expands to empty string
  cc -pg  -O2 -pipe -DMALLOC_PRODUCTION -march=prescott
  -I/usr/src/lib/libmd -DSHA1_ASM -DRMD160_ASM -std=gnu99
  -fstack-protector -Wno-pointer-sign -c /usr/src/lib/libmd/md5c.c -o
  md5c.po
  bmake: ${CTFCONVERT_CMD} expands to empty string

      The attached patch is correct per bmake today (if empty strings in
  bmake should be supported, a similar shim will need to be added for it
  as was added for pmake with r228157), and it seems to be accepted (or
  at least not explicitly denied) per POSIX
  (http://pubs.opengroup.org/onlinepubs/009695399/utilities/make.html):

  The algorithm for determining a new entry for target rules is
  partially unspecified. Some historical makes allow blank, empty, or
  comment lines within the collection of commands marked by leading
  <tab>s. A conforming makefile must ensure that each command starts
  with a <tab>, but implementations are free to ignore blank, empty, and
  comment lines without triggering the start of a new entry.s

      FWIW, the logic in this block was broken in r236338 by moving away
  from 5${DATE} to a ${RELENG_MAJOR_VERSION}${DATE} format. It's
  unfortunate that the new versioning scheme messed this up, but I
  understand the logic behind the new format as a good chunk of features
  committed to 10.x's version of pmake haven't been backported to
  stable/9 or earlier as it would potentially break things and one would
  need to do this in order to bootstrap make only when needed.
      I've CCed interested parties for the empty command enhancement in
  bmake as bmake has upstream sources and as such we shouldn't be
  changing things arbitrarily without talking with Simon first.
  Thanks!
  -Garrett

Index: share/mk/bsd.own.mk
===================================================================
--- share/mk/bsd.own.mk	(revision 241309)
+++ share/mk/bsd.own.mk	(working copy)
@@ -671,7 +672,8 @@
 
 .if ${MK_CTF} != "no"
 CTFCONVERT_CMD=	${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
-.elif defined(MAKE_VERSION) && ${MAKE_VERSION} >= 5201111300
+.elif !defined(WITH_BMAKE) && \
+      (defined(MAKE_VERSION) && ${MAKE_VERSION} >= 10201205300)
 CTFCONVERT_CMD=
 .else
 CTFCONVERT_CMD=	@:
