xref: /freebsd/sys/conf/kern.mk (revision 59c7ad52aaa5b26e503871334672af0f58f9c2e8)
1# $FreeBSD$
2
3#
4# Warning flags for compiling the kernel and components of the kernel.
5#
6# Note that the newly added -Wcast-qual is responsible for generating
7# most of the remaining warnings.  Warnings introduced with -Wall will
8# also pop up, but are easier to fix.
9CWARNFLAGS?=	-Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes \
10		-Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual \
11		-Wundef -Wno-pointer-sign -fformat-extensions \
12		-Wmissing-include-dirs
13#
14# The following flags are next up for working on:
15#	-Wextra
16
17#
18# On i386, do not align the stack to 16-byte boundaries.  Otherwise GCC 2.95
19# and above adds code to the entry and exit point of every function to align the
20# stack to 16-byte boundaries -- thus wasting approximately 12 bytes of stack
21# per function call.  While the 16-byte alignment may benefit micro benchmarks,
22# it is probably an overall loss as it makes the code bigger (less efficient
23# use of code cache tag lines) and uses more stack (less efficient use of data
24# cache tag lines).  Explicitly prohibit the use of FPU, SSE and other SIMD
25# operations inside the kernel itself.  These operations are exclusively
26# reserved for user applications.
27#
28.if ${MACHINE_CPUARCH} == "i386"
29.if ${CC:T:Mclang} != "clang"
30CFLAGS+=	-mno-align-long-strings -mpreferred-stack-boundary=2
31.endif
32CFLAGS+=	-mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 -msoft-float
33INLINE_LIMIT?=	8000
34.endif
35
36.if ${MACHINE_CPUARCH} == "arm"
37INLINE_LIMIT?=	8000
38.endif
39
40#
41# For IA-64, we use r13 for the kernel globals pointer and we only use
42# a very small subset of float registers for integer divides.
43#
44.if ${MACHINE_CPUARCH} == "ia64"
45CFLAGS+=	-ffixed-r13 -mfixed-range=f32-f127 -fpic #-mno-sdata
46INLINE_LIMIT?=	15000
47.endif
48
49#
50# For sparc64 we want medlow code model, and we tell gcc to use floating
51# point emulation.  This avoids using floating point registers for integer
52# operations which it has a tendency to do.
53#
54.if ${MACHINE_CPUARCH} == "sparc64"
55CFLAGS+=	-mcmodel=medany -msoft-float
56INLINE_LIMIT?=	15000
57.endif
58
59#
60# For AMD64, we explicitly prohibit the use of FPU, SSE and other SIMD
61# operations inside the kernel itself.  These operations are exclusively
62# reserved for user applications.
63#
64.if ${MACHINE_CPUARCH} == "amd64"
65CFLAGS+=	-mcmodel=kernel -mno-red-zone \
66		-mfpmath=387 -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 \
67		-msoft-float -fno-asynchronous-unwind-tables
68INLINE_LIMIT?=	8000
69.endif
70
71#
72# For PowerPC we tell gcc to use floating point emulation.  This avoids using
73# floating point registers for integer operations which it has a tendency to do.
74# Also explicitly disable Altivec instructions inside the kernel.
75#
76.if ${MACHINE_CPUARCH} == "powerpc"
77CFLAGS+=	-msoft-float -mno-altivec
78INLINE_LIMIT?=	15000
79.endif
80
81#
82# Use dot symbols on powerpc64 to make ddb happy
83#
84.if ${MACHINE_ARCH} == "powerpc64"
85CFLAGS+=	-mcall-aixdesc
86.endif
87
88#
89# For MIPS we also tell gcc to use floating point emulation
90#
91.if ${MACHINE_CPUARCH} == "mips"
92CFLAGS+=	-msoft-float
93INLINE_LIMIT?=	8000
94.endif
95
96#
97# GCC 3.0 and above like to do certain optimizations based on the
98# assumption that the program is linked against libc.  Stop this.
99#
100CFLAGS+=	-ffreestanding
101
102#
103# GCC SSP support
104#
105.if ${MK_SSP} != "no" && ${MACHINE_CPUARCH} != "ia64" && \
106    ${MACHINE_CPUARCH} != "arm" && ${MACHINE_CPUARCH} != "mips"
107CFLAGS+=	-fstack-protector
108.endif
109
110#
111# Enable CTF conversation on request
112#
113.if defined(WITH_CTF)
114.undef NO_CTF
115.endif
116