4 # Warning flags for compiling the kernel and components of the kernel:
6 CWARNFLAGS?= -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
11 # The following flags are next up for working on:
14 # Disable a few warnings for clang, since there are several places in the
15 # kernel where fixing them is more trouble than it is worth, or where there is
17 .if ${CC:T:Mclang} == "clang"
18 NO_WCONSTANT_CONVERSION= -Wno-constant-conversion
19 NO_WARRAY_BOUNDS= -Wno-array-bounds
23 # On i386, do not align the stack to 16-byte boundaries. Otherwise GCC 2.95
24 # and above adds code to the entry and exit point of every function to align the
25 # stack to 16-byte boundaries -- thus wasting approximately 12 bytes of stack
26 # per function call. While the 16-byte alignment may benefit micro benchmarks,
27 # it is probably an overall loss as it makes the code bigger (less efficient
28 # use of code cache tag lines) and uses more stack (less efficient use of data
29 # cache tag lines). Explicitly prohibit the use of FPU, SSE and other SIMD
30 # operations inside the kernel itself. These operations are exclusively
31 # reserved for user applications.
34 # Setting -mno-mmx implies -mno-3dnow
35 # Setting -mno-sse implies -mno-sse2, -mno-sse3 and -mno-ssse3
38 # Setting -mno-mmx implies -mno-3dnow, -mno-3dnowa, -mno-sse, -mno-sse2,
39 # -mno-sse3, -mno-ssse3, -mno-sse41 and -mno-sse42
41 .if ${MACHINE_CPUARCH} == "i386"
42 .if ${CC:T:Mclang} != "clang"
43 CFLAGS+= -mno-align-long-strings -mpreferred-stack-boundary=2 -mno-sse
45 CFLAGS+= -mno-aes -mno-avx
47 CFLAGS+= -mno-mmx -msoft-float
51 .if ${MACHINE_CPUARCH} == "arm"
56 # For IA-64, we use r13 for the kernel globals pointer and we only use
57 # a very small subset of float registers for integer divides.
59 .if ${MACHINE_CPUARCH} == "ia64"
60 CFLAGS+= -ffixed-r13 -mfixed-range=f32-f127 -fpic #-mno-sdata
65 # For sparc64 we want medlow code model, and we tell gcc to use floating
66 # point emulation. This avoids using floating point registers for integer
67 # operations which it has a tendency to do.
69 .if ${MACHINE_CPUARCH} == "sparc64"
70 CFLAGS+= -mcmodel=medany -msoft-float
75 # For AMD64, we explicitly prohibit the use of FPU, SSE and other SIMD
76 # operations inside the kernel itself. These operations are exclusively
77 # reserved for user applications.
80 # Setting -mno-mmx implies -mno-3dnow
81 # Setting -mno-sse implies -mno-sse2, -mno-sse3, -mno-ssse3 and -mfpmath=387
84 # Setting -mno-mmx implies -mno-3dnow, -mno-3dnowa, -mno-sse, -mno-sse2,
85 # -mno-sse3, -mno-ssse3, -mno-sse41 and -mno-sse42
86 # (-mfpmath= is not supported)
88 .if ${MACHINE_CPUARCH} == "amd64"
89 .if ${CC:T:Mclang} != "clang"
92 CFLAGS+= -mno-aes -mno-avx
94 CFLAGS+= -mcmodel=kernel -mno-red-zone -mno-mmx -msoft-float \
95 -fno-asynchronous-unwind-tables
100 # For PowerPC we tell gcc to use floating point emulation. This avoids using
101 # floating point registers for integer operations which it has a tendency to do.
102 # Also explicitly disable Altivec instructions inside the kernel.
104 .if ${MACHINE_CPUARCH} == "powerpc"
105 CFLAGS+= -msoft-float -mno-altivec
110 # Use dot symbols on powerpc64 to make ddb happy
112 .if ${MACHINE_ARCH} == "powerpc64"
113 CFLAGS+= -mcall-aixdesc
117 # For MIPS we also tell gcc to use floating point emulation
119 .if ${MACHINE_CPUARCH} == "mips"
120 CFLAGS+= -msoft-float
125 # GCC 3.0 and above like to do certain optimizations based on the
126 # assumption that the program is linked against libc. Stop this.
128 CFLAGS+= -ffreestanding
133 .if ${MK_SSP} != "no" && ${MACHINE_CPUARCH} != "ia64" && \
134 ${MACHINE_CPUARCH} != "arm" && ${MACHINE_CPUARCH} != "mips"
135 CFLAGS+= -fstack-protector
139 # Enable CTF conversation on request
141 .if defined(WITH_CTF)