]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/conf/kern.mk
Update libc++ to 3.7.0 release.
[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                 -Wno-unknown-pragmas \
11                 ${CWARNEXTRA}
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_WSHIFT_COUNT_NEGATIVE=       -Wno-shift-count-negative
22 NO_WSHIFT_COUNT_OVERFLOW=       -Wno-shift-count-overflow
23 NO_WSELF_ASSIGN=                -Wno-self-assign
24 NO_WUNNEEDED_INTERNAL_DECL=     -Wno-unneeded-internal-declaration
25 NO_WSOMETIMES_UNINITIALIZED=    -Wno-error-sometimes-uninitialized
26 NO_WCAST_QUAL=                  -Wno-cast-qual
27 # Several other warnings which might be useful in some cases, but not severe
28 # enough to error out the whole kernel build.  Display them anyway, so there is
29 # some incentive to fix them eventually.
30 CWARNEXTRA?=    -Wno-error-tautological-compare -Wno-error-empty-body \
31                 -Wno-error-parentheses-equality -Wno-error-unused-function \
32                 -Wno-error-pointer-sign
33 .if ${COMPILER_VERSION} >= 30700
34 CWARNEXTRA+=    -Wno-error-shift-negative-value
35 .endif
36
37 CLANG_NO_IAS= -no-integrated-as
38 .if ${COMPILER_VERSION} < 30500
39 # XXX: clang < 3.5 integrated-as doesn't grok .codeNN directives
40 CLANG_NO_IAS34= -no-integrated-as
41 .endif
42 .endif
43
44 .if ${COMPILER_TYPE} == "gcc"
45 .if ${COMPILER_VERSION} >= 40300
46 # Catch-all for all the things that are in our tree, but for which we're
47 # not yet ready for this compiler. Note: we likely only really "support"
48 # building with gcc 4.8 and newer. Nothing older has been tested.
49 CWARNEXTRA?=    -Wno-error=inline -Wno-error=enum-compare -Wno-error=unused-but-set-variable \
50                 -Wno-error=aggressive-loop-optimizations -Wno-error=maybe-uninitialized \
51                 -Wno-error=array-bounds -Wno-error=address \
52                 -Wno-error=cast-qual -Wno-error=sequence-point -Wno-error=attributes \
53                 -Wno-error=strict-overflow -Wno-error=overflow
54 .else
55 # For gcc 4.2, eliminate the too-often-wrong warnings about uninitialized vars.
56 CWARNEXTRA?=    -Wno-uninitialized
57 .endif
58 .endif
59
60 # External compilers may not support our format extensions.  Allow them
61 # to be disabled.  WARNING: format checking is disabled in this case.
62 .if ${MK_FORMAT_EXTENSIONS} == "no"
63 FORMAT_EXTENSIONS=      -Wno-format
64 .elif ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 30600
65 FORMAT_EXTENSIONS=      -D__printf__=__freebsd_kprintf__
66 .else
67 FORMAT_EXTENSIONS=      -fformat-extensions
68 .endif
69
70 #
71 # On i386, do not align the stack to 16-byte boundaries.  Otherwise GCC 2.95
72 # and above adds code to the entry and exit point of every function to align the
73 # stack to 16-byte boundaries -- thus wasting approximately 12 bytes of stack
74 # per function call.  While the 16-byte alignment may benefit micro benchmarks,
75 # it is probably an overall loss as it makes the code bigger (less efficient
76 # use of code cache tag lines) and uses more stack (less efficient use of data
77 # cache tag lines).  Explicitly prohibit the use of FPU, SSE and other SIMD
78 # operations inside the kernel itself.  These operations are exclusively
79 # reserved for user applications.
80 #
81 # gcc:
82 # Setting -mno-mmx implies -mno-3dnow
83 # Setting -mno-sse implies -mno-sse2, -mno-sse3 and -mno-ssse3
84 #
85 # clang:
86 # Setting -mno-mmx implies -mno-3dnow and -mno-3dnowa
87 # Setting -mno-sse implies -mno-sse2, -mno-sse3, -mno-ssse3, -mno-sse41 and -mno-sse42
88 #
89 .if ${MACHINE_CPUARCH} == "i386"
90 CFLAGS.gcc+=    -mno-align-long-strings -mpreferred-stack-boundary=2
91 CFLAGS.clang+=  -mno-aes -mno-avx
92 CFLAGS+=        -mno-mmx -mno-sse -msoft-float
93 INLINE_LIMIT?=  8000
94 .endif
95
96 .if ${MACHINE_CPUARCH} == "arm"
97 INLINE_LIMIT?=  8000
98 .endif
99
100 #
101 # For sparc64 we want the medany code model so modules may be located
102 # anywhere in the 64-bit address space.  We also tell GCC to use floating
103 # point emulation.  This avoids using floating point registers for integer
104 # operations which it has a tendency to do.
105 #
106 .if ${MACHINE_CPUARCH} == "sparc64"
107 CFLAGS.clang+=  -mcmodel=large -fno-dwarf2-cfi-asm
108 CFLAGS.gcc+=    -mcmodel=medany -msoft-float
109 INLINE_LIMIT?=  15000
110 .endif
111
112 #
113 # For AMD64, we explicitly prohibit the use of FPU, SSE and other SIMD
114 # operations inside the kernel itself.  These operations are exclusively
115 # reserved for user applications.
116 #
117 # gcc:
118 # Setting -mno-mmx implies -mno-3dnow
119 # Setting -mno-sse implies -mno-sse2, -mno-sse3, -mno-ssse3 and -mfpmath=387
120 #
121 # clang:
122 # Setting -mno-mmx implies -mno-3dnow and -mno-3dnowa
123 # Setting -mno-sse implies -mno-sse2, -mno-sse3, -mno-ssse3, -mno-sse41 and -mno-sse42
124 # (-mfpmath= is not supported)
125 #
126 .if ${MACHINE_CPUARCH} == "amd64"
127 CFLAGS.clang+=  -mno-aes -mno-avx
128 CFLAGS+=        -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float \
129                 -fno-asynchronous-unwind-tables
130 INLINE_LIMIT?=  8000
131 .endif
132
133 #
134 # For PowerPC we tell gcc to use floating point emulation.  This avoids using
135 # floating point registers for integer operations which it has a tendency to do.
136 # Also explicitly disable Altivec instructions inside the kernel.
137 #
138 .if ${MACHINE_CPUARCH} == "powerpc"
139 CFLAGS+=        -mno-altivec
140 CFLAGS.clang+=  -mllvm -disable-ppc-float-in-variadic=true
141 CFLAGS.gcc+=    -msoft-float
142 INLINE_LIMIT?=  15000
143 .endif
144
145 #
146 # Use dot symbols on powerpc64 to make ddb happy
147 #
148 .if ${MACHINE_ARCH} == "powerpc64"
149 CFLAGS.gcc+=    -mcall-aixdesc
150 .endif
151
152 #
153 # For MIPS we also tell gcc to use floating point emulation
154 #
155 .if ${MACHINE_CPUARCH} == "mips"
156 CFLAGS+=        -msoft-float
157 INLINE_LIMIT?=  8000
158 .endif
159
160 #
161 # GCC 3.0 and above like to do certain optimizations based on the
162 # assumption that the program is linked against libc.  Stop this.
163 #
164 CFLAGS+=        -ffreestanding
165
166 #
167 # The C standard leaves signed integer overflow behavior undefined.
168 # gcc and clang opimizers take advantage of this.  The kernel makes
169 # use of signed integer wraparound mechanics so we need the compiler
170 # to treat it as a wraparound and not take shortcuts.
171
172 CFLAGS+=        -fwrapv
173
174 #
175 # GCC SSP support
176 #
177 .if ${MK_SSP} != "no" && \
178     ${MACHINE_CPUARCH} != "arm" && ${MACHINE_CPUARCH} != "mips"
179 CFLAGS+=        -fstack-protector
180 .endif
181
182 #
183 # Add -gdwarf-2 when compiling -g. The default starting in clang v3.4
184 # and gcc 4.8 is to generate DWARF version 4. However, our tools don't
185 # cope well with DWARF 4, so force it to genereate DWARF2, which they
186 # understand. Do this unconditionally as it is harmless when not needed,
187 # but critical for these newer versions.
188 #
189 .if ${CFLAGS:M-g} != "" && ${CFLAGS:M-gdwarf*} == ""
190 CFLAGS+=        -gdwarf-2
191 .endif
192
193 CFLAGS+= ${CWARNFLAGS} ${CWARNFLAGS.${.IMPSRC:T}}
194 CFLAGS+= ${CFLAGS.${COMPILER_TYPE}} ${CFLAGS.${.IMPSRC:T}}
195
196 # Tell bmake not to mistake standard targets for things to be searched for
197 # or expect to ever be up-to-date.
198 PHONY_NOTMAIN = afterdepend afterinstall all beforedepend beforeinstall \
199                 beforelinking build build-tools buildfiles buildincludes \
200                 checkdpadd clean cleandepend cleandir cleanobj configure \
201                 depend dependall distclean distribute exe \
202                 html includes install installfiles installincludes lint \
203                 obj objlink objs objwarn realall realdepend \
204                 realinstall regress subdir-all subdir-depend subdir-install \
205                 tags whereobj
206
207 .PHONY: ${PHONY_NOTMAIN}
208 .NOTMAIN: ${PHONY_NOTMAIN}
209
210 CSTD=           c99
211
212 .if ${CSTD} == "k&r"
213 CFLAGS+=        -traditional
214 .elif ${CSTD} == "c89" || ${CSTD} == "c90"
215 CFLAGS+=        -std=iso9899:1990
216 .elif ${CSTD} == "c94" || ${CSTD} == "c95"
217 CFLAGS+=        -std=iso9899:199409
218 .elif ${CSTD} == "c99"
219 CFLAGS+=        -std=iso9899:1999
220 .else # CSTD
221 CFLAGS+=        -std=${CSTD}
222 .endif # CSTD