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