git: 5e5687aac4e0 - stable/14 - src: Use gnu++17 as the default C++ standard

From: Enji Cooper <ngie_at_FreeBSD.org>
Date: Mon, 23 Nov 2026 05:49:24 UTC
The branch stable/14 has been updated by ngie:

URL: https://cgit.FreeBSD.org/src/commit/?id=5e5687aac4e069dc20fa8dc735c581c188534144

commit 5e5687aac4e069dc20fa8dc735c581c188534144
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2025-04-11 13:53:50 +0000
Commit:     Enji Cooper <ngie@FreeBSD.org>
CommitDate: 2026-11-23 05:44:04 +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
    
    (cherry picked from commit 6527682ab7058e5023a2a6dea01d51c15dca701f)
---
 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 e06f9a2c29f6..4716ce12f48d 100644
--- a/lib/clang/llvm.build.mk
+++ b/lib/clang/llvm.build.mk
@@ -122,7 +122,6 @@ LDFLAGS+=	-Wl,-m,elf64lriscv_fbsd
 .endif
 .endif
 
-CXXSTD?=	c++17
 CXXFLAGS+=	-fno-exceptions
 CXXFLAGS+=	-fno-rtti
 CXXFLAGS+=	-fvisibility-inlines-hidden
diff --git a/lib/libc/tests/stdlib/Makefile b/lib/libc/tests/stdlib/Makefile
index 14f1ab022c37..6c7c61bf291b 100644
--- a/lib/libc/tests/stdlib/Makefile
+++ b/lib/libc/tests/stdlib/Makefile
@@ -61,8 +61,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 4be3c667462f..b0386bb0ae5d 100644
--- a/lib/libclang_rt/Makefile.inc
+++ b/lib/libclang_rt/Makefile.inc
@@ -35,4 +35,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 48a724dd42f2..66465694e975 100644
--- a/lib/libcxxrt/Makefile
+++ b/lib/libcxxrt/Makefile
@@ -21,7 +21,6 @@ SRCS+=		typeinfo.cc
 
 WARNS?=		0
 CFLAGS+=	-isystem ${SRCDIR} -nostdinc++
-CXXSTD?=	c++14
 VERSION_MAP=	${.CURDIR}/Version.map
 
 .include <bsd.lib.mk>
diff --git a/lib/libgcc_eh/Makefile.inc b/lib/libgcc_eh/Makefile.inc
index 75e7d743a720..82012746b2c2 100644
--- a/lib/libgcc_eh/Makefile.inc
+++ b/lib/libgcc_eh/Makefile.inc
@@ -39,7 +39,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 aa9e6799ab59..81010084a2bf 100644
--- a/lib/libomp/Makefile
+++ b/lib/libomp/Makefile
@@ -55,7 +55,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 47470132a2b6..2eb82fb8c938 100644
--- a/lib/ofed/libibnetdisc/Makefile
+++ b/lib/ofed/libibnetdisc/Makefile
@@ -31,7 +31,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 e2491a49b29d..28ba3cdf70ee 100644
--- a/share/mk/bsd.sys.mk
+++ b/share/mk/bsd.sys.mk
@@ -23,6 +23,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 1293373e2451..a8035a3bd7a4 100644
--- a/tests/sys/fs/fusefs/Makefile
+++ b/tests/sys/fs/fusefs/Makefile
@@ -100,7 +100,6 @@ CXXWARNFLAGS+=	-Wno-vla-cxx-extension
 CXXFLAGS+=	-I${SRCTOP}/tests
 CXXFLAGS+=	-I${FUSEFS}
 CXXFLAGS+=	-I${MOUNT}
-CXXSTD=		c++14
 
 .for f in getmntopts.c mntopts.h
 CLEANFILES+=	${f}
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 dda72c85a106..a4e12470ae5e 100644
--- a/usr.sbin/pmc/Makefile
+++ b/usr.sbin/pmc/Makefile
@@ -6,7 +6,6 @@ PROG_CXX=	pmc
 MAN=	
 WARNS?=	3
 CXXFLAGS+= -O0
-CXXSTD= c++14
 CWARNFLAGS.gcc+= -Wno-redundant-decls
 CFLAGS+= -I${SRCTOP}/lib/libpmcstat