Since clang 3.6.0 now implements the archetype 'freebsd_kprintf' for

__attribute__((format(...))), and the -fformat-extensions flag was
removed, introduce a new macro in bsd.sys.mk to choose the right variant
of compile flag for the used compiler, and use it.

Also add something similar to kern.mk, since including bsd.sys.mk from
that file will anger Warner. :-)

Note that bsd.sys.mk does not support the MK_FORMAT_EXTENSIONS knob used
in kern.mk, since that knob is only available in kern.opts.mk, not in
src.opts.mk.  We might want to add it later, to more easily support
external compilers for building world (in particular, sys/boot).
This commit is contained in:
Dimitry Andric 2015-01-28 18:36:33 +00:00
parent a45fd13259
commit accc510ac3
5 changed files with 15 additions and 7 deletions

View File

@ -109,6 +109,13 @@ CWARNFLAGS+= -Werror
CWARNFLAGS+= -Wno-format
.endif # NO_WFORMAT || NO_WFORMAT.${COMPILER_TYPE}
# How to handle FreeBSD custom printf format specifiers.
.if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 30600
FORMAT_EXTENSIONS= -D__printf__=__freebsd_kprintf__
.else
FORMAT_EXTENSIONS= -fformat-extensions
.endif
.if defined(IGNORE_PRAGMA)
CWARNFLAGS+= -Wno-unknown-pragmas
.endif # IGNORE_PRAGMA

View File

@ -20,8 +20,7 @@ CFLAGS+= -I${.CURDIR}/../../common
CFLAGS+= -DNO_PCI
# Suppress warning from clang for FreeBSD %b and %D formats
CFLAGS+= -fformat-extensions
# Handle FreeBSD specific %b and %D printf format specifiers
CFLAGS+= ${FORMAT_EXTENSIONS}
.include <bsd.lib.mk>

View File

@ -55,8 +55,8 @@ CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}/../common \
# the location of libstand
CFLAGS+= -I${.CURDIR}/../../../../lib/libstand/
# Suppress warning from clang for FreeBSD %b and %D formats
CFLAGS+= -fformat-extensions
# Handle FreeBSD specific %b and %D printf format specifiers
CFLAGS+= ${FORMAT_EXTENSIONS}
.if ${MACHINE_CPUARCH} == "amd64"
CLEANFILES+= machine

View File

@ -44,7 +44,7 @@ CFLAGS+= -I${.CURDIR}/../../common \
# the location of libstand
CFLAGS+= -I${.CURDIR}/../../../../lib/libstand/
# Suppress warning from clang for FreeBSD %b and %D formats
CFLAGS+= -fformat-extensions
# Handle FreeBSD specific %b and %D printf format specifiers
CFLAGS+= ${FORMAT_EXTENSIONS}
.include <bsd.lib.mk>

View File

@ -58,6 +58,8 @@ CWARNEXTRA?= -Wno-uninitialized
# to be disabled. WARNING: format checking is disabled in this case.
.if ${MK_FORMAT_EXTENSIONS} == "no"
FORMAT_EXTENSIONS= -Wno-format
.elif ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 30600
FORMAT_EXTENSIONS= -D__printf__=__freebsd_kprintf__
.else
FORMAT_EXTENSIONS= -fformat-extensions
.endif