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