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