]> CyberLeo.Net >> Repos - FreeBSD/stable/9.git/blob - sys/conf/kern.mk
MFC r284308: MFV r284042: 1778 Assertion failed: rn->rn_nozpool == B_FALSE
[FreeBSD/stable/9.git] / sys / conf / kern.mk
1 # $FreeBSD$
2
3 #
4 # Warning flags for compiling the kernel and components of the kernel:
5 #
6 CWARNFLAGS?=    -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes \
7                 -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual \
8                 -Wundef -Wno-pointer-sign \
9                 -Wmissing-include-dirs -fdiagnostics-show-option \
10                 ${CWARNEXTRA}
11 MK_CLANG_IS_CC ?= no
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.
19 .if ${COMPILER_TYPE} == "clang"
20 NO_WCONSTANT_CONVERSION=        -Wno-constant-conversion
21 NO_WARRAY_BOUNDS=               -Wno-array-bounds
22 NO_WSHIFT_COUNT_NEGATIVE=       -Wno-shift-count-negative
23 NO_WSHIFT_COUNT_OVERFLOW=       -Wno-shift-count-overflow
24 NO_WUNUSED_VALUE=               -Wno-unused-value
25 NO_WSELF_ASSIGN=                -Wno-self-assign
26 NO_WFORMAT_SECURITY=            -Wno-format-security
27 NO_WUNNEEDED_INTERNAL_DECL=     -Wno-unneeded-internal-declaration
28 NO_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.
32 CWARNEXTRA?=    -Wno-error-tautological-compare -Wno-error-empty-body \
33                 -Wno-error-parentheses-equality -Wno-error-unused-function
34 .endif
35
36 #
37 # On i386, do not align the stack to 16-byte boundaries.  Otherwise GCC 2.95
38 # and above adds code to the entry and exit point of every function to align the
39 # stack to 16-byte boundaries -- thus wasting approximately 12 bytes of stack
40 # per function call.  While the 16-byte alignment may benefit micro benchmarks,
41 # it is probably an overall loss as it makes the code bigger (less efficient
42 # use of code cache tag lines) and uses more stack (less efficient use of data
43 # cache tag lines).  Explicitly prohibit the use of FPU, SSE and other SIMD
44 # operations inside the kernel itself.  These operations are exclusively
45 # reserved for user applications.
46 #
47 # gcc:
48 # Setting -mno-mmx implies -mno-3dnow
49 # Setting -mno-sse implies -mno-sse2, -mno-sse3 and -mno-ssse3
50 #
51 # clang:
52 # Setting -mno-mmx implies -mno-3dnow and -mno-3dnowa
53 # Setting -mno-sse implies -mno-sse2, -mno-sse3, -mno-ssse3, -mno-sse41 and -mno-sse42
54 #
55 .if ${MACHINE_CPUARCH} == "i386"
56 .if ${COMPILER_TYPE} != "clang"
57 CFLAGS+=        -mno-align-long-strings -mpreferred-stack-boundary=2
58 .else
59 CFLAGS+=        -mno-aes -mno-avx
60 .endif
61 CFLAGS+=        -mno-mmx -mno-sse -msoft-float
62 INLINE_LIMIT?=  8000
63 .endif
64
65 .if ${MACHINE_CPUARCH} == "arm"
66 INLINE_LIMIT?=  8000
67 .endif
68
69 #
70 # For IA-64, we use r13 for the kernel globals pointer and we only use
71 # a very small subset of float registers for integer divides.
72 #
73 .if ${MACHINE_CPUARCH} == "ia64"
74 CFLAGS+=        -ffixed-r13 -mfixed-range=f32-f127 -fpic #-mno-sdata
75 INLINE_LIMIT?=  15000
76 .endif
77
78 #
79 # For sparc64 we want the medany code model so modules may be located
80 # anywhere in the 64-bit address space.  We also tell GCC to use floating
81 # point emulation.  This avoids using floating point registers for integer
82 # operations which it has a tendency to do.
83 #
84 .if ${MACHINE_CPUARCH} == "sparc64"
85 .if ${COMPILER_TYPE} == "clang"
86 CFLAGS+=        -mcmodel=large -fno-dwarf2-cfi-asm
87 .else
88 CFLAGS+=        -mcmodel=medany -msoft-float
89 .endif
90 INLINE_LIMIT?=  15000
91 .endif
92
93 #
94 # For AMD64, we explicitly prohibit the use of FPU, SSE and other SIMD
95 # operations inside the kernel itself.  These operations are exclusively
96 # reserved for user applications.
97 #
98 # gcc:
99 # Setting -mno-mmx implies -mno-3dnow
100 # Setting -mno-sse implies -mno-sse2, -mno-sse3, -mno-ssse3 and -mfpmath=387
101 #
102 # clang:
103 # Setting -mno-mmx implies -mno-3dnow and -mno-3dnowa
104 # Setting -mno-sse implies -mno-sse2, -mno-sse3, -mno-ssse3, -mno-sse41 and -mno-sse42
105 # (-mfpmath= is not supported)
106 #
107 .if ${MACHINE_CPUARCH} == "amd64"
108 .if ${COMPILER_TYPE} == "clang"
109 CFLAGS+=        -mno-aes -mno-avx
110 .endif
111 CFLAGS+=        -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float \
112                 -fno-asynchronous-unwind-tables
113 INLINE_LIMIT?=  8000
114 .endif
115
116 #
117 # For PowerPC we tell gcc to use floating point emulation.  This avoids using
118 # floating point registers for integer operations which it has a tendency to do.
119 # Also explicitly disable Altivec instructions inside the kernel.
120 #
121 .if ${MACHINE_CPUARCH} == "powerpc"
122 CFLAGS+=        -msoft-float -mno-altivec
123 INLINE_LIMIT?=  15000
124 .endif
125
126 #
127 # Use dot symbols on powerpc64 to make ddb happy
128 #
129 .if ${MACHINE_ARCH} == "powerpc64"
130 CFLAGS+=        -mcall-aixdesc
131 .endif
132
133 #
134 # For MIPS we also tell gcc to use floating point emulation
135 #
136 .if ${MACHINE_CPUARCH} == "mips"
137 CFLAGS+=        -msoft-float
138 INLINE_LIMIT?=  8000
139 .endif
140
141 #
142 # GCC 3.0 and above like to do certain optimizations based on the
143 # assumption that the program is linked against libc.  Stop this.
144 #
145 CFLAGS+=        -ffreestanding
146
147 #
148 # GCC SSP support
149 #
150 .if ${MK_SSP} != "no" && ${MACHINE_CPUARCH} != "ia64" && \
151     ${MACHINE_CPUARCH} != "arm" && ${MACHINE_CPUARCH} != "mips"
152 CFLAGS+=        -fstack-protector
153 .endif
154
155 #
156 # Add -gdwarf-2 when compiling -g
157 #
158 .if ${COMPILER_TYPE} == "clang" && ${CFLAGS:M-g} != "" && ${CFLAGS:M-gdwarf} == ""
159 CFLAGS+=        -gdwarf-2
160 .endif