From mi@aldan.algebra.com  Wed Jun 27 20:27:04 2007
Return-Path: <mi@aldan.algebra.com>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 0721B16A400
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 27 Jun 2007 20:27:04 +0000 (UTC)
	(envelope-from mi@aldan.algebra.com)
Received: from aldan.algebra.com (aldan.algebra.com [216.254.65.224])
	by mx1.freebsd.org (Postfix) with ESMTP id B9D9113C480
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 27 Jun 2007 20:27:03 +0000 (UTC)
	(envelope-from mi@aldan.algebra.com)
Received: from aldan.algebra.com (localhost [127.0.0.1])
	by aldan.algebra.com (8.14.1/8.14.1) with ESMTP id l5RKR2M9098080
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO)
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 27 Jun 2007 16:27:03 -0400 (EDT)
	(envelope-from mi@aldan.algebra.com)
Received: (from mi@localhost)
	by aldan.algebra.com (8.14.1/8.14.1/Submit) id l5RKR2Zl098079;
	Wed, 27 Jun 2007 16:27:02 -0400 (EDT)
	(envelope-from mi)
Message-Id: <200706272027.l5RKR2Zl098079@aldan.algebra.com>
Date: Wed, 27 Jun 2007 16:27:02 -0400 (EDT)
From: "Mikhail T." <mi@aldan.algebra.com>
To: FreeBSD-gnats-submit@freebsd.org
Subject: default CFLAGS have a blank at the end
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         114082
>Category:       bin
>Synopsis:       [make.conf] [patch] default CFLAGS have a blank at the end
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    arundel
>State:          analyzed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jun 27 20:30:02 GMT 2007
>Closed-Date:    
>Last-Modified:  Mon Nov 21 23:21:35 UTC 2011
>Originator:     Mikhail T.
>Release:        FreeBSD 6.2-STABLE amd64
>Organization:
Virtual Estates, Inc.
>Environment:
System: FreeBSD aldan.algebra.com 6.2-STABLE FreeBSD 6.2-STABLE #1: Thu Jun 7 22:11:33 EDT 2007 mi@aldan.algebra.com:/meow/obj/var/src/sys/SILVER-SMP amd64

>Description:
	When the CFLAGS are not altered by /etc/make.conf (such as
	by setting the CPUTYPE) or by local Makefile(s), the default
	value contains a blank space at the end: "-O2 -fno-strict-aliasing
	-pipe ".

	Not sure, whether this is a problem with the make code or with
	the /usr/share/mk/*, but I'm afraid, it is the former.

	It is known to be reproducible in 7.x as well as 6.2.

>How-To-Repeat:

	Run make with the following simple two-line makefile:

	echo:
		# >${CFLAGS}<

	Note the extra space before the closing ``<'':

	# >-O2 -fno-strict-aliasing -pipe <

>Fix:
>Release-Note:
>Audit-Trail:

From: "Andrew Pantyukhin" <infofarmer@FreeBSD.org>
To: bug-followup@FreeBSD.org, mi@aldan.algebra.com
Cc:  
Subject: Re: bin/114082: [make.conf] default CFLAGS have a blank at the end
Date: Thu, 5 Jul 2007 09:59:48 +0400

 So instead of trying to fix this, can we ask why
 this is a problem at all?
 
 We never enforce the absence of extra whitespace
 in CFLAGS (and almost in any other variable).
 Cases like "+=" definitions without a preceding
 "=" definition can easily cause this.
 
 Also, having extra blanks before, after or in
 between flags is valid for almost every
 application I have seen. AFAIK, this very issue
 comes from an autoconf idiosyncrasy to match
 CFLAGS in a broken way and spill out some cache-
 related errors.

From: Mikhail Teterin <mi+kde@aldan.algebra.com>
To: "Andrew Pantyukhin" <infofarmer@freebsd.org>
Cc: bug-followup@freebsd.org
Subject: Re: bin/114082: [make.conf] default CFLAGS have a blank at the end
Date: Thu, 5 Jul 2007 07:52:23 -0400

 On  05  2007, Andrew Pantyukhin wrote:
 = So instead of trying to fix this, can we ask why
 = this is a problem at all?
 
 It is a probable sign of a rot somewhere inside make :( Such blanks are 
 supposed to be stripped -- and usually are.
 
 If they aren't, there may be an off-by-one error somewhere...
 
 And, of course, it freaks out certain silly configure scripts (see 
 devel/gdb6's Makefile for a work-around).
 
 	-mi

From: Alexander Best <arundel@freebsd.org>
To: bug-followup@freebsd.org
Cc:  
Subject: Re: bin/114082: [make.conf] default CFLAGS have a blank at the end
Date: Mon, 16 Aug 2010 17:46:28 +0000

 the reason for this is that
 
 CFLAGS           = -O2 -pipe ${_CPUCFLAGS}
 
 and ${_CPUCFLAGS} is empty if CPUTYPE hasn't been set (which it isn't with an
 empty or non-existing make.conf). to verify simply do a `make -dA -VCFLAGS`
 with an empty or non existing /etc/make.conf.
 
 this "problem" still exists in HEAD as of 16 Aug 2010.
 
 cheers.
 alex
 
 -- 
 a13x

From: Alexander Best <arundel@freebsd.org>
To: bug-followup@freebsd.org
Cc:  
Subject: Re: bin/114082: [make.conf] default CFLAGS have a blank at the end
Date: Tue, 7 Sep 2010 14:15:39 +0000

 --r5Pyd7+fXNt84Ff3
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 the following patch works for me. it ensures that ${_CPUCFLAGS} doesn't get
 appended to CFLAGS, as well as to COPTFLAGS, if it hasn't been defined or is
 empty.
 
 cheers.
 alex
 
 -- 
 a13x
 
 --r5Pyd7+fXNt84Ff3
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename="bsd.cpu.mk-and-kern.pre.mk.diff"
 
 diff --git a/share/mk/bsd.cpu.mk b/share/mk/bsd.cpu.mk
 index e3ad18b..fa7fb32 100644
 --- a/share/mk/bsd.cpu.mk
 +++ b/share/mk/bsd.cpu.mk
 @@ -6,6 +6,7 @@
  
  .if !defined(CPUTYPE) || empty(CPUTYPE)
  _CPUCFLAGS =
 +NO_CPU_CFLAGS =
  . if ${MACHINE_ARCH} == "i386"
  MACHINE_CPU = i486
  . elif ${MACHINE_ARCH} == "amd64"
 diff --git a/sys/conf/kern.pre.mk b/sys/conf/kern.pre.mk
 index d4bdc1f..9929176 100644
 --- a/sys/conf/kern.pre.mk
 +++ b/sys/conf/kern.pre.mk
 @@ -23,6 +23,10 @@ NM?=		nm
  OBJCOPY?=	objcopy
  SIZE?=		size
  
 +.if !defined(CPUTYPE) || empty(CPUTYPE)
 +_CPUCFLAGS =
 +NO_CPU_COPTFLAGS =
 +.endif
  .if ${CC:T:Micc} == "icc"
  COPTFLAGS?=	-O
  .else
 
 --r5Pyd7+fXNt84Ff3--
State-Changed-From-To: open->analyzed 
State-Changed-By: arundel 
State-Changed-When: Tue Feb 15 01:58:05 UTC 2011 
State-Changed-Why:  
A patch has been submitted, which should fix the issue. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=114082 
Responsible-Changed-From-To: freebsd-bugs->arundel 
Responsible-Changed-By: arundel 
Responsible-Changed-When: Mon Nov 21 23:20:52 UTC 2011 
Responsible-Changed-Why:  
Assign to me. Although i don't have commit rights to src, 
i'm working on this issue atm. 

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