From db933d76bb02f19347b706717ff7e70044d0a5fa Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Mon, 22 Apr 2019 18:40:46 +0000 Subject: [PATCH] Fix up CXXSTD support originally added in r345708 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. MFC after: 2 weeks MFC with: r345708, r346574 Reviewed by: emaste Reported by: jbeich Differential Revision: https://reviews.freebsd.org/D19895 (as part of a larger change) --- share/mk/bsd.sys.mk | 12 ++---------- share/mk/googletest.test.inc.mk | 2 ++ 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/share/mk/bsd.sys.mk b/share/mk/bsd.sys.mk index 836f23a62c14..00146a138fbd 100644 --- a/share/mk/bsd.sys.mk +++ b/share/mk/bsd.sys.mk @@ -25,17 +25,9 @@ CFLAGS+= -std=iso9899:1999 CFLAGS+= -std=${CSTD} .endif # CSTD -.if ${COMPILER_FEATURES:Mc++11} -CXXSTD?= c++11 -.elif ${COMPILER_TYPE} == "gcc" -# Prior versions of g++ support C++98 with GNU extensions by default. -CXXSTD?= gnu++98 -.else -# Assume that the compiler supports at least C++98. -CXXSTD?= c++98 -.endif +.if !empty(CXXSTD) CXXFLAGS+= -std=${CXXSTD} -# CXXSTD +.endif # -pedantic is problematic because it also imposes namespace restrictions #CFLAGS+= -pedantic diff --git a/share/mk/googletest.test.inc.mk b/share/mk/googletest.test.inc.mk index 98f0e6a6fbe3..ee08a9a70dcc 100644 --- a/share/mk/googletest.test.inc.mk +++ b/share/mk/googletest.test.inc.mk @@ -9,4 +9,6 @@ GTESTS_CXXFLAGS+= -frtti # libgmock's, etc, headers. CXXFLAGS+= -I${DESTDIR}${INCLUDEDIR}/private +CXXSTD?= c++11 + NO_WTHREAD_SAFETY=