1# $FreeBSD$ 2 3# 4# Warning flags for compiling the kernel and components of the kernel: 5# 6CWARNFLAGS?= -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes \ 7 -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual \ 8 -Wundef -Wno-pointer-sign -fformat-extensions \ 9 -Wmissing-include-dirs -fdiagnostics-show-option \ 10 ${CWARNEXTRA} 11# 12# The following flags are next up for working on: 13# -Wextra 14 15# Disable a few warnings for clang, since there are several places in the 16# kernel where fixing them is more trouble than it is worth, or where there is 17# a false positive. 18.if ${CC:T:Mclang} == "clang" 19NO_WCONSTANT_CONVERSION= -Wno-constant-conversion 20NO_WARRAY_BOUNDS= -Wno-array-bounds 21NO_WSHIFT_COUNT_NEGATIVE= -Wno-shift-count-negative 22NO_WSHIFT_COUNT_OVERFLOW= -Wno-shift-count-overflow 23NO_WUNUSED_VALUE= -Wno-unused-value 24NO_WSELF_ASSIGN= -Wno-self-assign 25NO_WUNNEEDED_INTERNAL_DECL= -Wno-unneeded-internal-declaration 26NO_WFORMAT_SECURITY= -Wno-format-security 27# Several other warnings which might be useful in some cases, but not severe 28# enough to error out the whole kernel build. Display them anyway, so there is 29# some incentive to fix them eventually. 30CWARNEXTRA?= -Wno-error-tautological-compare -Wno-error-empty-body \ 31 -Wno-error-parentheses-equality 32.endif 33 34# 35# On i386, do not align the stack to 16-byte boundaries. Otherwise GCC 2.95 36# and above adds code to the entry and exit point of every function to align the 37# stack to 16-byte boundaries -- thus wasting approximately 12 bytes of stack 38# per function call. While the 16-byte alignment may benefit micro benchmarks, 39# it is probably an overall loss as it makes the code bigger (less efficient 40# use of code cache tag lines) and uses more stack (less efficient use of data 41# cache tag lines). Explicitly prohibit the use of FPU, SSE and other SIMD 42# operations inside the kernel itself. These operations are exclusively 43# reserved for user applications. 44# 45# gcc: 46# Setting -mno-mmx implies -mno-3dnow 47# Setting -mno-sse implies -mno-sse2, -mno-sse3 and -mno-ssse3 48# 49# clang: 50# Setting -mno-mmx implies -mno-3dnow, -mno-3dnowa, -mno-sse, -mno-sse2, 51# -mno-sse3, -mno-ssse3, -mno-sse41 and -mno-sse42 52# 53.if ${MACHINE_CPUARCH} == "i386" 54.if ${CC:T:Mclang} != "clang" 55CFLAGS+= -mno-align-long-strings -mpreferred-stack-boundary=2 -mno-sse 56.else 57CFLAGS+= -mno-aes -mno-avx 58.endif 59CFLAGS+= -mno-mmx -msoft-float 60INLINE_LIMIT?= 8000 61.endif 62 63.if ${MACHINE_CPUARCH} == "arm" 64INLINE_LIMIT?= 8000 65.endif 66 67# 68# For IA-64, we use r13 for the kernel globals pointer and we only use 69# a very small subset of float registers for integer divides. 70# 71.if ${MACHINE_CPUARCH} == "ia64" 72CFLAGS+= -ffixed-r13 -mfixed-range=f32-f127 -fpic #-mno-sdata 73INLINE_LIMIT?= 15000 74.endif 75 76# 77# For sparc64 we want the medany code model so modules may be located 78# anywhere in the 64-bit address space. We also tell GCC to use floating 79# point emulation. This avoids using floating point registers for integer 80# operations which it has a tendency to do. 81# 82.if ${MACHINE_CPUARCH} == "sparc64" 83CFLAGS+= -mcmodel=medany -msoft-float 84INLINE_LIMIT?= 15000 85.endif 86 87# 88# For AMD64, we explicitly prohibit the use of FPU, SSE and other SIMD 89# operations inside the kernel itself. These operations are exclusively 90# reserved for user applications. 91# 92# gcc: 93# Setting -mno-mmx implies -mno-3dnow 94# Setting -mno-sse implies -mno-sse2, -mno-sse3, -mno-ssse3 and -mfpmath=387 95# 96# clang: 97# Setting -mno-mmx implies -mno-3dnow, -mno-3dnowa, -mno-sse, -mno-sse2, 98# -mno-sse3, -mno-ssse3, -mno-sse41 and -mno-sse42 99# (-mfpmath= is not supported) 100# 101.if ${MACHINE_CPUARCH} == "amd64" 102.if ${CC:T:Mclang} != "clang" 103CFLAGS+= -mno-sse 104.else 105CFLAGS+= -mno-aes -mno-avx 106.endif 107CFLAGS+= -mcmodel=kernel -mno-red-zone -mno-mmx -msoft-float \ 108 -fno-asynchronous-unwind-tables 109INLINE_LIMIT?= 8000 110.endif 111 112# 113# For PowerPC we tell gcc to use floating point emulation. This avoids using 114# floating point registers for integer operations which it has a tendency to do. 115# Also explicitly disable Altivec instructions inside the kernel. 116# 117.if ${MACHINE_CPUARCH} == "powerpc" 118CFLAGS+= -msoft-float -mno-altivec 119INLINE_LIMIT?= 15000 120.endif 121 122# 123# Use dot symbols on powerpc64 to make ddb happy 124# 125.if ${MACHINE_ARCH} == "powerpc64" 126CFLAGS+= -mcall-aixdesc 127.endif 128 129# 130# For MIPS we also tell gcc to use floating point emulation 131# 132.if ${MACHINE_CPUARCH} == "mips" 133CFLAGS+= -msoft-float 134INLINE_LIMIT?= 8000 135.endif 136 137# 138# GCC 3.0 and above like to do certain optimizations based on the 139# assumption that the program is linked against libc. Stop this. 140# 141CFLAGS+= -ffreestanding 142 143# 144# GCC SSP support 145# 146.if ${MK_SSP} != "no" && ${MACHINE_CPUARCH} != "ia64" && \ 147 ${MACHINE_CPUARCH} != "arm" && ${MACHINE_CPUARCH} != "mips" 148CFLAGS+= -fstack-protector 149.endif 150