Simplify clang ifdefs in the kernel a bit. Introduce

CFLAGS.${COMPILER_TYPE} to mirror userland. Be explicit about which
compiler needs something (not clang isn't necessarily gcc in the
future).
This commit is contained in:
Warner Losh 2014-05-10 16:38:09 +00:00
parent 7273339dc4
commit 22ba0b2f67
4 changed files with 24 additions and 39 deletions

View File

@ -39,20 +39,17 @@ SYSTEM_DEP:= ${SYSTEM_DEP:$S/conf/ldscript.$M=ldscript.$M}
STRIP_FLAGS = -S
.endif
.if ${COMPILER_TYPE} != "clang"
CFLAGS += -mno-thumb-interwork
.endif
# We don't support gcc's thump interwork stuff, so disable it
CFLAGS.gcc += -mno-thumb-interwork
.if empty(DDB_ENABLED)
.if ${MK_ARM_EABI} == "no" && ${COMPILER_TYPE} == "gcc"
CFLAGS += -mno-apcs-frame
.if ${MK_ARM_EABI} == "no"
CFLAGS.gcc += -mno-apcs-frame
.endif
.elif ${MK_ARM_EABI} != "no"
CFLAGS += -funwind-tables
.if ${COMPILER_TYPE} == "clang"
# clang requires us to tell it to emit assembly with unwind information
CFLAGS += -mllvm -arm-enable-ehabi
.endif
CFLAGS.clang += -mllvm -arm-enable-ehabi
.endif
# hack because genassym.c includes sys/bus.h which includes these.

View File

@ -64,11 +64,8 @@ FORMAT_EXTENSIONS= -fformat-extensions
# Setting -mno-sse implies -mno-sse2, -mno-sse3, -mno-ssse3, -mno-sse41 and -mno-sse42
#
.if ${MACHINE_CPUARCH} == "i386"
.if ${COMPILER_TYPE} != "clang"
CFLAGS+= -mno-align-long-strings -mpreferred-stack-boundary=2
.else
CFLAGS+= -mno-aes -mno-avx
.endif
CFLAGS.gcc+= -mno-align-long-strings -mpreferred-stack-boundary=2
CFLAGS.clang+= -mno-aes -mno-avx
CFLAGS+= -mno-mmx -mno-sse -msoft-float
INLINE_LIMIT?= 8000
.endif
@ -93,11 +90,8 @@ INLINE_LIMIT?= 15000
# operations which it has a tendency to do.
#
.if ${MACHINE_CPUARCH} == "sparc64"
.if ${COMPILER_TYPE} == "clang"
CFLAGS+= -mcmodel=large -fno-dwarf2-cfi-asm
.else
CFLAGS+= -mcmodel=medany -msoft-float
.endif
CFLAGS.clang+= -mcmodel=large -fno-dwarf2-cfi-asm
CFLAGS.gcc+= -mcmodel=medany -msoft-float
INLINE_LIMIT?= 15000
.endif
@ -116,9 +110,7 @@ INLINE_LIMIT?= 15000
# (-mfpmath= is not supported)
#
.if ${MACHINE_CPUARCH} == "amd64"
.if ${COMPILER_TYPE} == "clang"
CFLAGS+= -mno-aes -mno-avx
.endif
CFLAGS.clang+= -mno-aes -mno-avx
CFLAGS+= -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float \
-fno-asynchronous-unwind-tables
INLINE_LIMIT?= 8000
@ -173,3 +165,5 @@ CFLAGS+= -fstack-protector
.if ${CFLAGS:M-g} != "" && ${CFLAGS:M-gdwarf*} == ""
CFLAGS+= -gdwarf-2
.endif
CFLAGS+= ${CFLAGS.${COMPILER_TYPE}}

View File

@ -37,10 +37,10 @@ _MINUS_O= -O2
.endif
.endif
.if ${MACHINE_CPUARCH} == "amd64"
.if ${COMPILER_TYPE} != "clang"
COPTFLAGS?=-O2 -frename-registers -pipe
.else
.if ${COMPILER_TYPE} == "clang"
COPTFLAGS?=-O2 -pipe
.else
COPTFLAGS?=-O2 -frename-registers -pipe
.endif
.else
COPTFLAGS?=${_MINUS_O} -pipe
@ -86,13 +86,11 @@ CFLAGS_PARAM_LARGE_FUNCTION_GROWTH?=1000
.if ${MACHINE_CPUARCH} == "mips"
CFLAGS_ARCH_PARAMS?=--param max-inline-insns-single=1000
.endif
.if ${COMPILER_TYPE} != "clang"
CFLAGS+= -fno-common -finline-limit=${INLINE_LIMIT}
CFLAGS+= --param inline-unit-growth=${CFLAGS_PARAM_INLINE_UNIT_GROWTH}
CFLAGS+= --param large-function-growth=${CFLAGS_PARAM_LARGE_FUNCTION_GROWTH}
CFLAGS.gcc+= -fno-common -finline-limit=${INLINE_LIMIT}
CFLAGS.gcc+= --param inline-unit-growth=${CFLAGS_PARAM_INLINE_UNIT_GROWTH}
CFLAGS.gcc+= --param large-function-growth=${CFLAGS_PARAM_LARGE_FUNCTION_GROWTH}
.if defined(CFLAGS_ARCH_PARAMS)
CFLAGS+=${CFLAGS_ARCH_PARAMS}
.endif
CFLAGS.gcc+=${CFLAGS_ARCH_PARAMS}
.endif
WERROR?= -Werror
@ -107,13 +105,11 @@ GCC_MS_EXTENSIONS= -fms-extensions
.if defined(PROFLEVEL) && ${PROFLEVEL} >= 1
CFLAGS+= -DGPROF
.if ${COMPILER_TYPE} != "clang"
CFLAGS+= -falign-functions=16
.endif
CFLAGS.gcc+= -falign-functions=16
.if ${PROFLEVEL} >= 2
CFLAGS+= -DGPROF4 -DGUPROF
PROF= -pg
.if ${COMPILER_TYPE} != "clang"
.if ${COMPILER_TYPE} == "gcc"
PROF+= -mprofiler-epilogue
.endif
.else

View File

@ -116,11 +116,9 @@ CFLAGS+= -I. -I@
# for example.
CFLAGS+= -I@/contrib/altq
.if ${COMPILER_TYPE} != "clang"
CFLAGS+= -finline-limit=${INLINE_LIMIT}
CFLAGS+= --param inline-unit-growth=100
CFLAGS+= --param large-function-growth=1000
.endif
CFLAGS.gcc+= -finline-limit=${INLINE_LIMIT}
CFLAGS.gcc+= --param inline-unit-growth=100
CFLAGS.gcc+= --param large-function-growth=1000
# Disallow common variables, and if we end up with commons from
# somewhere unexpected, allocate storage for them in the module itself.