1a9643ea8Slogwang# 2a9643ea8Slogwang# Derived from FreeBSD src/sys/conf/kern.mk 3a9643ea8Slogwang# 4a9643ea8Slogwang# 5a9643ea8Slogwang# Warning flags for compiling the kernel and components of the kernel: 6a9643ea8Slogwang# 7a9643ea8Slogwang 8a9643ea8SlogwangCWARNFLAGS?= -Wall -Wnested-externs -Wstrict-prototypes \ 9a9643ea8Slogwang -Wmissing-prototypes -Wpointer-arith -Wno-inline -Wcast-qual \ 10a9643ea8Slogwang -Wno-pointer-sign -Wmissing-include-dirs -fdiagnostics-show-option \ 11a9643ea8Slogwang ${CWARNEXTRA} 12a9643ea8Slogwang# 13a9643ea8Slogwang# The following flags are next up for working on: 14a9643ea8Slogwang# -Wextra 15a9643ea8Slogwang 16a9643ea8Slogwang# Disable a few warnings for clang, since there are several places in the 17a9643ea8Slogwang# kernel where fixing them is more trouble than it is worth, or where there is 18a9643ea8Slogwang# a false positive. 19a9643ea8Slogwangifeq (${COMPILER_TYPE},clang) 20a9643ea8SlogwangNO_WCONSTANT_CONVERSION= -Wno-constant-conversion 21a9643ea8SlogwangNO_WARRAY_BOUNDS= -Wno-array-bounds 22a9643ea8SlogwangNO_WSHIFT_COUNT_NEGATIVE= -Wno-shift-count-negative 23a9643ea8SlogwangNO_WSHIFT_COUNT_OVERFLOW= -Wno-shift-count-overflow 24a9643ea8SlogwangNO_WUNUSED_VALUE= -Wno-unused-value 25a9643ea8SlogwangNO_WSELF_ASSIGN= -Wno-self-assign 26a9643ea8SlogwangNO_WFORMAT_SECURITY= -Wno-format-security 27a9643ea8SlogwangNO_WUNNEEDED_INTERNAL_DECL= -Wno-unneeded-internal-declaration 28a9643ea8SlogwangNO_WSOMETIMES_UNINITIALIZED= -Wno-error-sometimes-uninitialized 29a9643ea8Slogwang# Several other warnings which might be useful in some cases, but not severe 30a9643ea8Slogwang# enough to error out the whole kernel build. Display them anyway, so there is 31a9643ea8Slogwang# some incentive to fix them eventually. 32a9643ea8SlogwangCWARNEXTRA?= -Wno-error-tautological-compare -Wno-error-empty-body \ 33a9643ea8Slogwang -Wno-error-parentheses-equality -Wno-incompatible-library-redeclaration \ 34a9643ea8Slogwang -Wno-builtin-requires-header -Wno-error-shift-negative-value -Wno-unknown-warning-option 35a9643ea8Slogwangendif 36a9643ea8Slogwang 37a9643ea8Slogwangifeq (${COMPILER_TYPE},gcc) 38*a1d3d0a7SPhilip HerronCWARNEXTRA?= -Wno-unused-but-set-variable -Wno-address-of-packed-member 39a9643ea8Slogwangendif 40a9643ea8Slogwang 41a9643ea8Slogwang# 42a9643ea8Slogwang# On i386, do not align the stack to 16-byte boundaries. Otherwise GCC 2.95 43a9643ea8Slogwang# and above adds code to the entry and exit point of every function to align the 44a9643ea8Slogwang# stack to 16-byte boundaries -- thus wasting approximately 12 bytes of stack 45a9643ea8Slogwang# per function call. While the 16-byte alignment may benefit micro benchmarks, 46a9643ea8Slogwang# it is probably an overall loss as it makes the code bigger (less efficient 47a9643ea8Slogwang# use of code cache tag lines) and uses more stack (less efficient use of data 48a9643ea8Slogwang# cache tag lines). 49a9643ea8Slogwang# 50a9643ea8Slogwangifeq (${MACHINE_CPUARCH},i386) 51a9643ea8Slogwangifneq (${COMPILER_TYPE},clang) 52a9643ea8SlogwangCFLAGS+= -mno-align-long-strings -mpreferred-stack-boundary=2 53a9643ea8Slogwangelse 54a9643ea8SlogwangCFLAGS+= 55a9643ea8Slogwangendif 56a9643ea8SlogwangCFLAGS+= 57a9643ea8SlogwangINLINE_LIMIT?= 8000 58a9643ea8Slogwangendif 59a9643ea8Slogwang 60a9643ea8Slogwangifeq (${MACHINE_CPUARCH},arm) 61a9643ea8SlogwangINLINE_LIMIT?= 8000 62a9643ea8Slogwangendif 63a9643ea8Slogwang 64a9643ea8Slogwang# 65a9643ea8Slogwang# For IA-64, we use r13 for the kernel globals pointer and we only use 66a9643ea8Slogwang# a very small subset of float registers for integer divides. 67a9643ea8Slogwang# 68a9643ea8Slogwangifeq (${MACHINE_CPUARCH},ia64) 69a9643ea8SlogwangCFLAGS+= -ffixed-r13 -mfixed-range=f32-f127 -fpic #-mno-sdata 70a9643ea8SlogwangINLINE_LIMIT?= 15000 71a9643ea8Slogwangendif 72a9643ea8Slogwang 73a9643ea8Slogwang# 74a9643ea8Slogwang# For sparc64 we want the medany code model so modules may be located 75a9643ea8Slogwang# anywhere in the 64-bit address space. 76a9643ea8Slogwang# 77a9643ea8Slogwangifeq (${MACHINE_CPUARCH},sparc64) 78a9643ea8SlogwangCFLAGS+= -mcmodel=medany 79a9643ea8SlogwangINLINE_LIMIT?= 15000 80a9643ea8Slogwangendif 81a9643ea8Slogwang 82a9643ea8Slogwangifeq (${MACHINE_CPUARCH},amd64) 83a9643ea8Slogwangifeq (${COMPILER_TYPE},clang) 84a9643ea8SlogwangCFLAGS+= 85a9643ea8Slogwangendif 86a9643ea8SlogwangCFLAGS+= 87a9643ea8SlogwangINLINE_LIMIT?= 8000 88a9643ea8Slogwangendif 89a9643ea8Slogwang 90a9643ea8Slogwangifeq (${MACHINE_CPUARCH},powerpc) 91a9643ea8SlogwangCFLAGS+= 92a9643ea8SlogwangINLINE_LIMIT?= 15000 93a9643ea8Slogwangendif 94a9643ea8Slogwang 95a9643ea8Slogwangifeq (${MACHINE_ARCH},powerpc64) 96a9643ea8SlogwangCFLAGS+= 97a9643ea8Slogwangendif 98a9643ea8Slogwang 99a9643ea8Slogwangifeq (${MACHINE_CPUARCH},mips) 100a9643ea8SlogwangCFLAGS+= 101a9643ea8SlogwangINLINE_LIMIT?= 8000 102a9643ea8Slogwangendif 103a9643ea8Slogwang 1049bd490e8Sdongbo4ifeq (${MACHINE_CPUARCH},arm64) 1059bd490e8Sdongbo4INLINE_LIMIT?= 15000 1069bd490e8Sdongbo4endif 1079bd490e8Sdongbo4 108a9643ea8Slogwang# 109a9643ea8Slogwang# GCC SSP support 110a9643ea8Slogwang# 111a9643ea8Slogwangifneq (${MK_SSP},no) 112a9643ea8Slogwangifneq (${MACHINE_CPUARCH},ia64) 113a9643ea8Slogwangifneq (${MACHINE_CPUARCH},arm) 114a9643ea8Slogwangifneq (${MACHINE_CPUARCH},mips) 115a9643ea8SlogwangCFLAGS+= -fstack-protector 116a9643ea8Slogwangendif 117a9643ea8Slogwangendif 118a9643ea8Slogwangendif 119a9643ea8Slogwangendif 120a9643ea8Slogwang 121a9643ea8Slogwang 122a9643ea8Slogwang${IMACROS_FILE}: ${TOPDIR}/mk/kern.pre.mk 123a9643ea8Slogwang echo | ${CC} -E -dM - | grep -v -E '${IMACROS_FILTER_EXPR}' > ${IMACROS_FILE} 124