Bug 180365 - [bsd.cpu.mk] Not attach ${_CPUCFLAGS} to CXXFLAGS
Summary: [bsd.cpu.mk] Not attach ${_CPUCFLAGS} to CXXFLAGS
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: misc (show other bugs)
Version: 10.0-CURRENT
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-07-07 17:20 UTC by Norikatsu Shigemura
Modified: 2025-01-21 21:29 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Norikatsu Shigemura freebsd_committer freebsd_triage 2013-07-07 17:20:00 UTC
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.

Fix: 

.if !defined(NO_CPU_CFLAGS)
 CFLAGS += ${_CPUCFLAGS}
+CXXFLAGS += ${_CPUCFLAGS}
 .endif--0FWefJ7gmV6krGXrq5Uw3GRZCJViUTRkyvuSt4UWHQ0CBqZG
Content-Type: text/plain; name="file.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="file.diff"

Index: share/mk/bsd.cpu.mk
===================================================================
--- share/mk/bsd.cpu.mk       (revision 252953)
+++ share/mk/bsd.cpu.mk       (working copy)
@@ -259,4 +259,5 @@
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
Comment 1 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 08:00:34 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped
Comment 2 Graham Perrin freebsd_committer freebsd_triage 2022-10-17 12:38:39 UTC
Keyword: 

    patch
or  patch-ready

– in lieu of summary line prefix: 

    [patch]

* bulk change for the keyword
* summary lines may be edited manually (not in bulk). 

Keyword descriptions and search interface: 

    <https://bugs.freebsd.org/bugzilla/describekeywords.cgi>
Comment 3 Warner Losh freebsd_committer freebsd_triage 2025-01-20 20:59:07 UTC
Nice catch... too bad we ignored this for approximately forever.
I noticed it last night looking for something else, and committed.
Comment 4 commit-hook freebsd_committer freebsd_triage 2025-01-21 21:26:09 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=0fb33e049ac01ebe85a0bc2af670d4ac82df59c8

commit 0fb33e049ac01ebe85a0bc2af670d4ac82df59c8
Author:     Norikatsu Shigemura <nork@FreeBSD.org>
AuthorDate: 2025-01-20 20:53:19 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2025-01-21 21:24:10 +0000

    bsd.cpu.mk: Add _CPUFLAGS to CXXFLAGS as well

    PR: 180365
    Reviewed by: imp
    Sponsored by: Netflix

 share/mk/bsd.cpu.mk | 1 +
 1 file changed, 1 insertion(+)