]> CyberLeo.Net >> Repos - FreeBSD/stable/9.git/blob - sys/conf/kern.mk
MFC r319414:
[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 ${FORMAT_EXTENSIONS} \
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                 ${NO_WFORMAT}
35 .endif
36
37 # External compilers may not support our format extensions.  Allow them
38 # to be disabled.  WARNING: format checking is disabled in this case.
39 .if ${MK_FORMAT_EXTENSIONS} == "no"
40 NO_WFORMAT=             -Wno-format
41 .else
42 FORMAT_EXTENSIONS=      -fformat-extensions
43 .endif
44
45 #
46 # On i386, do not align the stack to 16-byte boundaries.  Otherwise GCC 2.95
47 # and above adds code to the entry and exit point of every function to align the
48 # stack to 16-byte boundaries -- thus wasting approximately 12 bytes of stack
49 # per function call.  While the 16-byte alignment may benefit micro benchmarks,
50 # it is probably an overall loss as it makes the code bigger (less efficient
51 # use of code cache tag lines) and uses more stack (less efficient use of data
52 # cache tag lines).  Explicitly prohibit the use of FPU, SSE and other SIMD
53 # operations inside the kernel itself.  These operations are exclusively
54 # reserved for user applications.
55 #
56 # gcc:
57 # Setting -mno-mmx implies -mno-3dnow
58 # Setting -mno-sse implies -mno-sse2, -mno-sse3 and -mno-ssse3
59 #
60 # clang:
61 # Setting -mno-mmx implies -mno-3dnow and -mno-3dnowa
62 # Setting -mno-sse implies -mno-sse2, -mno-sse3, -mno-ssse3, -mno-sse41 and -mno-sse42
63 #
64 .if ${MACHINE_CPUARCH} == "i386"
65 .if ${COMPILER_TYPE} != "clang"
66 CFLAGS+=        -mno-align-long-strings -mpreferred-stack-boundary=2
67 .else
68 CFLAGS+=        -mno-aes -mno-avx
69 .endif
70 CFLAGS+=        -mno-mmx -mno-sse -msoft-float
71 INLINE_LIMIT?=  8000
72 .endif
73
74 .if ${MACHINE_CPUARCH} == "arm"
75 INLINE_LIMIT?=  8000
76 .endif
77
78 #
79 # For IA-64, we use r13 for the kernel globals pointer and we only use
80 # a very small subset of float registers for integer divides.
81 #
82 .if ${MACHINE_CPUARCH} == "ia64"
83 CFLAGS+=        -ffixed-r13 -mfixed-range=f32-f127 -fpic #-mno-sdata
84 INLINE_LIMIT?=  15000
85 .endif
86
87 #
88 # For sparc64 we want the medany code model so modules may be located
89 # anywhere in the 64-bit address space.  We also tell GCC to use floating
90 # point emulation.  This avoids using floating point registers for integer
91 # operations which it has a tendency to do.
92 #
93 .if ${MACHINE_CPUARCH} == "sparc64"
94 .if ${COMPILER_TYPE} == "clang"
95 CFLAGS+=        -mcmodel=large -fno-dwarf2-cfi-asm
96 .else
97 CFLAGS+=        -mcmodel=medany -msoft-float
98 .endif
99 INLINE_LIMIT?=  15000
100 .endif
101
102 #
103 # For AMD64, we explicitly prohibit the use of FPU, SSE and other SIMD
104 # operations inside the kernel itself.  These operations are exclusively
105 # reserved for user applications.
106 #
107 # gcc:
108 # Setting -mno-mmx implies -mno-3dnow
109 # Setting -mno-sse implies -mno-sse2, -mno-sse3, -mno-ssse3 and -mfpmath=387
110 #
111 # clang:
112 # Setting -mno-mmx implies -mno-3dnow and -mno-3dnowa
113 # Setting -mno-sse implies -mno-sse2, -mno-sse3, -mno-ssse3, -mno-sse41 and -mno-sse42
114 # (-mfpmath= is not supported)
115 #
116 .if ${MACHINE_CPUARCH} == "amd64"
117 .if ${COMPILER_TYPE} == "clang"
118 CFLAGS+=        -mno-aes -mno-avx
119 .endif
120 CFLAGS+=        -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float \
121                 -fno-asynchronous-unwind-tables
122 INLINE_LIMIT?=  8000
123 .endif
124
125 #
126 # For PowerPC we tell gcc to use floating point emulation.  This avoids using
127 # floating point registers for integer operations which it has a tendency to do.
128 # Also explicitly disable Altivec instructions inside the kernel.
129 #
130 .if ${MACHINE_CPUARCH} == "powerpc"
131 CFLAGS+=        -msoft-float -mno-altivec
132 INLINE_LIMIT?=  15000
133 .endif
134
135 #
136 # Use dot symbols on powerpc64 to make ddb happy
137 #
138 .if ${MACHINE_ARCH} == "powerpc64"
139 CFLAGS+=        -mcall-aixdesc
140 .endif
141
142 #
143 # For MIPS we also tell gcc to use floating point emulation
144 #
145 .if ${MACHINE_CPUARCH} == "mips"
146 CFLAGS+=        -msoft-float
147 INLINE_LIMIT?=  8000
148 .endif
149
150 #
151 # GCC 3.0 and above like to do certain optimizations based on the
152 # assumption that the program is linked against libc.  Stop this.
153 #
154 CFLAGS+=        -ffreestanding
155
156 #
157 # GCC SSP support
158 #
159 .if ${MK_SSP} != "no" && ${MACHINE_CPUARCH} != "ia64" && \
160     ${MACHINE_CPUARCH} != "arm" && ${MACHINE_CPUARCH} != "mips"
161 CFLAGS+=        -fstack-protector
162 .endif
163
164 #
165 # Add -gdwarf-2 when compiling -g
166 #
167 .if ${COMPILER_TYPE} == "clang" && ${CFLAGS:M-g} != "" && ${CFLAGS:M-gdwarf} == ""
168 CFLAGS+=        -gdwarf-2
169 .endif