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