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 25# Several other warnings which might be useful in some cases, but not severe 26# enough to error out the whole kernel build. Display them anyway, so there is 27# some incentive to fix them eventually. 28CWARNEXTRA?= -Wno-error-tautological-compare -Wno-error-empty-body \ 29 -Wno-error-parentheses-equality 30.endif 31 32# 33# On i386, do not align the stack to 16-byte boundaries. Otherwise GCC 2.95 34# and above adds code to the entry and exit point of every function to align the 35# stack to 16-byte boundaries -- thus wasting approximately 12 bytes of stack 36# per function call. While the 16-byte alignment may benefit micro benchmarks, 37# it is probably an overall loss as it makes the code bigger (less efficient 38# use of code cache tag lines) and uses more stack (less efficient use of data 39# cache tag lines). Explicitly prohibit the use of FPU, SSE and other SIMD 40# operations inside the kernel itself. These operations are exclusively 41# reserved for user applications. 42# 43# gcc: 44# Setting -mno-mmx implies -mno-3dnow 45# Setting -mno-sse implies -mno-sse2, -mno-sse3 and -mno-ssse3 46# 47# clang: 48# Setting -mno-mmx implies -mno-3dnow, -mno-3dnowa, -mno-sse, -mno-sse2, 49# -mno-sse3, -mno-ssse3, -mno-sse41 and -mno-sse42 50# 51.if ${MACHINE_CPUARCH} == "i386" 52.if ${CC:T:Mclang} != "clang" 53CFLAGS+= -mno-align-long-strings -mpreferred-stack-boundary=2 -mno-sse 54.else 55CFLAGS+= -mno-aes -mno-avx 56.endif 57CFLAGS+= -mno-mmx -msoft-float 58INLINE_LIMIT?= 8000 59.endif 60 61.if ${MACHINE_CPUARCH} == "arm" 62INLINE_LIMIT?= 8000 63.endif 64 65# 66# For IA-64, we use r13 for the kernel globals pointer and we only use 67# a very small subset of float registers for integer divides. 68# 69.if ${MACHINE_CPUARCH} == "ia64" 70CFLAGS+= -ffixed-r13 -mfixed-range=f32-f127 -fpic #-mno-sdata 71INLINE_LIMIT?= 15000 72.endif 73 74# 75# For sparc64 we want the medany code model so modules may be located 76# anywhere in the 64-bit address space. We also tell GCC to use floating 77# point emulation. This avoids using floating point registers for integer 78# operations which it has a tendency to do. 79# 80.if ${MACHINE_CPUARCH} == "sparc64" 81CFLAGS+= -mcmodel=medany -msoft-float 82INLINE_LIMIT?= 15000 83.endif 84 85# 86# For AMD64, we explicitly prohibit the use of FPU, SSE and other SIMD 87# operations inside the kernel itself. These operations are exclusively 88# reserved for user applications. 89# 90# gcc: 91# Setting -mno-mmx implies -mno-3dnow 92# Setting -mno-sse implies -mno-sse2, -mno-sse3, -mno-ssse3 and -mfpmath=387 93# 94# clang: 95# Setting -mno-mmx implies -mno-3dnow, -mno-3dnowa, -mno-sse, -mno-sse2, 96# -mno-sse3, -mno-ssse3, -mno-sse41 and -mno-sse42 97# (-mfpmath= is not supported) 98# 99.if ${MACHINE_CPUARCH} == "amd64" 100.if ${CC:T:Mclang} != "clang" 101CFLAGS+= -mno-sse 102.else 103CFLAGS+= -mno-aes -mno-avx 104.endif 105CFLAGS+= -mcmodel=kernel -mno-red-zone -mno-mmx -msoft-float \ 106 -fno-asynchronous-unwind-tables 107INLINE_LIMIT?= 8000 108.endif 109 110# 111# For PowerPC we tell gcc to use floating point emulation. This avoids using 112# floating point registers for integer operations which it has a tendency to do. 113# Also explicitly disable Altivec instructions inside the kernel. 114# 115.if ${MACHINE_CPUARCH} == "powerpc" 116CFLAGS+= -msoft-float -mno-altivec 117INLINE_LIMIT?= 15000 118.endif 119 120# 121# Use dot symbols on powerpc64 to make ddb happy 122# 123.if ${MACHINE_ARCH} == "powerpc64" 124CFLAGS+= -mcall-aixdesc 125.endif 126 127# 128# For MIPS we also tell gcc to use floating point emulation 129# 130.if ${MACHINE_CPUARCH} == "mips" 131CFLAGS+= -msoft-float 132INLINE_LIMIT?= 8000 133.endif 134 135# 136# GCC 3.0 and above like to do certain optimizations based on the 137# assumption that the program is linked against libc. Stop this. 138# 139CFLAGS+= -ffreestanding 140 141# 142# GCC SSP support 143# 144.if ${MK_SSP} != "no" && ${MACHINE_CPUARCH} != "ia64" && \ 145 ${MACHINE_CPUARCH} != "arm" && ${MACHINE_CPUARCH} != "mips" 146CFLAGS+= -fstack-protector 147.endif 148