kern.pre.mk (c8c62548bffb83f3d25e062929c45d66fea755f1) kern.pre.mk (aa3ea612be3659881392251e91912682b038ce78)
1# $FreeBSD$
2
3# Part of a unified Makefile for building kernels. This part contains all
4# of the definitions that need to be before %BEFORE_DEPEND.
5
6# Allow user to configure things that only effect src tree builds.
7# Note: This is duplicated from src.sys.mk to ensure that we include
8# /etc/src.conf when building the kernel. Kernels can be built without

--- 78 unchanged lines hidden (view full) ---

87# The following should be removed no earlier than LLVM11 being imported into the
88# tree, to ensure we don't regress the build. LLVM11 and GCC10 will switch the
89# default over to -fno-common, making this redundant.
90CFLAGS+= -fno-common
91
92# XXX LOCORE means "don't declare C stuff" not "for locore.s".
93ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS} ${ASM_CFLAGS.${.IMPSRC:T}}
94
1# $FreeBSD$
2
3# Part of a unified Makefile for building kernels. This part contains all
4# of the definitions that need to be before %BEFORE_DEPEND.
5
6# Allow user to configure things that only effect src tree builds.
7# Note: This is duplicated from src.sys.mk to ensure that we include
8# /etc/src.conf when building the kernel. Kernels can be built without

--- 78 unchanged lines hidden (view full) ---

87# The following should be removed no earlier than LLVM11 being imported into the
88# tree, to ensure we don't regress the build. LLVM11 and GCC10 will switch the
89# default over to -fno-common, making this redundant.
90CFLAGS+= -fno-common
91
92# XXX LOCORE means "don't declare C stuff" not "for locore.s".
93ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS} ${ASM_CFLAGS.${.IMPSRC:T}}
94
95.if defined(PROFLEVEL) && ${PROFLEVEL} >= 1
96CFLAGS+= -DGPROF
97CFLAGS.gcc+= -falign-functions=16
98.if ${PROFLEVEL} >= 2
99CFLAGS+= -DGPROF4 -DGUPROF
100PROF= -pg
101.if ${COMPILER_TYPE} == "gcc"
102PROF+= -mprofiler-epilogue
103.endif
104.else
105PROF= -pg
106.endif
107.endif
108DEFINED_PROF= ${PROF}
109
110KCSAN_ENABLED!= grep KCSAN opt_global.h || true ; echo
111.if !empty(KCSAN_ENABLED)
112SAN_CFLAGS+= -fsanitize=thread
113.endif
114
115KUBSAN_ENABLED!= grep KUBSAN opt_global.h || true ; echo
116.if !empty(KUBSAN_ENABLED)
117SAN_CFLAGS+= -fsanitize=undefined

--- 15 unchanged lines hidden (view full) ---

133.if !empty(GCOV_ENABLED)
134.if ${COMPILER_TYPE} == "gcc"
135GCOV_CFLAGS+= -fprofile-arcs -ftest-coverage
136.endif
137.endif
138
139CFLAGS+= ${GCOV_CFLAGS}
140
95KCSAN_ENABLED!= grep KCSAN opt_global.h || true ; echo
96.if !empty(KCSAN_ENABLED)
97SAN_CFLAGS+= -fsanitize=thread
98.endif
99
100KUBSAN_ENABLED!= grep KUBSAN opt_global.h || true ; echo
101.if !empty(KUBSAN_ENABLED)
102SAN_CFLAGS+= -fsanitize=undefined

--- 15 unchanged lines hidden (view full) ---

118.if !empty(GCOV_ENABLED)
119.if ${COMPILER_TYPE} == "gcc"
120GCOV_CFLAGS+= -fprofile-arcs -ftest-coverage
121.endif
122.endif
123
124CFLAGS+= ${GCOV_CFLAGS}
125
141# Put configuration-specific C flags last (except for ${PROF}) so that they
142# can override the others.
126# Put configuration-specific C flags last so that they can override
127# the others.
143CFLAGS+= ${CONF_CFLAGS}
144
145.if defined(LINKER_FEATURES) && ${LINKER_FEATURES:Mbuild-id}
146LDFLAGS+= --build-id=sha1
147.endif
148
149.if (${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "amd64" || \
150 ${MACHINE_CPUARCH} == "i386" || ${MACHINE} == "powerpc") && \

--- 20 unchanged lines hidden (view full) ---

171# rewriting the instructions to generate an absolute address of 0); -fPIE
172# avoids this since it uses the GOT for all extern symbols, which is overly
173# inefficient for us. Drop once undefined weak symbols work with medany.
174.if ${LINKER_TYPE} == "lld"
175CFLAGS+= -fPIE
176.endif
177.endif
178
128CFLAGS+= ${CONF_CFLAGS}
129
130.if defined(LINKER_FEATURES) && ${LINKER_FEATURES:Mbuild-id}
131LDFLAGS+= --build-id=sha1
132.endif
133
134.if (${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "amd64" || \
135 ${MACHINE_CPUARCH} == "i386" || ${MACHINE} == "powerpc") && \

--- 20 unchanged lines hidden (view full) ---

156# rewriting the instructions to generate an absolute address of 0); -fPIE
157# avoids this since it uses the GOT for all extern symbols, which is overly
158# inefficient for us. Drop once undefined weak symbols work with medany.
159.if ${LINKER_TYPE} == "lld"
160CFLAGS+= -fPIE
161.endif
162.endif
163
179NORMAL_C= ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.IMPSRC}
164NORMAL_C= ${CC} -c ${CFLAGS} ${WERROR} ${.IMPSRC}
180NORMAL_S= ${CC:N${CCACHE_BIN}} -c ${ASM_CFLAGS} ${WERROR} ${.IMPSRC}
165NORMAL_S= ${CC:N${CCACHE_BIN}} -c ${ASM_CFLAGS} ${WERROR} ${.IMPSRC}
181PROFILE_C= ${CC} -c ${CFLAGS} ${WERROR} ${.IMPSRC}
182NORMAL_C_NOWERROR= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
166NORMAL_C_NOWERROR= ${CC} -c ${CFLAGS} ${.IMPSRC}
183
184NORMAL_M= ${AWK} -f $S/tools/makeobjops.awk ${.IMPSRC} -c ; \
167
168NORMAL_M= ${AWK} -f $S/tools/makeobjops.awk ${.IMPSRC} -c ; \
185 ${CC} -c ${CFLAGS} ${WERROR} ${PROF} ${.PREFIX}.c
169 ${CC} -c ${CFLAGS} ${WERROR} ${.PREFIX}.c
186
187NORMAL_FW= uudecode -o ${.TARGET} ${.ALLSRC}
188NORMAL_FWO= ${CC:N${CCACHE_BIN}} -c ${ASM_CFLAGS} ${WERROR} -o ${.TARGET} \
189 $S/kern/firmw.S -DFIRMW_FILE="${.ALLSRC:M*.fw}" \
190 -DFIRMW_SYMBOL="${.ALLSRC:M*.fw:C/[-.\/]/_/g}"
191
192# for ZSTD in the kernel (include zstd/lib/freebsd before other CFLAGS)
193ZSTD_C= ${CC} -c -DZSTD_HEAPMODE=1 -I$S/contrib/zstd/lib/freebsd ${CFLAGS} \
194 -I$S/contrib/zstd/lib -I$S/contrib/zstd/lib/common ${WERROR} \
170
171NORMAL_FW= uudecode -o ${.TARGET} ${.ALLSRC}
172NORMAL_FWO= ${CC:N${CCACHE_BIN}} -c ${ASM_CFLAGS} ${WERROR} -o ${.TARGET} \
173 $S/kern/firmw.S -DFIRMW_FILE="${.ALLSRC:M*.fw}" \
174 -DFIRMW_SYMBOL="${.ALLSRC:M*.fw:C/[-.\/]/_/g}"
175
176# for ZSTD in the kernel (include zstd/lib/freebsd before other CFLAGS)
177ZSTD_C= ${CC} -c -DZSTD_HEAPMODE=1 -I$S/contrib/zstd/lib/freebsd ${CFLAGS} \
178 -I$S/contrib/zstd/lib -I$S/contrib/zstd/lib/common ${WERROR} \
195 -Wno-missing-prototypes ${PROF} -U__BMI__ \
196 -DZSTD_NO_INTRINSICS \
197 ${.IMPSRC}
179 -Wno-missing-prototypes -U__BMI__ -DZSTD_NO_INTRINSICS ${.IMPSRC}
198# https://github.com/facebook/zstd/commit/812e8f2a [zstd 1.4.1]
199# "Note that [GCC] autovectorization still does not do a good job on the
200# optimized version, so it's turned off via attribute and flag. I found
201# that neither attribute nor command-line flag were entirely successful in
202# turning off vectorization, which is why there were both."
203.if ${COMPILER_TYPE} == "gcc"
204ZSTD_DECOMPRESS_BLOCK_FLAGS= -fno-tree-vectorize
205.endif

--- 26 unchanged lines hidden (view full) ---

232 -Wno-switch \
233 -Wno-undef \
234 -Wno-uninitialized \
235 -Wno-unknown-pragmas \
236 -Wno-unused \
237 -include ${ZINCDIR}/os/freebsd/spl/sys/ccompile.h \
238 -I$S/cddl/contrib/opensolaris/uts/common \
239 -I$S -I$S/cddl/compat/opensolaris
180# https://github.com/facebook/zstd/commit/812e8f2a [zstd 1.4.1]
181# "Note that [GCC] autovectorization still does not do a good job on the
182# optimized version, so it's turned off via attribute and flag. I found
183# that neither attribute nor command-line flag were entirely successful in
184# turning off vectorization, which is why there were both."
185.if ${COMPILER_TYPE} == "gcc"
186ZSTD_DECOMPRESS_BLOCK_FLAGS= -fno-tree-vectorize
187.endif

--- 26 unchanged lines hidden (view full) ---

214 -Wno-switch \
215 -Wno-undef \
216 -Wno-uninitialized \
217 -Wno-unknown-pragmas \
218 -Wno-unused \
219 -include ${ZINCDIR}/os/freebsd/spl/sys/ccompile.h \
220 -I$S/cddl/contrib/opensolaris/uts/common \
221 -I$S -I$S/cddl/compat/opensolaris
240CDDL_C= ${CC} -c ${CDDL_CFLAGS} ${WERROR} ${PROF} ${.IMPSRC}
222CDDL_C= ${CC} -c ${CDDL_CFLAGS} ${WERROR} ${.IMPSRC}
241
242# Special flags for managing the compat compiles for ZFS
243ZFS_CFLAGS+= ${CDDL_CFLAGS} -DBUILDING_ZFS -DHAVE_UIO_ZEROCOPY \
244 -DWITH_NETDUMP -D__KERNEL__ -D_SYS_CONDVAR_H_ -DSMP \
245 -DIN_FREEBSD_BASE -DHAVE_KSID
246
247.if ${MACHINE_ARCH} == "amd64"
248ZFS_CFLAGS+= -DHAVE_AVX2 -DHAVE_AVX -D__x86_64 -DHAVE_SSE2 -DHAVE_AVX512F \

--- 4 unchanged lines hidden (view full) ---

253 ${MACHINE_ARCH} == "powerpcspe" || ${MACHINE_ARCH} == "arm"
254ZFS_CFLAGS+= -DBITS_PER_LONG=32
255.else
256ZFS_CFLAGS+= -DBITS_PER_LONG=64
257.endif
258
259
260ZFS_ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${ZFS_CFLAGS}
223
224# Special flags for managing the compat compiles for ZFS
225ZFS_CFLAGS+= ${CDDL_CFLAGS} -DBUILDING_ZFS -DHAVE_UIO_ZEROCOPY \
226 -DWITH_NETDUMP -D__KERNEL__ -D_SYS_CONDVAR_H_ -DSMP \
227 -DIN_FREEBSD_BASE -DHAVE_KSID
228
229.if ${MACHINE_ARCH} == "amd64"
230ZFS_CFLAGS+= -DHAVE_AVX2 -DHAVE_AVX -D__x86_64 -DHAVE_SSE2 -DHAVE_AVX512F \

--- 4 unchanged lines hidden (view full) ---

235 ${MACHINE_ARCH} == "powerpcspe" || ${MACHINE_ARCH} == "arm"
236ZFS_CFLAGS+= -DBITS_PER_LONG=32
237.else
238ZFS_CFLAGS+= -DBITS_PER_LONG=64
239.endif
240
241
242ZFS_ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${ZFS_CFLAGS}
261ZFS_C= ${CC} -c ${ZFS_CFLAGS} ${WERROR} ${PROF} ${.IMPSRC}
262ZFS_RPC_C= ${CC} -c ${ZFS_CFLAGS} -DHAVE_RPC_TYPES ${WERROR} ${PROF} ${.IMPSRC}
243ZFS_C= ${CC} -c ${ZFS_CFLAGS} ${WERROR} ${.IMPSRC}
244ZFS_RPC_C= ${CC} -c ${ZFS_CFLAGS} -DHAVE_RPC_TYPES ${WERROR} ${.IMPSRC}
263ZFS_S= ${CC} -c ${ZFS_ASM_CFLAGS} ${WERROR} ${.IMPSRC}
264
265
266
267# Special flags for managing the compat compiles for DTrace
268DTRACE_CFLAGS= -DBUILDING_DTRACE ${CDDL_CFLAGS} -I$S/cddl/dev/dtrace -I$S/cddl/dev/dtrace/${MACHINE_CPUARCH}
269.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
270DTRACE_CFLAGS+= -I$S/cddl/contrib/opensolaris/uts/intel -I$S/cddl/dev/dtrace/x86
271.endif
272DTRACE_CFLAGS+= -I$S/cddl/contrib/opensolaris/common/util -I$S -DDIS_MEM -DSMP -I$S/cddl/compat/opensolaris
273DTRACE_CFLAGS+= -I$S/cddl/contrib/opensolaris/uts/common
274DTRACE_ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${DTRACE_CFLAGS}
245ZFS_S= ${CC} -c ${ZFS_ASM_CFLAGS} ${WERROR} ${.IMPSRC}
246
247
248
249# Special flags for managing the compat compiles for DTrace
250DTRACE_CFLAGS= -DBUILDING_DTRACE ${CDDL_CFLAGS} -I$S/cddl/dev/dtrace -I$S/cddl/dev/dtrace/${MACHINE_CPUARCH}
251.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
252DTRACE_CFLAGS+= -I$S/cddl/contrib/opensolaris/uts/intel -I$S/cddl/dev/dtrace/x86
253.endif
254DTRACE_CFLAGS+= -I$S/cddl/contrib/opensolaris/common/util -I$S -DDIS_MEM -DSMP -I$S/cddl/compat/opensolaris
255DTRACE_CFLAGS+= -I$S/cddl/contrib/opensolaris/uts/common
256DTRACE_ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${DTRACE_CFLAGS}
275DTRACE_C= ${CC} -c ${DTRACE_CFLAGS} ${WERROR} ${PROF} ${.IMPSRC}
257DTRACE_C= ${CC} -c ${DTRACE_CFLAGS} ${WERROR} ${.IMPSRC}
276DTRACE_S= ${CC} -c ${DTRACE_ASM_CFLAGS} ${WERROR} ${.IMPSRC}
277
278# Special flags for managing the compat compiles for DTrace/FBT
279FBT_CFLAGS= -DBUILDING_DTRACE -nostdinc -I$S/cddl/dev/fbt/${MACHINE_CPUARCH} -I$S/cddl/dev/fbt ${CDDL_CFLAGS} -I$S/cddl/compat/opensolaris -I$S/cddl/contrib/opensolaris/uts/common
280.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
281FBT_CFLAGS+= -I$S/cddl/dev/fbt/x86
282.endif
258DTRACE_S= ${CC} -c ${DTRACE_ASM_CFLAGS} ${WERROR} ${.IMPSRC}
259
260# Special flags for managing the compat compiles for DTrace/FBT
261FBT_CFLAGS= -DBUILDING_DTRACE -nostdinc -I$S/cddl/dev/fbt/${MACHINE_CPUARCH} -I$S/cddl/dev/fbt ${CDDL_CFLAGS} -I$S/cddl/compat/opensolaris -I$S/cddl/contrib/opensolaris/uts/common
262.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
263FBT_CFLAGS+= -I$S/cddl/dev/fbt/x86
264.endif
283FBT_C= ${CC} -c ${FBT_CFLAGS} ${WERROR} ${PROF} ${.IMPSRC}
265FBT_C= ${CC} -c ${FBT_CFLAGS} ${WERROR} ${.IMPSRC}
284
285.if ${MK_CTF} != "no"
286NORMAL_CTFCONVERT= ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
287.elif ${MAKE_VERSION} >= 5201111300
288NORMAL_CTFCONVERT=
289.else
290NORMAL_CTFCONVERT= @:
291.endif
292
293# Linux Kernel Programming Interface C-flags
294LINUXKPI_INCLUDES= -I$S/compat/linuxkpi/common/include
295LINUXKPI_C= ${NORMAL_C} ${LINUXKPI_INCLUDES}
296
297# Infiniband C flags. Correct include paths and omit errors that linux
298# does not honor.
299OFEDINCLUDES= -I$S/ofed/include -I$S/ofed/include/uapi ${LINUXKPI_INCLUDES}
300OFEDNOERR= -Wno-cast-qual -Wno-pointer-arith
301OFEDCFLAGS= ${CFLAGS:N-I*} -DCONFIG_INFINIBAND_USER_MEM \
302 ${OFEDINCLUDES} ${CFLAGS:M-I*} ${OFEDNOERR}
266
267.if ${MK_CTF} != "no"
268NORMAL_CTFCONVERT= ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
269.elif ${MAKE_VERSION} >= 5201111300
270NORMAL_CTFCONVERT=
271.else
272NORMAL_CTFCONVERT= @:
273.endif
274
275# Linux Kernel Programming Interface C-flags
276LINUXKPI_INCLUDES= -I$S/compat/linuxkpi/common/include
277LINUXKPI_C= ${NORMAL_C} ${LINUXKPI_INCLUDES}
278
279# Infiniband C flags. Correct include paths and omit errors that linux
280# does not honor.
281OFEDINCLUDES= -I$S/ofed/include -I$S/ofed/include/uapi ${LINUXKPI_INCLUDES}
282OFEDNOERR= -Wno-cast-qual -Wno-pointer-arith
283OFEDCFLAGS= ${CFLAGS:N-I*} -DCONFIG_INFINIBAND_USER_MEM \
284 ${OFEDINCLUDES} ${CFLAGS:M-I*} ${OFEDNOERR}
303OFED_C_NOIMP= ${CC} -c -o ${.TARGET} ${OFEDCFLAGS} ${WERROR} ${PROF}
285OFED_C_NOIMP= ${CC} -c -o ${.TARGET} ${OFEDCFLAGS} ${WERROR}
304OFED_C= ${OFED_C_NOIMP} ${.IMPSRC}
305
306# mlxfw C flags.
307MLXFW_C= ${OFED_C_NOIMP} \
308 -I${SRCTOP}/sys/contrib/xz-embedded/freebsd \
309 -I${SRCTOP}/sys/contrib/xz-embedded/linux/lib/xz \
310 ${.IMPSRC}
311

--- 56 unchanged lines hidden ---
286OFED_C= ${OFED_C_NOIMP} ${.IMPSRC}
287
288# mlxfw C flags.
289MLXFW_C= ${OFED_C_NOIMP} \
290 -I${SRCTOP}/sys/contrib/xz-embedded/freebsd \
291 -I${SRCTOP}/sys/contrib/xz-embedded/linux/lib/xz \
292 ${.IMPSRC}
293

--- 56 unchanged lines hidden ---