]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - sys/conf/kern.mk
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.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 #
12 # The following flags are next up for working on:
13 #       -Wextra
14
15 # Disable a few warnings for clang, since there are several places in the
16 # kernel where fixing them is more trouble than it is worth, or where there is
17 # a false positive.
18 .if ${COMPILER_TYPE} == "clang"
19 NO_WCONSTANT_CONVERSION=        -Wno-constant-conversion
20 NO_WARRAY_BOUNDS=               -Wno-array-bounds
21 NO_WSHIFT_COUNT_NEGATIVE=       -Wno-shift-count-negative
22 NO_WSHIFT_COUNT_OVERFLOW=       -Wno-shift-count-overflow
23 NO_WUNUSED_VALUE=               -Wno-unused-value
24 NO_WSELF_ASSIGN=                -Wno-self-assign
25 NO_WFORMAT_SECURITY=            -Wno-format-security
26 NO_WUNNEEDED_INTERNAL_DECL=     -Wno-unneeded-internal-declaration
27 NO_WSOMETIMES_UNINITIALIZED=    -Wno-error-sometimes-uninitialized
28 # Several other warnings which might be useful in some cases, but not severe
29 # enough to error out the whole kernel build.  Display them anyway, so there is
30 # some incentive to fix them eventually.
31 CWARNEXTRA?=    -Wno-error-tautological-compare -Wno-error-empty-body \
32                 -Wno-error-parentheses-equality ${NO_WFORMAT}
33 .endif
34
35 # External compilers may not support our format extensions.  Allow them
36 # to be disabled.  WARNING: format checking is disabled in this case.
37 .if ${MK_FORMAT_EXTENSIONS} == "no"
38 NO_WFORMAT=             -Wno-format
39 .else
40 FORMAT_EXTENSIONS=      -fformat-extensions
41 .endif
42
43 #
44 # On i386, do not align the stack to 16-byte boundaries.  Otherwise GCC 2.95
45 # and above adds code to the entry and exit point of every function to align the
46 # stack to 16-byte boundaries -- thus wasting approximately 12 bytes of stack
47 # per function call.  While the 16-byte alignment may benefit micro benchmarks,
48 # it is probably an overall loss as it makes the code bigger (less efficient
49 # use of code cache tag lines) and uses more stack (less efficient use of data
50 # cache tag lines).  Explicitly prohibit the use of FPU, SSE and other SIMD
51 # operations inside the kernel itself.  These operations are exclusively
52 # reserved for user applications.
53 #
54 # gcc:
55 # Setting -mno-mmx implies -mno-3dnow
56 # Setting -mno-sse implies -mno-sse2, -mno-sse3 and -mno-ssse3
57 #
58 # clang:
59 # Setting -mno-mmx implies -mno-3dnow and -mno-3dnowa
60 # Setting -mno-sse implies -mno-sse2, -mno-sse3, -mno-ssse3, -mno-sse41 and -mno-sse42
61 #
62 .if ${MACHINE_CPUARCH} == "i386"
63 .if ${COMPILER_TYPE} != "clang"
64 CFLAGS+=        -mno-align-long-strings -mpreferred-stack-boundary=2
65 .else
66 CFLAGS+=        -mno-aes -mno-avx
67 .endif
68 CFLAGS+=        -mno-mmx -mno-sse -msoft-float
69 INLINE_LIMIT?=  8000
70 .endif
71
72 .if ${MACHINE_CPUARCH} == "arm"
73 INLINE_LIMIT?=  8000
74 .endif
75
76 #
77 # For IA-64, we use r13 for the kernel globals pointer and we only use
78 # a very small subset of float registers for integer divides.
79 #
80 .if ${MACHINE_CPUARCH} == "ia64"
81 CFLAGS+=        -ffixed-r13 -mfixed-range=f32-f127 -fpic #-mno-sdata
82 INLINE_LIMIT?=  15000
83 .endif
84
85 #
86 # For sparc64 we want the medany code model so modules may be located
87 # anywhere in the 64-bit address space.  We also tell GCC to use floating
88 # point emulation.  This avoids using floating point registers for integer
89 # operations which it has a tendency to do.
90 #
91 .if ${MACHINE_CPUARCH} == "sparc64"
92 CFLAGS+=        -mcmodel=medany -msoft-float
93 INLINE_LIMIT?=  15000
94 .endif
95
96 #
97 # For AMD64, we explicitly prohibit the use of FPU, SSE and other SIMD
98 # operations inside the kernel itself.  These operations are exclusively
99 # reserved for user applications.
100 #
101 # gcc:
102 # Setting -mno-mmx implies -mno-3dnow
103 # Setting -mno-sse implies -mno-sse2, -mno-sse3, -mno-ssse3 and -mfpmath=387
104 #
105 # clang:
106 # Setting -mno-mmx implies -mno-3dnow and -mno-3dnowa
107 # Setting -mno-sse implies -mno-sse2, -mno-sse3, -mno-ssse3, -mno-sse41 and -mno-sse42
108 # (-mfpmath= is not supported)
109 #
110 .if ${MACHINE_CPUARCH} == "amd64"
111 .if ${COMPILER_TYPE} == "clang"
112 CFLAGS+=        -mno-aes -mno-avx
113 .endif
114 CFLAGS+=        -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float \
115                 -fno-asynchronous-unwind-tables
116 INLINE_LIMIT?=  8000
117 .endif
118
119 #
120 # For PowerPC we tell gcc to use floating point emulation.  This avoids using
121 # floating point registers for integer operations which it has a tendency to do.
122 # Also explicitly disable Altivec instructions inside the kernel.
123 #
124 .if ${MACHINE_CPUARCH} == "powerpc"
125 CFLAGS+=        -msoft-float -mno-altivec
126 INLINE_LIMIT?=  15000
127 .endif
128
129 #
130 # Use dot symbols on powerpc64 to make ddb happy
131 #
132 .if ${MACHINE_ARCH} == "powerpc64"
133 CFLAGS+=        -mcall-aixdesc
134 .endif
135
136 #
137 # For MIPS we also tell gcc to use floating point emulation
138 #
139 .if ${MACHINE_CPUARCH} == "mips"
140 CFLAGS+=        -msoft-float
141 INLINE_LIMIT?=  8000
142 .endif
143
144 #
145 # GCC 3.0 and above like to do certain optimizations based on the
146 # assumption that the program is linked against libc.  Stop this.
147 #
148 CFLAGS+=        -ffreestanding
149
150 #
151 # GCC SSP support
152 #
153 .if ${MK_SSP} != "no" && ${MACHINE_CPUARCH} != "ia64" && \
154     ${MACHINE_CPUARCH} != "arm" && ${MACHINE_CPUARCH} != "mips"
155 CFLAGS+=        -fstack-protector
156 .endif