From nobody@FreeBSD.org  Sun Jul  7 16:18:54 2013
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
	by hub.freebsd.org (Postfix) with ESMTP id A2B9D4BD
	for <freebsd-gnats-submit@FreeBSD.org>; Sun,  7 Jul 2013 16:18:54 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from oldred.freebsd.org (oldred.freebsd.org [8.8.178.121])
	by mx1.freebsd.org (Postfix) with ESMTP id 9550E1A6F
	for <freebsd-gnats-submit@FreeBSD.org>; Sun,  7 Jul 2013 16:18:54 +0000 (UTC)
Received: from oldred.freebsd.org ([127.0.1.6])
	by oldred.freebsd.org (8.14.5/8.14.7) with ESMTP id r67GIsqY040414
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 7 Jul 2013 16:18:54 GMT
	(envelope-from nobody@oldred.freebsd.org)
Received: (from nobody@localhost)
	by oldred.freebsd.org (8.14.5/8.14.5/Submit) id r67GIs1D040407;
	Sun, 7 Jul 2013 16:18:54 GMT
	(envelope-from nobody)
Message-Id: <201307071618.r67GIs1D040407@oldred.freebsd.org>
Date: Sun, 7 Jul 2013 16:18:54 GMT
From: Norikatsu Shigemura <nork@FreeBSD.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [bsd.cpu.mk] Not attach ${_CPUCFLAGS} to CXXFLAGS
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         180365
>Category:       misc
>Synopsis:       [bsd.cpu.mk] [patch] Not attach ${_CPUCFLAGS} to CXXFLAGS
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jul 07 16:20:00 UTC 2013
>Closed-Date:    
>Last-Modified:  Sun Jul 07 20:24:26 UTC 2013
>Originator:     Norikatsu Shigemura
>Release:        FreeBSD/amd64 10.0-CURRENT
>Organization:
Personal
>Environment:
FreeBSD pelsia.ninth-nine.com 10.0-CURRENT FreeBSD 10.0-CURRENT #1: Sun Jul  7 20:45:05 JST 2013     nork@pelsia.ninth-nine.com:/usr/obj/usr/src/sys/PELSIA  amd64
>Description:
In share/mk/bsd.cpu.mk, ${_CPUCFLAGS} is added to CFLAGS.
But CXXFLAGS doesn't.  If CXXFLAGS doesn't set, CXXFLAGS=${CFLAGS}.
So we don't almost notice thus issue.

BTW, ${_CPUCFLAGS} should be added to CXXFLAGS,
because C binaries and C++ binaries are combined multiple -mcpu=XXXX.
Even if thus thing almost no problem, but it's wrong for optimization.
>How-To-Repeat:
$ cd /usr/src
$ make -VCFLAGS -VCXXFLAGS
-O2 -pipe -march=corei7
-O2 -pipe -march=corei7
$ env CFLAGS="-O2" CXXFLAGS="-O2" make -VCFLAGS -VCXXFLAGS
-O2 -march=corei7
-O2
$ env CFLAGS="-O2" make -VCFLAGS -VCXXFLAGS
-O2 -march=corei7
-O2 -march=corei7

$ cd /usr/ports/lang/perl5.16
$ make -VCFLAGS -VCXXFLAGS
-O2 -pipe -march=corei7 -fno-strict-aliasing
-O2 -pipe -march=corei7 -fno-strict-aliasing
$ CFLAGS="-O2" CXXFLAGS="-O2" make -VCFLAGS -VCXXFLAGS
-O2 -march=corei7 -fno-strict-aliasing
-O2

>Fix:
Index: share/mk/bsd.cpu.mk
===================================================================
--- share/mk/bsd.cpu.mk       (revision 252953)
+++ share/mk/bsd.cpu.mk       (working copy)
@@ -259,4 +259,5 @@

 .if !defined(NO_CPU_CFLAGS)
 CFLAGS += ${_CPUCFLAGS}
+CXXFLAGS += ${_CPUCFLAGS}
 .endif

>Release-Note:
>Audit-Trail:
>Unformatted:
