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