xref: /freebsd/sys/conf/kern.mk (revision 6fd05b64b5b65dd4ba9b86482a0634a5f0b96c29)
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		-fformat-extensions -std=c99
16.endif
17#
18# The following flags are next up for working on:
19#	-W
20
21#
22# On the i386, do not align the stack to 16-byte boundaries.  Otherwise GCC
23# 2.95 adds code to the entry and exit point of every function to align the
24# stack to 16-byte boundaries -- thus wasting approximately 12 bytes of stack
25# per function call.  While the 16-byte alignment may benefit micro benchmarks,
26# it is probably an overall loss as it makes the code bigger (less efficient
27# use of code cache tag lines) and uses more stack (less efficient use of data
28# cache tag lines)
29#
30.if ${MACHINE_ARCH} == "i386" && ${CC} != "icc"
31CFLAGS+=	-mno-align-long-strings -mpreferred-stack-boundary=2
32INLINE_LIMIT?=	8000
33.endif
34
35#
36# On the alpha, make sure that we don't use floating-point registers and
37# allow the use of BWX etc instructions (only needed for low-level i/o).
38# Also, reserve register t7 to point at per-cpu global variables.
39#
40.if ${MACHINE_ARCH} == "alpha"
41CFLAGS+=	-mno-fp-regs -ffixed-8 -Wa,-mev6
42INLINE_LIMIT?=	15000
43.endif
44
45.if ${MACHINE_ARCH} == "arm"
46INLINE_LIMIT?=	8000
47.endif
48#
49# For IA-64, we use r13 for the kernel globals pointer and we only use
50# a very small subset of float registers for integer divides.
51#
52.if ${MACHINE_ARCH} == "ia64"
53CFLAGS+=	-ffixed-r13 -mfixed-range=f32-f127 -mno-sdata
54INLINE_LIMIT?=	15000
55.endif
56
57#
58# For sparc64 we want medlow code model, and we tell gcc to use floating
59# point emulation.  This avoids using floating point registers for integer
60# operations which it has a tendency to do.
61#
62.if ${MACHINE_ARCH} == "sparc64"
63CFLAGS+=	-mcmodel=medlow -msoft-float
64INLINE_LIMIT?=	15000
65.endif
66
67#
68# For AMD64, use a medium model for now.  We'll switch to "kernel"
69# once pmap is ready.  Be excessively careful to not generate FPU code.
70#
71.if ${MACHINE_ARCH} == "amd64"
72CFLAGS+=	-mcmodel=kernel -mno-red-zone \
73		-mfpmath=387 -mno-sse -mno-sse2 -mno-mmx -mno-3dnow \
74		-msoft-float -fno-asynchronous-unwind-tables
75INLINE_LIMIT?=	8000
76.endif
77
78#
79# For PowerPC we tell gcc to use floating point emulation.  This avoids using
80# floating point registers for integer operations which it has a tendency to do.
81#
82.if ${MACHINE_ARCH} == "powerpc"
83CFLAGS+=	-msoft-float
84INLINE_LIMIT?=	15000
85.endif
86
87#
88# GCC 3.0 and above like to do certain optimizations based on the
89# assumption that the program is linked against libc.  Stop this.
90#
91.if ${CC} == "icc"
92CFLAGS+=	-nolib_inline
93.else
94CFLAGS+=	-ffreestanding
95.endif
96
97.if ${CC} == "icc"
98CFLAGS+=	-restrict
99.endif
100