]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/conf/kern.mk
Fix module builds on arm (and maybe others) by turning off a whole
[FreeBSD/FreeBSD.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 -Wno-error-unused-function
33 .endif
34
35 .if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 40300
36 # Catch-all for all the things that are in our tree, but for which we're
37 # not yet ready for this compiler. Note: we likely only really "support"
38 # building with gcc 4.8 and newer. Nothing older has been tested.
39 CWARNEXTRA?=    -Wno-error=inline -Wno-error=enum-compare -Wno-error=unused-but-set-variable \
40                 -Wno-error=aggressive-loop-optimizations -Wno-error=maybe-uninitialized \
41                 -Wno-error=array-bounds -Wno-error=address \
42                 -Wno-error=cast-qual -Wno-error=sequence-point -Wno-error=attributes \
43                 -Wno-error=strict-overflow -Wno-error=overflow
44 .endif
45
46 # External compilers may not support our format extensions.  Allow them
47 # to be disabled.  WARNING: format checking is disabled in this case.
48 .if ${MK_FORMAT_EXTENSIONS} == "no"
49 FORMAT_EXTENSIONS=      -Wno-format
50 .else
51 FORMAT_EXTENSIONS=      -fformat-extensions
52 .endif
53
54 #
55 # On i386, do not align the stack to 16-byte boundaries.  Otherwise GCC 2.95
56 # and above adds code to the entry and exit point of every function to align the
57 # stack to 16-byte boundaries -- thus wasting approximately 12 bytes of stack
58 # per function call.  While the 16-byte alignment may benefit micro benchmarks,
59 # it is probably an overall loss as it makes the code bigger (less efficient
60 # use of code cache tag lines) and uses more stack (less efficient use of data
61 # cache tag lines).  Explicitly prohibit the use of FPU, SSE and other SIMD
62 # operations inside the kernel itself.  These operations are exclusively
63 # reserved for user applications.
64 #
65 # gcc:
66 # Setting -mno-mmx implies -mno-3dnow
67 # Setting -mno-sse implies -mno-sse2, -mno-sse3 and -mno-ssse3
68 #
69 # clang:
70 # Setting -mno-mmx implies -mno-3dnow and -mno-3dnowa
71 # Setting -mno-sse implies -mno-sse2, -mno-sse3, -mno-ssse3, -mno-sse41 and -mno-sse42
72 #
73 .if ${MACHINE_CPUARCH} == "i386"
74 CFLAGS.gcc+=    -mno-align-long-strings -mpreferred-stack-boundary=2
75 CFLAGS.clang+=  -mno-aes -mno-avx
76 CFLAGS+=        -mno-mmx -mno-sse -msoft-float
77 INLINE_LIMIT?=  8000
78 .endif
79
80 .if ${MACHINE_CPUARCH} == "arm"
81 INLINE_LIMIT?=  8000
82 .endif
83
84 #
85 # For sparc64 we want the medany code model so modules may be located
86 # anywhere in the 64-bit address space.  We also tell GCC to use floating
87 # point emulation.  This avoids using floating point registers for integer
88 # operations which it has a tendency to do.
89 #
90 .if ${MACHINE_CPUARCH} == "sparc64"
91 CFLAGS.clang+=  -mcmodel=large -fno-dwarf2-cfi-asm
92 CFLAGS.gcc+=    -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 CFLAGS.clang+=  -mno-aes -mno-avx
112 CFLAGS+=        -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float \
113                 -fno-asynchronous-unwind-tables
114 INLINE_LIMIT?=  8000
115 .endif
116
117 #
118 # For PowerPC we tell gcc to use floating point emulation.  This avoids using
119 # floating point registers for integer operations which it has a tendency to do.
120 # Also explicitly disable Altivec instructions inside the kernel.
121 #
122 .if ${MACHINE_CPUARCH} == "powerpc"
123 CFLAGS+=        -msoft-float -mno-altivec
124 INLINE_LIMIT?=  15000
125 .endif
126
127 #
128 # Use dot symbols on powerpc64 to make ddb happy
129 #
130 .if ${MACHINE_ARCH} == "powerpc64"
131 CFLAGS+=        -mcall-aixdesc
132 .endif
133
134 #
135 # For MIPS we also tell gcc to use floating point emulation
136 #
137 .if ${MACHINE_CPUARCH} == "mips"
138 CFLAGS+=        -msoft-float
139 INLINE_LIMIT?=  8000
140 .endif
141
142 #
143 # GCC 3.0 and above like to do certain optimizations based on the
144 # assumption that the program is linked against libc.  Stop this.
145 #
146 CFLAGS+=        -ffreestanding
147
148 #
149 # GCC SSP support
150 #
151 .if ${MK_SSP} != "no" && \
152     ${MACHINE_CPUARCH} != "arm" && ${MACHINE_CPUARCH} != "mips"
153 CFLAGS+=        -fstack-protector
154 .endif
155
156 #
157 # Add -gdwarf-2 when compiling -g. The default starting in clang v3.4
158 # and gcc 4.8 is to generate DWARF version 4. However, our tools don't
159 # cope well with DWARF 4, so force it to genereate DWARF2, which they
160 # understand. Do this unconditionally as it is harmless when not needed,
161 # but critical for these newer versions.
162 #
163 .if ${CFLAGS:M-g} != "" && ${CFLAGS:M-gdwarf*} == ""
164 CFLAGS+=        -gdwarf-2
165 .endif
166
167 # A whole bunch of new default warnings in clang 3.5 subpress for now until
168 # this can be cleaned up.
169 .if ${COMPILER_VERSION} >= 30500
170 CFLAGS.clang+=    -Wno-pointer-sign -Wno-constant-conversion -Wno-format \
171         -Wno-shift-count-negative -Wno-tautological-pointer-compare \
172         -Wno-shift-count-overflow -Wno-tautological-compare
173 .endif
174
175 CFLAGS+= ${CFLAGS.${COMPILER_TYPE}}
176
177 # Tell bmake not to mistake standard targets for things to be searched for
178 # or expect to ever be up-to-date.
179 PHONY_NOTMAIN = afterdepend afterinstall all beforedepend beforeinstall \
180                 beforelinking build build-tools buildfiles buildincludes \
181                 checkdpadd clean cleandepend cleandir cleanobj configure \
182                 depend dependall distclean distribute exe \
183                 html includes install installfiles installincludes lint \
184                 obj objlink objs objwarn realall realdepend \
185                 realinstall regress subdir-all subdir-depend subdir-install \
186                 tags whereobj
187
188 .PHONY: ${PHONY_NOTMAIN}
189 .NOTMAIN: ${PHONY_NOTMAIN}