After r232322, it turned out many people (and some ports) are building

kernel modules using their old installed /usr/share/mk/bsd.*.mk files,
instead of the updated ones in their source tree.  This leads to errors
like:

  "sys/conf/kmod.mk", line 111: Malformed conditional (${MK_CLANG_IS_CC} == "no" && ${CC:T:Mclang} != "clang")

Obviously, these errors will go away after a "make installworld", or
alternatively, by using "make buildenv" before attempting to manually
build modules.

However, since it is apparently an expected use case to build using old
.mk files, change the way we test for clang, so it also works when the
MK_CLANG_IS_CC macro doesn't exist.

Note the conditional expressions are becoming rather unreadable now, but
I will attempt to fix that on a followup commit.

MFC after:	2 weeks
This commit is contained in:
dim 2012-03-03 18:58:15 +00:00
parent db63f69541
commit 35f5c46c91
4 changed files with 12 additions and 12 deletions

View File

@ -28,7 +28,7 @@ CFLAGS += -std=${CSTD}
. if defined(WARNS)
. if ${WARNS} >= 1
CWARNFLAGS += -Wsystem-headers
. if !defined(NO_WERROR) && ((${MK_CLANG_IS_CC} == "no" && ${CC:T:Mclang} != "clang") || !defined(NO_WERROR.clang))
. if !defined(NO_WERROR) && ((${CC:T:Mclang} != "clang" && (!defined(MK_CLANG_IS_CC) || ${MK_CLANG_IS_CC} == "no")) || !defined(NO_WERROR.clang))
CWARNFLAGS += -Werror
. endif
. endif
@ -42,7 +42,7 @@ CWARNFLAGS += -W -Wno-unused-parameter -Wstrict-prototypes\
. if ${WARNS} >= 4
CWARNFLAGS += -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch\
-Wshadow -Wunused-parameter
. if !defined(NO_WCAST_ALIGN) && ((${MK_CLANG_IS_CC} == "no" && ${CC:T:Mclang} != "clang") || !defined(NO_WCAST_ALIGN.clang))
. if !defined(NO_WCAST_ALIGN) && ((${CC:T:Mclang} != "clang" && (!defined(MK_CLANG_IS_CC) || ${MK_CLANG_IS_CC} == "no")) || !defined(NO_WCAST_ALIGN.clang))
CWARNFLAGS += -Wcast-align
. endif
. endif
@ -59,7 +59,7 @@ CWARNFLAGS += -Wno-uninitialized
CWARNFLAGS += -Wno-pointer-sign
# Clang has more warnings enabled by default, and when using -Wall, so if WARNS
# is set to low values, these have to be disabled explicitly.
. if ${MK_CLANG_IS_CC} != "no" || ${CC:T:Mclang} == "clang"
. if ${CC:T:Mclang} == "clang" || (defined(MK_CLANG_IS_CC) && ${MK_CLANG_IS_CC} != "no")
. if ${WARNS} <= 3
CWARNFLAGS += -Wno-tautological-compare -Wno-unused-value\
-Wno-parentheses-equality -Wno-unused-function\
@ -84,12 +84,12 @@ WFORMAT = 1
. if ${WFORMAT} > 0
#CWARNFLAGS += -Wformat-nonliteral -Wformat-security -Wno-format-extra-args
CWARNFLAGS += -Wformat=2 -Wno-format-extra-args
. if !defined(NO_WERROR) && ((${MK_CLANG_IS_CC} == "no" && ${CC:T:Mclang} != "clang") || !defined(NO_WERROR.clang))
. if !defined(NO_WERROR) && ((${CC:T:Mclang} != "clang" && (!defined(MK_CLANG_IS_CC) || ${MK_CLANG_IS_CC} == "no")) || !defined(NO_WERROR.clang))
CWARNFLAGS += -Werror
. endif
. endif
. endif
. if defined(NO_WFORMAT) || ((${MK_CLANG_IS_CC} != "no" || ${CC:T:Mclang} == "clang") && defined(NO_WFORMAT.clang))
. if defined(NO_WFORMAT) || ((${CC:T:Mclang} == "clang" || (defined(MK_CLANG_IS_CC) && ${MK_CLANG_IS_CC} != "no")) && defined(NO_WFORMAT.clang))
CWARNFLAGS += -Wno-format
. endif
.endif
@ -98,7 +98,7 @@ CWARNFLAGS += -Wno-format
CWARNFLAGS += -Wno-unknown-pragmas
.endif
.if ${MK_CLANG_IS_CC} != "no" || ${CC:T:Mclang} == "clang"
.if ${CC:T:Mclang} == "clang" || (defined(MK_CLANG_IS_CC) && ${MK_CLANG_IS_CC} != "no")
CLANG_NO_IAS = -no-integrated-as
CLANG_OPT_SMALL = -mllvm -stack-alignment=8 -mllvm -inline-threshold=3 \
-mllvm -enable-load-pre=false

View File

@ -15,7 +15,7 @@ CWARNFLAGS?= -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes \
# Disable a few warnings for clang, since there are several places in the
# kernel where fixing them is more trouble than it is worth, or where there is
# a false positive.
.if ${MK_CLANG_IS_CC} != "no" || ${CC:T:Mclang} == "clang"
.if ${CC:T:Mclang} == "clang" || (defined(MK_CLANG_IS_CC) && ${MK_CLANG_IS_CC} != "no")
NO_WCONSTANT_CONVERSION= -Wno-constant-conversion
NO_WARRAY_BOUNDS= -Wno-array-bounds
NO_WSHIFT_COUNT_NEGATIVE= -Wno-shift-count-negative
@ -50,7 +50,7 @@ CWARNEXTRA?= -Wno-error-tautological-compare -Wno-error-empty-body \
# -mno-sse3, -mno-ssse3, -mno-sse41 and -mno-sse42
#
.if ${MACHINE_CPUARCH} == "i386"
.if ${MK_CLANG_IS_CC} == "no" && ${CC:T:Mclang} != "clang"
.if ${CC:T:Mclang} != "clang" && (!defined(MK_CLANG_IS_CC) || ${MK_CLANG_IS_CC} == "no")
CFLAGS+= -mno-align-long-strings -mpreferred-stack-boundary=2 -mno-sse
.else
CFLAGS+= -mno-aes -mno-avx
@ -98,7 +98,7 @@ INLINE_LIMIT?= 15000
# (-mfpmath= is not supported)
#
.if ${MACHINE_CPUARCH} == "amd64"
.if ${MK_CLANG_IS_CC} == "no" && ${CC:T:Mclang} != "clang"
.if ${CC:T:Mclang} != "clang" && (!defined(MK_CLANG_IS_CC) || ${MK_CLANG_IS_CC} == "no")
CFLAGS+= -mno-sse
.else
CFLAGS+= -mno-aes -mno-avx

View File

@ -34,7 +34,7 @@ _MINUS_O= -O2
.endif
.endif
.if ${MACHINE_CPUARCH} == "amd64"
.if ${MK_CLANG_IS_CC} == "no" && ${CC:T:Mclang} != "clang"
.if ${CC:T:Mclang} != "clang" && (!defined(MK_CLANG_IS_CC) || ${MK_CLANG_IS_CC} == "no")
COPTFLAGS?=-O2 -frename-registers -pipe
.else
COPTFLAGS?=-O2 -pipe
@ -84,7 +84,7 @@ INCLUDES+= -I$S/dev/cxgb -I$S/dev/cxgbe
CFLAGS= ${COPTFLAGS} ${C_DIALECT} ${DEBUG} ${CWARNFLAGS}
CFLAGS+= ${INCLUDES} -D_KERNEL -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h
.if ${MK_CLANG_IS_CC} == "no" && ${CC:T:Mclang} != "clang"
.if ${CC:T:Mclang} != "clang" && (!defined(MK_CLANG_IS_CC) || ${MK_CLANG_IS_CC} == "no")
CFLAGS+= -fno-common -finline-limit=${INLINE_LIMIT}
.if ${MACHINE_CPUARCH} != "mips"
CFLAGS+= --param inline-unit-growth=100

View File

@ -108,7 +108,7 @@ CFLAGS+= -I. -I@
# for example.
CFLAGS+= -I@/contrib/altq
.if ${MK_CLANG_IS_CC} == "no" && ${CC:T:Mclang} != "clang"
.if ${CC:T:Mclang} != "clang" && (!defined(MK_CLANG_IS_CC) || ${MK_CLANG_IS_CC} == "no")
CFLAGS+= -finline-limit=${INLINE_LIMIT}
CFLAGS+= --param inline-unit-growth=100
CFLAGS+= --param large-function-growth=1000