Page MenuHomeFreeBSD

Fix up CXXSTD support, added in r345708
ClosedPublic

Authored by ngie on Apr 13 2019, 9:04 AM.
Tags
None
Referenced Files
F82099396: D19895.id56158.diff
Thu, Apr 25, 12:27 PM
Unknown Object (File)
Mon, Apr 22, 8:44 AM
Unknown Object (File)
Mon, Apr 22, 8:31 AM
Unknown Object (File)
Jan 1 2024, 8:59 AM
Unknown Object (File)
Dec 11 2023, 5:48 AM
Unknown Object (File)
Aug 29 2023, 4:02 PM
Unknown Object (File)
Aug 29 2023, 3:56 PM
Unknown Object (File)
Aug 29 2023, 12:13 PM
Subscribers

Details

Reviewers
emaste
jbeich
jhb
Summary

r345708 worked for the base system, but unfortunately, caused a lot of
disruption for third-party packages that relied on C++, since bsd.sys.mk is
used by applications outside the base system. The defaults picked didn't match
the compiler's defaults and broke some builds that didn't specify a standard,
as well as some that overrode the value by setting -std=gnu++14 (for
example) manually.

This change takes a more relaxed approach to appending -std=${CXXSTD} to
CXXFLAGS, by only doing so when the value is specified, as opposed to
overriding the standard set by an end-user. This avoids the need for having
to bake NOP default into bsd.sys.mk for supported compiler-toolchain
versions.

In order to make this change possible, add CXXSTD to Makefile snippets which
relied on the default value (c++11) added in r345708. For those Makefile
snippets that allowed the end-user to override the standard, make it default
to the target standard used prior to r345708 to match the behavior from
before the change.

MFC after: 2 weeks
MFC with: r345708
Reported by: jbeich

Test Plan

make tinderbox

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Errors
SeverityLocationCodeMessage
Errorlib/libc++/Makefile:NAME1Bad Filename
Errorlib/libc++experimental/Makefile:NAME1Bad Filename
Errorlib/libc++fs/Makefile:NAME1Bad Filename
Unit
No Test Coverage
Build Status
Buildable 23653
Build 22634: arc lint + arc unit

Event Timeline

ngie edited the summary of this revision. (Show Details)
lib/libc++/Makefile
79

For all of these libraries, what is the rationale for switching from = to ?=?

share/mk/bsd.sys.mk
28

Is there value in keeping the old check as well? (i.e. ${COMPILER_FEATURES:Mc++11} && !empty(CXXSTD))

(I wonder if it would cause problems if the C++ standard version got added to the build of a C file in a library with mixed C and C++ code.)

ngie marked 2 inline comments as done.Apr 14 2019, 2:57 AM
ngie added inline comments.
lib/libc++/Makefile
79

Apologies. The reasoning is buried in the proposed commit message:

For those Makefile snippets that allowed the end-user to override the standard,
make it default to the target standard used prior to r345708 to match the behavior
from before the change.
share/mk/bsd.sys.mk
28

Is there value in keeping the old check as well? (i.e. ${COMPILER_FEATURES:Mc++11} && !empty(CXXSTD))

No. I don't want this variable to be set based on whether or not the compiler is deemed to be C++11 capable, because it's a very broad brushstroke to apply to everything that relies on bsd.sys.mk, especially because the list in bsd.compiler.mk is incomplete (icc, etc).

(I wonder if it would cause problems if the C++ standard version got added to the build of a C file in a library with mixed C and C++ code.)

It won't cause problems with CSTD values applied to C++ objects, since CXXSTD gets applied later on:

$ make CXXSTD=c++11 -VCFLAGS -VCXXFLAGS
-O2 -pipe -I/home/ngie/svn/freebsd/base/head/lib/libpmc   -g  -std=gnu99 -fstack-protector-strong -Wsystem-headers -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wno-uninitialized -Wno-pointer-sign -Wno-empty-body -Wno-string-plus-int -Wno-unused-const-variable -Wno-tautological-compare -Wno-unused-value -Wno-parentheses-equality -Wno-unused-function -Wno-enum-conversion -Wno-unused-local-typedef -Wno-address-of-packed-member  -Qunused-arguments 
-O2 -pipe -I/home/ngie/svn/freebsd/base/head/lib/libpmc -g -fstack-protector-strong -Wsystem-headers -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wpointer-arith -Wno-uninitialized -Wno-empty-body -Wno-string-plus-int -Wno-unused-const-variable -Wno-tautological-compare -Wno-unused-value -Wno-parentheses-equality -Wno-unused-function -Wno-enum-conversion -Wno-unused-local-typedef -Wno-address-of-packed-member -Qunused-arguments  -g -std=c++11 -Wno-c++11-extensions 
$ make CXXSTD=c++11 -V'${CFLAGS:M-std=*}' -V'${CXXFLAGS:M-std=*}'
-std=gnu99
-std=c++11

CXXSTD overrides CSTD when both are present, as seen with lib/libpmc.

lib/libc++/Makefile
79

I think this (whole) change is fine, but ISTM that it'd be easier to follow if done as two separate commits. Is it OK to commit just the ?= change first?

ngie marked 3 inline comments as done.Apr 20 2019, 1:08 PM
ngie added inline comments.
lib/libc++/Makefile
79

I'll do that :).

This revision is now accepted and ready to land.Apr 22 2019, 6:31 PM
ngie marked an inline comment as done.

Committed as rS346574 and rS346576.