src: Use gnu++17 as the default C++ standard

Previously the compiler's default C++ standard was used unlike C where
bsd.sys.mk explicitly sets a default language version.  Setting an
explicit default version will give a more uniform experience across
different compilers and compiler versions.

gnu++17 was chosen to match the default C standard.  It is well
supported by a wide range of clang (5+) and GCC (9+) versions.

gnu++17 is also the default C++ standard in recent versions of clang
(16+) and GCC (11+).  As a result, many of the explicit CXXSTD
settings in Makefiles had the effect of lowering the C++ standard
instead of raising it as was originally intended and are removed.

Note that the remaining explicit CXXSTD settings for atf and liblutok
explicitly lower the standard to C++11 due to use of the deprecated
auto_ptr<> template which is removed in later versions.

Reviewed by:	imp, asomers, dim, emaste
Differential Revision:	https://reviews.freebsd.org/D49223
This commit is contained in:
John Baldwin 2025-04-11 09:53:50 -04:00
parent 75a24e7f9a
commit 6527682ab7
13 changed files with 2 additions and 15 deletions

View file

@ -119,7 +119,6 @@ LDFLAGS+= -Wl,-m,elf64lriscv_fbsd
.endif
.endif
CXXSTD?= c++17
CXXFLAGS+= -fno-exceptions
CXXFLAGS+= -fno-rtti
.if ${.MAKE.OS} == "FreeBSD" || !defined(BOOTSTRAPPING)

View file

@ -59,8 +59,6 @@ PROGS+= h_getopt h_getopt_long
CFLAGS+= -I${.CURDIR}
CXXSTD.cxa_thread_atexit_test= c++11
CXXSTD.cxa_thread_atexit_nothr_test= c++11
LIBADD.cxa_thread_atexit_test+= pthread
# Tests that requires Blocks feature

View file

@ -33,4 +33,3 @@ CXXFLAGS+= -fvisibility-inlines-hidden
CXXFLAGS+= -fvisibility=hidden
CFLAGS+= -I${CRTSRC}/include
CFLAGS+= -I${CRTSRC}/lib
CXXSTD= c++17

View file

@ -23,7 +23,6 @@ SRCS+= typeinfo.cc
WARNS?= 0
CFLAGS+= -isystem ${SRCDIR} -nostdinc++
CXXSTD?= c++14
.if exists(Version.map.${MACHINE})
VERSION_MAP= ${.CURDIR}/Version.map.${MACHINE}

View file

@ -38,7 +38,6 @@ CFLAGS+= -I${UNWINDINCDIR}
CFLAGS+= -D_LIBUNWIND_IS_NATIVE_ONLY
CFLAGS+= -D_LIBUNWIND_USE_FRAME_HEADER_CACHE
CXXFLAGS+= -fno-rtti
CXXSTD?= c++11
STATIC_CXXFLAGS+= -fvisibility=hidden -fPIC
# Probably need to just move this earlier or use CXXFLAGS
.if ${MK_DIRDEPS_BUILD} == "yes"

View file

@ -57,7 +57,6 @@ CFLAGS+= -fdata-sections
CXXFLAGS+= -fvisibility-inlines-hidden
CXXFLAGS+= -fno-exceptions
CXXFLAGS+= -fno-rtti
CXXSTD= c++17
.if ${COMPILER_TYPE} == "clang"
.if ${MACHINE_CPUARCH} == "i386"

View file

@ -29,7 +29,6 @@ LIBADD= osmcomp ibmad ibumad
CFLAGS+= -DHAVE_CONFIG_H=1
CFLAGS+= -I${_spath}
CFLAGS+= -I${SYSROOT:U${DESTDIR}}/${INCLUDEDIR}/infiniband
CXXSTD= c++11
VERSION_MAP= ${_spath}/libibnetdisc.map
.include <bsd.lib.mk>

View file

@ -4,7 +4,6 @@
PACKAGE= tests
PROG_CXX= atf_pytest_wrapper
SRCS= atf_pytest_wrapper.cpp
CXXSTD= c++17
MAN=
.include <bsd.prog.mk>

View file

@ -22,6 +22,8 @@ CFLAGS+= -std=iso9899:1999
CFLAGS+= -std=${CSTD}
.endif # CSTD
CXXSTD?= gnu++17
.if !empty(CXXSTD)
CXXFLAGS+= -std=${CXXSTD}
.endif

View file

@ -9,6 +9,4 @@ GTESTS_CXXFLAGS+= -frtti
# libgmock's, etc, headers.
CXXFLAGS+= -I${DESTDIR}${INCLUDEDIR}/private
CXXSTD?= c++14
NO_WTHREAD_SAFETY=

View file

@ -89,7 +89,6 @@ CXXFLAGS+= -I${SRCTOP}/tests
CXXFLAGS+= -I${FUSEFS}
CXXFLAGS+= -I${MOUNT}
.PATH: ${MOUNT}
CXXSTD= c++14
LIBADD+= pthread
LIBADD+= gmock gtest

View file

@ -6,8 +6,6 @@ WARNS?= 3
CXXFLAGS+= -fno-rtti -fno-exceptions
CXXSTD= c++17
NO_SHARED?=NO
.include <bsd.prog.mk>

View file

@ -2,7 +2,6 @@
PROG_CXX= pmc
MAN=
CXXSTD= c++14
CWARNFLAGS.gcc+= -Wno-redundant-decls
CFLAGS+= -I${SRCTOP}/lib/libpmcstat