xref: /f-stack/mk/kern.mk (revision a9643ea8)
1#
2# Derived from FreeBSD src/sys/conf/kern.mk
3#
4#
5# Warning flags for compiling the kernel and components of the kernel:
6#
7
8CWARNFLAGS?=	-Wall -Wnested-externs -Wstrict-prototypes \
9		-Wmissing-prototypes -Wpointer-arith -Wno-inline -Wcast-qual \
10		-Wno-pointer-sign -Wmissing-include-dirs -fdiagnostics-show-option \
11		${CWARNEXTRA}
12#
13# The following flags are next up for working on:
14#	-Wextra
15
16# Disable a few warnings for clang, since there are several places in the
17# kernel where fixing them is more trouble than it is worth, or where there is
18# a false positive.
19ifeq (${COMPILER_TYPE},clang)
20NO_WCONSTANT_CONVERSION=	-Wno-constant-conversion
21NO_WARRAY_BOUNDS=		-Wno-array-bounds
22NO_WSHIFT_COUNT_NEGATIVE=	-Wno-shift-count-negative
23NO_WSHIFT_COUNT_OVERFLOW=	-Wno-shift-count-overflow
24NO_WUNUSED_VALUE=		-Wno-unused-value
25NO_WSELF_ASSIGN=		-Wno-self-assign
26NO_WFORMAT_SECURITY=		-Wno-format-security
27NO_WUNNEEDED_INTERNAL_DECL=	-Wno-unneeded-internal-declaration
28NO_WSOMETIMES_UNINITIALIZED=	-Wno-error-sometimes-uninitialized
29# Several other warnings which might be useful in some cases, but not severe
30# enough to error out the whole kernel build.  Display them anyway, so there is
31# some incentive to fix them eventually.
32CWARNEXTRA?=	-Wno-error-tautological-compare -Wno-error-empty-body \
33		-Wno-error-parentheses-equality -Wno-incompatible-library-redeclaration \
34		-Wno-builtin-requires-header -Wno-error-shift-negative-value -Wno-unknown-warning-option
35endif
36
37ifeq (${COMPILER_TYPE},gcc)
38CWARNEXTRA?=	-Wno-unused-but-set-variable
39endif
40
41#
42# On i386, do not align the stack to 16-byte boundaries.  Otherwise GCC 2.95
43# and above adds code to the entry and exit point of every function to align the
44# stack to 16-byte boundaries -- thus wasting approximately 12 bytes of stack
45# per function call.  While the 16-byte alignment may benefit micro benchmarks,
46# it is probably an overall loss as it makes the code bigger (less efficient
47# use of code cache tag lines) and uses more stack (less efficient use of data
48# cache tag lines).
49#
50ifeq (${MACHINE_CPUARCH},i386)
51ifneq (${COMPILER_TYPE},clang)
52CFLAGS+=	-mno-align-long-strings -mpreferred-stack-boundary=2
53else
54CFLAGS+=
55endif
56CFLAGS+=
57INLINE_LIMIT?=	8000
58endif
59
60ifeq (${MACHINE_CPUARCH},arm)
61INLINE_LIMIT?=	8000
62endif
63
64#
65# For IA-64, we use r13 for the kernel globals pointer and we only use
66# a very small subset of float registers for integer divides.
67#
68ifeq (${MACHINE_CPUARCH},ia64)
69CFLAGS+=	-ffixed-r13 -mfixed-range=f32-f127 -fpic #-mno-sdata
70INLINE_LIMIT?=	15000
71endif
72
73#
74# For sparc64 we want the medany code model so modules may be located
75# anywhere in the 64-bit address space.
76#
77ifeq (${MACHINE_CPUARCH},sparc64)
78CFLAGS+=	-mcmodel=medany
79INLINE_LIMIT?=	15000
80endif
81
82ifeq (${MACHINE_CPUARCH},amd64)
83ifeq (${COMPILER_TYPE},clang)
84CFLAGS+=
85endif
86CFLAGS+=
87INLINE_LIMIT?=	8000
88endif
89
90ifeq (${MACHINE_CPUARCH},powerpc)
91CFLAGS+=
92INLINE_LIMIT?=	15000
93endif
94
95ifeq (${MACHINE_ARCH},powerpc64)
96CFLAGS+=
97endif
98
99ifeq (${MACHINE_CPUARCH},mips)
100CFLAGS+=
101INLINE_LIMIT?=	8000
102endif
103
104#
105# GCC SSP support
106#
107ifneq (${MK_SSP},no)
108ifneq (${MACHINE_CPUARCH},ia64)
109ifneq (${MACHINE_CPUARCH},arm)
110ifneq (${MACHINE_CPUARCH},mips)
111CFLAGS+=	-fstack-protector
112endif
113endif
114endif
115endif
116
117
118${IMACROS_FILE}: ${TOPDIR}/mk/kern.pre.mk
119	echo | ${CC} -E -dM - | grep -v -E '${IMACROS_FILTER_EXPR}' > ${IMACROS_FILE}
120