Standardize -std=c++* as
CXXSTD`
CXXSTD was added as the C++ analogue to CSTD. CXXSTD defaults to `-std=c++11` with supporting compilers; `-std=gnu++98`, otherwise for older versions of g++. This change standardizes the CXXSTD variable, originally added to googletest.test.inc.mk as part of r345203. As part of this effort, convert all `CXXFLAGS+= -std=*` calls to use `CXXSTD`. Notes: This value is not sanity checked in bsd.sys.mk, however, given the two most used C++ compilers on FreeBSD (clang++ and g++) support both modes, it is likely to work with both toolchains. This method will be refined in the future to support more variants of C++, as not all versions of clang++ and g++ (for instance) support C++14, C++17, etc. Any manual appending of `-std=*` to `CXXFLAGS` should be replaced with CXXSTD. Example: Before this commit: ``` CXXFLAGS+= -std=c++14 ``` After this commit: ``` CXXSTD= c++14 ``` Reviewed by: asomers Approved by: emaste (mentor) MFC after: 1 month MFC with: r345203, r345704, r345705 Relnotes: yes Tested with: make tinderbox Differential Revision: https://reviews.freebsd.org/D19732
This commit is contained in:
parent
752cabaa1c
commit
760b1a815b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=345706
@ -95,7 +95,7 @@ CFLAGS+= -ffunction-sections
|
|||||||
CFLAGS+= -fdata-sections
|
CFLAGS+= -fdata-sections
|
||||||
LDFLAGS+= -Wl,--gc-sections
|
LDFLAGS+= -Wl,--gc-sections
|
||||||
|
|
||||||
CXXFLAGS+= -std=c++11
|
CXXSTD?= c++11
|
||||||
CXXFLAGS+= -fno-exceptions
|
CXXFLAGS+= -fno-exceptions
|
||||||
CXXFLAGS+= -fno-rtti
|
CXXFLAGS+= -fno-rtti
|
||||||
CXXFLAGS.clang+= -stdlib=libc++
|
CXXFLAGS.clang+= -stdlib=libc++
|
||||||
|
@ -76,9 +76,7 @@ CFLAGS+= -nostdinc++
|
|||||||
CFLAGS+= -nostdlib
|
CFLAGS+= -nostdlib
|
||||||
CFLAGS+= -D_LIBCPP_BUILDING_LIBRARY
|
CFLAGS+= -D_LIBCPP_BUILDING_LIBRARY
|
||||||
CFLAGS+= -DLIBCXXRT
|
CFLAGS+= -DLIBCXXRT
|
||||||
.if empty(CXXFLAGS:M-std=*)
|
CXXSTD= c++11
|
||||||
CXXFLAGS+= -std=c++11
|
|
||||||
.endif
|
|
||||||
|
|
||||||
LIBADD+= cxxrt
|
LIBADD+= cxxrt
|
||||||
INCSGROUPS= STD EXP EXT
|
INCSGROUPS= STD EXP EXT
|
||||||
|
@ -20,8 +20,6 @@ CXXFLAGS+= -nostdinc++
|
|||||||
CXXFLAGS+= -nostdlib
|
CXXFLAGS+= -nostdlib
|
||||||
CXXFLAGS+= -D_LIBCPP_BUILDING_LIBRARY
|
CXXFLAGS+= -D_LIBCPP_BUILDING_LIBRARY
|
||||||
CXXFLAGS+= -DLIBCXXRT
|
CXXFLAGS+= -DLIBCXXRT
|
||||||
.if empty(CXXFLAGS:M-std=*)
|
CXXSTD= c++14
|
||||||
CXXFLAGS+= -std=c++14
|
|
||||||
.endif
|
|
||||||
|
|
||||||
.include <bsd.lib.mk>
|
.include <bsd.lib.mk>
|
||||||
|
@ -22,8 +22,6 @@ CXXFLAGS+= -nostdinc++
|
|||||||
CXXFLAGS+= -nostdlib
|
CXXFLAGS+= -nostdlib
|
||||||
CXXFLAGS+= -D_LIBCPP_BUILDING_LIBRARY
|
CXXFLAGS+= -D_LIBCPP_BUILDING_LIBRARY
|
||||||
CXXFLAGS+= -DLIBCXXRT
|
CXXFLAGS+= -DLIBCXXRT
|
||||||
.if empty(CXXFLAGS:M-std=*)
|
CXXSTD= c++14
|
||||||
CXXFLAGS+= -std=c++14
|
|
||||||
.endif
|
|
||||||
|
|
||||||
.include <bsd.lib.mk>
|
.include <bsd.lib.mk>
|
||||||
|
@ -50,8 +50,8 @@ PROGS+= h_getopt h_getopt_long
|
|||||||
|
|
||||||
CFLAGS+= -I${.CURDIR}
|
CFLAGS+= -I${.CURDIR}
|
||||||
|
|
||||||
CXXFLAGS.cxa_thread_atexit_test+= -std=c++11
|
CXXSTD.cxa_thread_atexit_test= c++11
|
||||||
CXXFLAGS.cxa_thread_atexit_nothr_test+= -std=c++11
|
CXXSTD.cxa_thread_atexit_nothr_test= c++11
|
||||||
LIBADD.cxa_thread_atexit_test+= pthread
|
LIBADD.cxa_thread_atexit_test+= pthread
|
||||||
|
|
||||||
.for t in h_getopt h_getopt_long
|
.for t in h_getopt h_getopt_long
|
||||||
|
@ -41,4 +41,4 @@ CFLAGS+= -funwind-tables
|
|||||||
CXXFLAGS+= -fvisibility-inlines-hidden
|
CXXFLAGS+= -fvisibility-inlines-hidden
|
||||||
CXXFLAGS+= -fvisibility=hidden
|
CXXFLAGS+= -fvisibility=hidden
|
||||||
CFLAGS+= -I${CRTSRC}/lib
|
CFLAGS+= -I${CRTSRC}/lib
|
||||||
CXXFLAGS+= -std=c++11
|
CXXSTD= c++11
|
||||||
|
@ -22,9 +22,7 @@ SRCS+= libelftc_dem_gnu3.c\
|
|||||||
|
|
||||||
WARNS= 0
|
WARNS= 0
|
||||||
CFLAGS+= -isystem ${SRCDIR} -nostdinc++
|
CFLAGS+= -isystem ${SRCDIR} -nostdinc++
|
||||||
.if empty(CXXFLAGS:M-std=*)
|
CXXSTD= c++11
|
||||||
CXXFLAGS+= -std=c++11
|
|
||||||
.endif
|
|
||||||
VERSION_MAP= ${.CURDIR}/Version.map
|
VERSION_MAP= ${.CURDIR}/Version.map
|
||||||
|
|
||||||
.include <bsd.lib.mk>
|
.include <bsd.lib.mk>
|
||||||
|
@ -27,10 +27,8 @@ CXXFLAGS.${file}+= -fno-exceptions -funwind-tables
|
|||||||
.endfor
|
.endfor
|
||||||
|
|
||||||
CFLAGS+= -I${UNWINDINCDIR} -I${.CURDIR} -D_LIBUNWIND_IS_NATIVE_ONLY
|
CFLAGS+= -I${UNWINDINCDIR} -I${.CURDIR} -D_LIBUNWIND_IS_NATIVE_ONLY
|
||||||
.if empty(CXXFLAGS:M-std=*)
|
|
||||||
CXXFLAGS+= -std=c++11
|
|
||||||
.endif
|
|
||||||
CXXFLAGS+= -fno-rtti
|
CXXFLAGS+= -fno-rtti
|
||||||
|
CXXSTD= c++11
|
||||||
STATIC_CXXFLAGS+= -fvisibility=hidden -fPIC
|
STATIC_CXXFLAGS+= -fvisibility=hidden -fPIC
|
||||||
# Probably need to just move this earlier or use CXXFLAGS
|
# Probably need to just move this earlier or use CXXFLAGS
|
||||||
.if ${MK_DIRDEPS_BUILD} == "yes"
|
.if ${MK_DIRDEPS_BUILD} == "yes"
|
||||||
|
@ -53,9 +53,9 @@ CFLAGS+= -I${ITTSRC}
|
|||||||
CFLAGS+= -ffunction-sections
|
CFLAGS+= -ffunction-sections
|
||||||
CFLAGS+= -fdata-sections
|
CFLAGS+= -fdata-sections
|
||||||
CXXFLAGS+= -fvisibility-inlines-hidden
|
CXXFLAGS+= -fvisibility-inlines-hidden
|
||||||
CXXFLAGS+= -std=c++11
|
|
||||||
CXXFLAGS+= -fno-exceptions
|
CXXFLAGS+= -fno-exceptions
|
||||||
CXXFLAGS+= -fno-rtti
|
CXXFLAGS+= -fno-rtti
|
||||||
|
CXXSTD= c++11
|
||||||
|
|
||||||
LDFLAGS+= -Wl,--warn-shared-textrel
|
LDFLAGS+= -Wl,--warn-shared-textrel
|
||||||
LDFLAGS+= -Wl,--gc-sections
|
LDFLAGS+= -Wl,--gc-sections
|
||||||
|
@ -31,9 +31,6 @@ LIBADD= osmcomp ibmad ibumad
|
|||||||
CFLAGS+= -DHAVE_CONFIG_H=1
|
CFLAGS+= -DHAVE_CONFIG_H=1
|
||||||
CFLAGS+= -I${_spath}
|
CFLAGS+= -I${_spath}
|
||||||
CFLAGS+= -I${SYSROOT:U${DESTDIR}}/${INCLUDEDIR}/infiniband
|
CFLAGS+= -I${SYSROOT:U${DESTDIR}}/${INCLUDEDIR}/infiniband
|
||||||
.if ${COMPILER_FEATURES:Mc++11}
|
|
||||||
CXXFLAGS+= -std=c++11
|
|
||||||
.endif
|
|
||||||
VERSION_MAP= ${_spath}/libibnetdisc.map
|
VERSION_MAP= ${_spath}/libibnetdisc.map
|
||||||
|
|
||||||
.include <bsd.lib.mk>
|
.include <bsd.lib.mk>
|
||||||
|
@ -22,8 +22,8 @@ PROGS += ${PROGS_CXX}
|
|||||||
|
|
||||||
.if defined(PROG)
|
.if defined(PROG)
|
||||||
# just one of many
|
# just one of many
|
||||||
PROG_OVERRIDE_VARS += BINDIR BINGRP BINOWN BINMODE DPSRCS MAN NO_WERROR \
|
PROG_OVERRIDE_VARS += BINDIR BINGRP BINOWN BINMODE CSTD CXXSTD DPSRCS MAN \
|
||||||
PROGNAME SRCS STRIP WARNS
|
NO_WERROR PROGNAME SRCS STRIP WARNS
|
||||||
PROG_VARS += CFLAGS CXXFLAGS DEBUG_FLAGS DPADD INTERNALPROG LDADD LIBADD \
|
PROG_VARS += CFLAGS CXXFLAGS DEBUG_FLAGS DPADD INTERNALPROG LDADD LIBADD \
|
||||||
LINKS LDFLAGS MLINKS ${PROG_OVERRIDE_VARS}
|
LINKS LDFLAGS MLINKS ${PROG_OVERRIDE_VARS}
|
||||||
.for v in ${PROG_VARS:O:u}
|
.for v in ${PROG_VARS:O:u}
|
||||||
|
@ -24,6 +24,19 @@ CFLAGS+= -std=iso9899:1999
|
|||||||
.else # CSTD
|
.else # CSTD
|
||||||
CFLAGS+= -std=${CSTD}
|
CFLAGS+= -std=${CSTD}
|
||||||
.endif # 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
|
||||||
|
CXXFLAGS+= -std=${CXXSTD}
|
||||||
|
# CXXSTD
|
||||||
|
|
||||||
# -pedantic is problematic because it also imposes namespace restrictions
|
# -pedantic is problematic because it also imposes namespace restrictions
|
||||||
#CFLAGS+= -pedantic
|
#CFLAGS+= -pedantic
|
||||||
.if defined(WARNS)
|
.if defined(WARNS)
|
||||||
|
@ -1,13 +1,9 @@
|
|||||||
# $FreeBSD$
|
# $FreeBSD$
|
||||||
|
|
||||||
# XXX: this should be defined in bsd.sys.mk
|
|
||||||
CXXSTD?= c++11
|
|
||||||
|
|
||||||
GTESTS_CXXFLAGS+= -DGTEST_HAS_POSIX_RE=1
|
GTESTS_CXXFLAGS+= -DGTEST_HAS_POSIX_RE=1
|
||||||
GTESTS_CXXFLAGS+= -DGTEST_HAS_PTHREAD=1
|
GTESTS_CXXFLAGS+= -DGTEST_HAS_PTHREAD=1
|
||||||
GTESTS_CXXFLAGS+= -DGTEST_HAS_STREAM_REDIRECTION=1
|
GTESTS_CXXFLAGS+= -DGTEST_HAS_STREAM_REDIRECTION=1
|
||||||
GTESTS_CXXFLAGS+= -frtti
|
GTESTS_CXXFLAGS+= -frtti
|
||||||
GTESTS_CXXFLAGS+= -std=${CXXSTD}
|
|
||||||
|
|
||||||
# XXX: src.libnames.mk should handle adding this directory for libgtest's,
|
# XXX: src.libnames.mk should handle adding this directory for libgtest's,
|
||||||
# libgmock's, etc, headers.
|
# libgmock's, etc, headers.
|
||||||
|
@ -6,7 +6,7 @@ MAN= dtc.1
|
|||||||
|
|
||||||
WARNS?= 3
|
WARNS?= 3
|
||||||
|
|
||||||
CXXFLAGS+= -std=c++11 -fno-rtti -fno-exceptions
|
CXXFLAGS+= -fno-rtti -fno-exceptions
|
||||||
|
|
||||||
NO_SHARED?=NO
|
NO_SHARED?=NO
|
||||||
|
|
||||||
|
@ -6,7 +6,8 @@
|
|||||||
PROG_CXX= pmc
|
PROG_CXX= pmc
|
||||||
MAN=
|
MAN=
|
||||||
WARNS?= 3
|
WARNS?= 3
|
||||||
CXXFLAGS+= -O0 -std=c++14
|
CXXFLAGS+= -O0
|
||||||
|
CXXSTD= c++14
|
||||||
CWARNFLAGS.gcc+= -Wno-redundant-decls
|
CWARNFLAGS.gcc+= -Wno-redundant-decls
|
||||||
|
|
||||||
LIBADD= kvm pmc m ncursesw pmcstat elf
|
LIBADD= kvm pmc m ncursesw pmcstat elf
|
||||||
|
Loading…
Reference in New Issue
Block a user