git: 6527682ab705 - main - src: Use gnu++17 as the default C++ standard

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Fri, 11 Apr 2025 13:54:30 UTC
The branch main has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=6527682ab7058e5023a2a6dea01d51c15dca701f

commit 6527682ab7058e5023a2a6dea01d51c15dca701f
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2025-04-11 13:53:50 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2025-04-11 13:53:50 +0000

    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
---
 lib/clang/llvm.build.mk                 | 1 -
 lib/libc/tests/stdlib/Makefile          | 2 --
 lib/libclang_rt/Makefile.inc            | 1 -
 lib/libcxxrt/Makefile                   | 1 -
 lib/libgcc_eh/Makefile.inc              | 1 -
 lib/libomp/Makefile                     | 1 -
 lib/ofed/libibnetdisc/Makefile          | 1 -
 libexec/atf/atf-pytest-wrapper/Makefile | 1 -
 share/mk/bsd.sys.mk                     | 2 ++
 share/mk/googletest.test.inc.mk         | 2 --
 tests/sys/fs/fusefs/Makefile            | 1 -
 usr.bin/dtc/Makefile                    | 2 --
 usr.sbin/pmc/Makefile                   | 1 -
 13 files changed, 2 insertions(+), 15 deletions(-)

diff --git a/lib/clang/llvm.build.mk b/lib/clang/llvm.build.mk
index 2520637e2d06..c731deba8976 100644
--- a/lib/clang/llvm.build.mk
+++ b/lib/clang/llvm.build.mk
@@ -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)
diff --git a/lib/libc/tests/stdlib/Makefile b/lib/libc/tests/stdlib/Makefile
index 54ac8a5f3b42..15b8d3844d08 100644
--- a/lib/libc/tests/stdlib/Makefile
+++ b/lib/libc/tests/stdlib/Makefile
@@ -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
diff --git a/lib/libclang_rt/Makefile.inc b/lib/libclang_rt/Makefile.inc
index c472e8b741be..e7db5a469661 100644
--- a/lib/libclang_rt/Makefile.inc
+++ b/lib/libclang_rt/Makefile.inc
@@ -33,4 +33,3 @@ CXXFLAGS+=	-fvisibility-inlines-hidden
 CXXFLAGS+=	-fvisibility=hidden
 CFLAGS+=	-I${CRTSRC}/include
 CFLAGS+=	-I${CRTSRC}/lib
-CXXSTD=		c++17
diff --git a/lib/libcxxrt/Makefile b/lib/libcxxrt/Makefile
index 7a683ba779f6..0f203b3a7cb1 100644
--- a/lib/libcxxrt/Makefile
+++ b/lib/libcxxrt/Makefile
@@ -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}
diff --git a/lib/libgcc_eh/Makefile.inc b/lib/libgcc_eh/Makefile.inc
index af59ee7aaa65..529ef7170485 100644
--- a/lib/libgcc_eh/Makefile.inc
+++ b/lib/libgcc_eh/Makefile.inc
@@ -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"
diff --git a/lib/libomp/Makefile b/lib/libomp/Makefile
index 6c14c7d21077..f1513e70f3f6 100644
--- a/lib/libomp/Makefile
+++ b/lib/libomp/Makefile
@@ -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"
diff --git a/lib/ofed/libibnetdisc/Makefile b/lib/ofed/libibnetdisc/Makefile
index d3e0dd92509a..aac0bf0f5971 100644
--- a/lib/ofed/libibnetdisc/Makefile
+++ b/lib/ofed/libibnetdisc/Makefile
@@ -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>
diff --git a/libexec/atf/atf-pytest-wrapper/Makefile b/libexec/atf/atf-pytest-wrapper/Makefile
index e4dc0f8a5fd1..80b5e411ec4e 100644
--- a/libexec/atf/atf-pytest-wrapper/Makefile
+++ b/libexec/atf/atf-pytest-wrapper/Makefile
@@ -4,7 +4,6 @@
 PACKAGE=	tests
 PROG_CXX=	atf_pytest_wrapper
 SRCS=		atf_pytest_wrapper.cpp
-CXXSTD=		c++17
 MAN=
 
 .include <bsd.prog.mk>
diff --git a/share/mk/bsd.sys.mk b/share/mk/bsd.sys.mk
index 63496e9b8ccd..b8535809e5aa 100644
--- a/share/mk/bsd.sys.mk
+++ b/share/mk/bsd.sys.mk
@@ -22,6 +22,8 @@ CFLAGS+=	-std=iso9899:1999
 CFLAGS+=	-std=${CSTD}
 .endif # CSTD
 
+CXXSTD?=	gnu++17
+
 .if !empty(CXXSTD)
 CXXFLAGS+=	-std=${CXXSTD}
 .endif
diff --git a/share/mk/googletest.test.inc.mk b/share/mk/googletest.test.inc.mk
index 05415775448b..9ef5a3ceac00 100644
--- a/share/mk/googletest.test.inc.mk
+++ b/share/mk/googletest.test.inc.mk
@@ -9,6 +9,4 @@ GTESTS_CXXFLAGS+= -frtti
 # libgmock's, etc, headers.
 CXXFLAGS+=	-I${DESTDIR}${INCLUDEDIR}/private
 
-CXXSTD?=	c++14
-
 NO_WTHREAD_SAFETY=
diff --git a/tests/sys/fs/fusefs/Makefile b/tests/sys/fs/fusefs/Makefile
index d91199fd519e..06b82071fe31 100644
--- a/tests/sys/fs/fusefs/Makefile
+++ b/tests/sys/fs/fusefs/Makefile
@@ -89,7 +89,6 @@ CXXFLAGS+=	-I${SRCTOP}/tests
 CXXFLAGS+=	-I${FUSEFS}
 CXXFLAGS+=	-I${MOUNT}
 .PATH:		${MOUNT}
-CXXSTD=		c++14
 
 LIBADD+=	pthread
 LIBADD+=	gmock gtest
diff --git a/usr.bin/dtc/Makefile b/usr.bin/dtc/Makefile
index 9b1aff13511f..d7661ae164c3 100644
--- a/usr.bin/dtc/Makefile
+++ b/usr.bin/dtc/Makefile
@@ -6,8 +6,6 @@ WARNS?=	3
 
 CXXFLAGS+=	-fno-rtti -fno-exceptions
 
-CXXSTD=	c++17
-
 NO_SHARED?=NO
 
 .include <bsd.prog.mk>
diff --git a/usr.sbin/pmc/Makefile b/usr.sbin/pmc/Makefile
index 3f73dd398958..02292917ab57 100644
--- a/usr.sbin/pmc/Makefile
+++ b/usr.sbin/pmc/Makefile
@@ -2,7 +2,6 @@
 
 PROG_CXX=	pmc
 MAN=	
-CXXSTD= c++14
 CWARNFLAGS.gcc+= -Wno-redundant-decls
 CFLAGS+= -I${SRCTOP}/lib/libpmcstat