2003-11-05 12:20:16 +00:00
|
|
|
|
|
|
|
# Part of a unified Makefile for building kernels. This part contains all
|
|
|
|
# of the definitions that need to be before %BEFORE_DEPEND.
|
2001-11-02 21:34:20 +00:00
|
|
|
|
2014-05-17 20:31:34 +00:00
|
|
|
# Allow user to configure things that only effect src tree builds.
|
|
|
|
# Note: This is duplicated from src.sys.mk to ensure that we include
|
|
|
|
# /etc/src.conf when building the kernel. Kernels can be built without
|
|
|
|
# the rest of /usr/src, but they still always process SRCCONF even though
|
|
|
|
# the normal mechanisms to prevent that (compiling out of tree) won't
|
|
|
|
# work. To ensure they do work, we have to duplicate thee few lines here.
|
|
|
|
SRCCONF?= /etc/src.conf
|
|
|
|
.if (exists(${SRCCONF}) || ${SRCCONF} != "/etc/src.conf") && !target(_srcconf_included_)
|
|
|
|
.include "${SRCCONF}"
|
|
|
|
_srcconf_included_:
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.include <bsd.own.mk>
|
2012-09-13 16:00:46 +00:00
|
|
|
.include <bsd.compiler.mk>
|
2014-05-09 21:11:27 +00:00
|
|
|
.include "kern.opts.mk"
|
2006-07-17 18:43:16 +00:00
|
|
|
|
2016-05-26 23:20:01 +00:00
|
|
|
# The kernel build always occurs in the object directory which is .CURDIR.
|
|
|
|
.if ${.MAKE.MODE:Unormal:Mmeta}
|
|
|
|
.MAKE.MODE+= curdirOk=yes
|
|
|
|
.endif
|
|
|
|
|
2017-11-09 02:37:49 +00:00
|
|
|
# The kernel build always expects .OBJDIR=.CURDIR.
|
|
|
|
.OBJDIR: ${.CURDIR}
|
|
|
|
|
2017-11-03 23:22:03 +00:00
|
|
|
.if defined(NO_OBJWALK) || ${MK_AUTO_OBJ} == "yes"
|
|
|
|
NO_OBJWALK= t
|
2017-05-09 20:21:38 +00:00
|
|
|
NO_MODULES_OBJ= t
|
|
|
|
.endif
|
2017-11-03 23:22:03 +00:00
|
|
|
.if !defined(NO_OBJWALK)
|
2017-05-09 20:21:38 +00:00
|
|
|
_obj= obj
|
|
|
|
.endif
|
|
|
|
|
2001-11-02 21:34:20 +00:00
|
|
|
# Can be overridden by makeoptions or /etc/make.conf
|
|
|
|
KERNEL_KO?= kernel
|
|
|
|
KERNEL?= kernel
|
|
|
|
KODIR?= /boot/${KERNEL}
|
2008-02-02 07:52:24 +00:00
|
|
|
LDSCRIPT_NAME?= ldscript.$M
|
|
|
|
LDSCRIPT?= $S/conf/${LDSCRIPT_NAME}
|
2001-11-02 21:34:20 +00:00
|
|
|
|
2015-04-16 22:34:10 +00:00
|
|
|
M= ${MACHINE}
|
2001-11-02 21:34:20 +00:00
|
|
|
|
2002-03-01 01:21:29 +00:00
|
|
|
AWK?= awk
|
2012-09-13 09:01:52 +00:00
|
|
|
CP?= cp
|
2021-12-01 00:51:01 +00:00
|
|
|
ELFDUMP?= elfdump
|
2001-11-02 21:34:20 +00:00
|
|
|
NM?= nm
|
|
|
|
OBJCOPY?= objcopy
|
|
|
|
SIZE?= size
|
|
|
|
|
2011-04-19 18:09:21 +00:00
|
|
|
.if defined(DEBUG)
|
2009-01-12 16:54:41 +00:00
|
|
|
CTFFLAGS+= -g
|
2011-12-24 19:01:31 +00:00
|
|
|
.endif
|
2020-09-29 11:48:22 +00:00
|
|
|
.if ${MACHINE_CPUARCH} == "amd64" && ${COMPILER_TYPE} != "clang"
|
|
|
|
_COPTFLAGS_EXTRA=-frename-registers
|
2011-12-24 19:01:31 +00:00
|
|
|
.else
|
2020-09-29 11:48:22 +00:00
|
|
|
_COPTFLAGS_EXTRA=
|
2011-04-19 18:09:21 +00:00
|
|
|
.endif
|
2020-09-29 11:48:22 +00:00
|
|
|
COPTFLAGS?=-O2 -pipe ${_COPTFLAGS_EXTRA}
|
2011-04-19 18:09:21 +00:00
|
|
|
.if !empty(COPTFLAGS:M-O[23s]) && empty(COPTFLAGS:M-fno-strict-aliasing)
|
2004-01-22 10:01:47 +00:00
|
|
|
COPTFLAGS+= -fno-strict-aliasing
|
|
|
|
.endif
|
2001-11-02 21:34:20 +00:00
|
|
|
.if !defined(NO_CPU_COPTFLAGS)
|
|
|
|
COPTFLAGS+= ${_CPUCFLAGS}
|
This are the build infrastructure changes to allow to use the
Intel C/C++ compiler (lang/icc) to build the kernel.
The icc CPUTYPE CFLAGS use icc v7 syntax, icc v8 moans about them, but
doesn't abort. They also produce CPU specific code (new instructions
of the CPU, not only CPU specific scheduling), so if you get coredumps
with signal 4 (SIGILL, illegal instruction) you've used the wrong
CPUTYPE.
Incarnations of this patch survive gcc compiles and my make universe.
I use it on my desktop.
To use it update share/mk, add
/usr/local/intel/compiler70/ia32/bin (icc v7, works)
or
/usr/local/intel_cc_80/bin (icc v8, doesn't work)
to your PATH, make sure you have a new kernel compile directory
(e.g. MYKERNEL_icc) and run
CFLAGS="-O2 -ip" CC=icc make depend
CFLAGS="-O2 -ip" CC=icc make
in it.
Don't compile with -ipo, the build infrastructure uses ld directly to
link the kernel and the modules, but -ipo needs the link step to be
performed with Intel's linker.
Problems with icc v8:
- panic: npx0 cannot be emulated on an SMP system
- UP: first start of /bin/sh results in a FP exception
Parts of this commit contains suggestions or submissions from
Marius Strobl <marius@alchemy.franken.de>.
Reviewed by: silence on -arch
Submitted by: netchild
2004-03-12 21:36:12 +00:00
|
|
|
.endif
|
|
|
|
NOSTDINC= -nostdinc
|
|
|
|
|
2018-05-10 17:55:24 +00:00
|
|
|
INCLUDES= ${NOSTDINC} ${INCLMAGIC} -I. -I$S -I$S/contrib/ck/include
|
2001-11-02 21:34:20 +00:00
|
|
|
|
2015-04-28 23:54:55 +00:00
|
|
|
CFLAGS= ${COPTFLAGS} ${DEBUG}
|
2005-10-05 10:05:55 +00:00
|
|
|
CFLAGS+= ${INCLUDES} -D_KERNEL -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h
|
2013-11-06 05:26:15 +00:00
|
|
|
CFLAGS_PARAM_INLINE_UNIT_GROWTH?=100
|
|
|
|
CFLAGS_PARAM_LARGE_FUNCTION_GROWTH?=1000
|
2020-04-07 17:04:24 +00:00
|
|
|
CFLAGS.gcc+= -fms-extensions -finline-limit=${INLINE_LIMIT}
|
2014-05-10 16:38:09 +00:00
|
|
|
CFLAGS.gcc+= --param inline-unit-growth=${CFLAGS_PARAM_INLINE_UNIT_GROWTH}
|
|
|
|
CFLAGS.gcc+= --param large-function-growth=${CFLAGS_PARAM_LARGE_FUNCTION_GROWTH}
|
2018-08-21 03:45:09 +00:00
|
|
|
CFLAGS.gcc+= -fms-extensions
|
2013-11-06 05:26:15 +00:00
|
|
|
.if defined(CFLAGS_ARCH_PARAMS)
|
2014-05-10 16:38:09 +00:00
|
|
|
CFLAGS.gcc+=${CFLAGS_ARCH_PARAMS}
|
2010-07-22 21:31:35 +00:00
|
|
|
.endif
|
2019-08-23 16:42:04 +00:00
|
|
|
WERROR?= -Werror
|
2020-04-07 17:04:24 +00:00
|
|
|
# The following should be removed no earlier than LLVM11 being imported into the
|
|
|
|
# tree, to ensure we don't regress the build. LLVM11 and GCC10 will switch the
|
|
|
|
# default over to -fno-common, making this redundant.
|
|
|
|
CFLAGS+= -fno-common
|
2001-11-02 21:34:20 +00:00
|
|
|
|
|
|
|
# XXX LOCORE means "don't declare C stuff" not "for locore.s".
|
2021-12-06 23:10:12 +00:00
|
|
|
ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS} ${ASM_CFLAGS.${.IMPSRC:T}}
|
2012-02-28 18:30:18 +00:00
|
|
|
|
2021-12-06 23:11:10 +00:00
|
|
|
COMPAT_FREEBSD32_ENABLED!= grep COMPAT_FREEBSD32 opt_global.h || true ; echo
|
|
|
|
|
2021-04-13 20:29:47 +00:00
|
|
|
KASAN_ENABLED!= grep KASAN opt_global.h || true ; echo
|
|
|
|
.if !empty(KASAN_ENABLED)
|
2021-07-19 20:09:42 +00:00
|
|
|
SAN_CFLAGS+= -DSAN_NEEDS_INTERCEPTORS -DSAN_INTERCEPTOR_PREFIX=kasan \
|
|
|
|
-fsanitize=kernel-address \
|
2021-04-13 20:29:47 +00:00
|
|
|
-mllvm -asan-stack=true \
|
|
|
|
-mllvm -asan-instrument-dynamic-allocas=true \
|
|
|
|
-mllvm -asan-globals=true \
|
|
|
|
-mllvm -asan-use-after-scope=true \
|
2021-11-03 16:28:48 +00:00
|
|
|
-mllvm -asan-instrumentation-with-call-threshold=0 \
|
|
|
|
-mllvm -asan-instrument-byval=false
|
arm64: add KASAN support
This entails:
- Marking some obvious candidates for __nosanitizeaddress
- Similar trap frame markings as amd64, for similar reasons
- Shadow map implementation
The shadow map implementation is roughly similar to what was done on
amd64, with some exceptions. Attempting to use available space at
preinit_map_va + PMAP_PREINIT_MAPPING_SIZE (up to the end of that range,
as depicted in the physmap) results in odd failures, so we instead
search the physmap for free regions that we can carve out, fragmenting
the shadow map as necessary to try and fit as much as we need for the
initial kernel map. pmap_bootstrap_san() is thus after
pmap_bootstrap(), which still included some technically reserved areas
of the memory map that needed to be included in the DMAP.
The odd failure noted above may be a bug, but I haven't investigated it
all that much.
Initial work by mhorne with additional fixes from kevans and markj.
Reviewed by: andrew, markj
Sponsored by: Juniper Networks, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D36701
2023-03-23 21:26:06 +00:00
|
|
|
|
|
|
|
.if ${MACHINE_CPUARCH} == "aarch64"
|
|
|
|
# KASAN/ARM64 TODO: -asan-mapping-offset is calculated from:
|
|
|
|
# (VM_KERNEL_MIN_ADDRESS >> KASAN_SHADOW_SCALE_SHIFT) + $offset = KASAN_MIN_ADDRESS
|
|
|
|
#
|
|
|
|
# This is different than amd64, where we have a different
|
|
|
|
# KASAN_MIN_ADDRESS, and this offset value should eventually be
|
|
|
|
# upstreamed similar to: https://reviews.llvm.org/D98285
|
|
|
|
#
|
|
|
|
SAN_CFLAGS+= -mllvm -asan-mapping-offset=0xdfff208000000000
|
|
|
|
.endif
|
2021-04-13 20:29:47 +00:00
|
|
|
.endif
|
|
|
|
|
2019-11-21 11:22:08 +00:00
|
|
|
KCSAN_ENABLED!= grep KCSAN opt_global.h || true ; echo
|
|
|
|
.if !empty(KCSAN_ENABLED)
|
2021-07-19 20:09:42 +00:00
|
|
|
SAN_CFLAGS+= -DSAN_NEEDS_INTERCEPTORS -DSAN_INTERCEPTOR_PREFIX=kcsan \
|
|
|
|
-fsanitize=thread
|
2019-11-21 11:22:08 +00:00
|
|
|
.endif
|
|
|
|
|
2021-08-10 19:51:03 +00:00
|
|
|
KMSAN_ENABLED!= grep KMSAN opt_global.h || true ; echo
|
|
|
|
.if !empty(KMSAN_ENABLED)
|
|
|
|
SAN_CFLAGS+= -DSAN_NEEDS_INTERCEPTORS -DSAN_INTERCEPTOR_PREFIX=kmsan \
|
|
|
|
-fsanitize=kernel-memory
|
|
|
|
.endif
|
|
|
|
|
2018-11-06 17:32:07 +00:00
|
|
|
KUBSAN_ENABLED!= grep KUBSAN opt_global.h || true ; echo
|
|
|
|
.if !empty(KUBSAN_ENABLED)
|
|
|
|
SAN_CFLAGS+= -fsanitize=undefined
|
|
|
|
.endif
|
Add support for the Clang Coverage Sanitizer in the kernel (KCOV).
When building with KCOV enabled the compiler will insert function calls
to probes allowing us to trace the execution of the kernel from userspace.
These probes are on function entry (trace-pc) and on comparison operations
(trace-cmp).
Userspace can enable the use of these probes on a single kernel thread with
an ioctl interface. It can allocate space for the probe with KIOSETBUFSIZE,
then mmap the allocated buffer and enable tracing with KIOENABLE, with the
trace mode being passed in as the int argument. When complete KIODISABLE
is used to disable tracing.
The first item in the buffer is the number of trace event that have
happened. Userspace can write 0 to this to reset the tracing, and is
expected to do so on first use.
The format of the buffer depends on the trace mode. When in PC tracing just
the return address of the probe is stored. Under comparison tracing the
comparison type, the two arguments, and the return address are traced. The
former method uses on entry per trace event, while the later uses 4. As
such they are incompatible so only a single mode may be enabled.
KCOV is expected to help fuzzing the kernel, and while in development has
already found a number of issues. It is required for the syzkaller system
call fuzzer [1]. Other kernel fuzzers could also make use of it, either
with the current interface, or by extending it with new modes.
A man page is currently being worked on and is expected to be committed
soon, however having the code in the kernel now is useful for other
developers to use.
[1] https://github.com/google/syzkaller
Submitted by: Mitchell Horne <mhorne063@gmail.com> (Earlier version)
Reviewed by: kib
Testing by: tuexen
Sponsored by: DARPA, AFRL
Sponsored by: The FreeBSD Foundation (Mitchell Horne)
Differential Revision: https://reviews.freebsd.org/D14599
2019-01-12 11:21:28 +00:00
|
|
|
|
2019-01-29 11:04:17 +00:00
|
|
|
COVERAGE_ENABLED!= grep COVERAGE opt_global.h || true ; echo
|
|
|
|
.if !empty(COVERAGE_ENABLED)
|
2019-02-04 16:55:24 +00:00
|
|
|
.if ${COMPILER_TYPE} == "clang" || \
|
|
|
|
(${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 80100)
|
Add support for the Clang Coverage Sanitizer in the kernel (KCOV).
When building with KCOV enabled the compiler will insert function calls
to probes allowing us to trace the execution of the kernel from userspace.
These probes are on function entry (trace-pc) and on comparison operations
(trace-cmp).
Userspace can enable the use of these probes on a single kernel thread with
an ioctl interface. It can allocate space for the probe with KIOSETBUFSIZE,
then mmap the allocated buffer and enable tracing with KIOENABLE, with the
trace mode being passed in as the int argument. When complete KIODISABLE
is used to disable tracing.
The first item in the buffer is the number of trace event that have
happened. Userspace can write 0 to this to reset the tracing, and is
expected to do so on first use.
The format of the buffer depends on the trace mode. When in PC tracing just
the return address of the probe is stored. Under comparison tracing the
comparison type, the two arguments, and the return address are traced. The
former method uses on entry per trace event, while the later uses 4. As
such they are incompatible so only a single mode may be enabled.
KCOV is expected to help fuzzing the kernel, and while in development has
already found a number of issues. It is required for the syzkaller system
call fuzzer [1]. Other kernel fuzzers could also make use of it, either
with the current interface, or by extending it with new modes.
A man page is currently being worked on and is expected to be committed
soon, however having the code in the kernel now is useful for other
developers to use.
[1] https://github.com/google/syzkaller
Submitted by: Mitchell Horne <mhorne063@gmail.com> (Earlier version)
Reviewed by: kib
Testing by: tuexen
Sponsored by: DARPA, AFRL
Sponsored by: The FreeBSD Foundation (Mitchell Horne)
Differential Revision: https://reviews.freebsd.org/D14599
2019-01-12 11:21:28 +00:00
|
|
|
SAN_CFLAGS+= -fsanitize-coverage=trace-pc,trace-cmp
|
2019-02-04 16:55:24 +00:00
|
|
|
.else
|
|
|
|
SAN_CFLAGS+= -fsanitize-coverage=trace-pc
|
|
|
|
.endif
|
Add support for the Clang Coverage Sanitizer in the kernel (KCOV).
When building with KCOV enabled the compiler will insert function calls
to probes allowing us to trace the execution of the kernel from userspace.
These probes are on function entry (trace-pc) and on comparison operations
(trace-cmp).
Userspace can enable the use of these probes on a single kernel thread with
an ioctl interface. It can allocate space for the probe with KIOSETBUFSIZE,
then mmap the allocated buffer and enable tracing with KIOENABLE, with the
trace mode being passed in as the int argument. When complete KIODISABLE
is used to disable tracing.
The first item in the buffer is the number of trace event that have
happened. Userspace can write 0 to this to reset the tracing, and is
expected to do so on first use.
The format of the buffer depends on the trace mode. When in PC tracing just
the return address of the probe is stored. Under comparison tracing the
comparison type, the two arguments, and the return address are traced. The
former method uses on entry per trace event, while the later uses 4. As
such they are incompatible so only a single mode may be enabled.
KCOV is expected to help fuzzing the kernel, and while in development has
already found a number of issues. It is required for the syzkaller system
call fuzzer [1]. Other kernel fuzzers could also make use of it, either
with the current interface, or by extending it with new modes.
A man page is currently being worked on and is expected to be committed
soon, however having the code in the kernel now is useful for other
developers to use.
[1] https://github.com/google/syzkaller
Submitted by: Mitchell Horne <mhorne063@gmail.com> (Earlier version)
Reviewed by: kib
Testing by: tuexen
Sponsored by: DARPA, AFRL
Sponsored by: The FreeBSD Foundation (Mitchell Horne)
Differential Revision: https://reviews.freebsd.org/D14599
2019-01-12 11:21:28 +00:00
|
|
|
.endif
|
|
|
|
|
2018-11-06 17:32:07 +00:00
|
|
|
CFLAGS+= ${SAN_CFLAGS}
|
|
|
|
|
2019-02-23 21:14:00 +00:00
|
|
|
GCOV_ENABLED!= grep GCOV opt_global.h || true ; echo
|
|
|
|
.if !empty(GCOV_ENABLED)
|
|
|
|
.if ${COMPILER_TYPE} == "gcc"
|
|
|
|
GCOV_CFLAGS+= -fprofile-arcs -ftest-coverage
|
|
|
|
.endif
|
|
|
|
.endif
|
|
|
|
|
|
|
|
CFLAGS+= ${GCOV_CFLAGS}
|
|
|
|
|
2021-03-31 21:04:55 +00:00
|
|
|
# Put configuration-specific C flags last so that they can override
|
|
|
|
# the others.
|
2001-11-02 21:34:20 +00:00
|
|
|
CFLAGS+= ${CONF_CFLAGS}
|
|
|
|
|
2017-07-05 19:43:16 +00:00
|
|
|
.if defined(LINKER_FEATURES) && ${LINKER_FEATURES:Mbuild-id}
|
2019-05-14 18:10:32 +00:00
|
|
|
LDFLAGS+= --build-id=sha1
|
2017-06-23 15:57:58 +00:00
|
|
|
.endif
|
|
|
|
|
2018-10-01 18:51:08 +00:00
|
|
|
.if (${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "amd64" || \
|
2020-05-07 19:32:49 +00:00
|
|
|
${MACHINE_CPUARCH} == "i386" || ${MACHINE} == "powerpc") && \
|
2020-12-27 00:34:24 +00:00
|
|
|
defined(LINKER_FEATURES) && ${LINKER_FEATURES:Mifunc} == "" && \
|
|
|
|
!make(install)
|
2020-05-07 19:32:49 +00:00
|
|
|
.error amd64/arm64/i386/ppc* kernel requires linker ifunc support
|
2018-05-10 20:10:02 +00:00
|
|
|
.endif
|
2018-09-18 15:01:21 +00:00
|
|
|
.if ${MACHINE_CPUARCH} == "amd64"
|
2019-05-14 18:10:32 +00:00
|
|
|
LDFLAGS+= -z max-page-size=2097152
|
2018-08-04 16:56:39 +00:00
|
|
|
.if ${LINKER_TYPE} != "lld"
|
2019-05-14 18:10:32 +00:00
|
|
|
LDFLAGS+= -z common-page-size=4096
|
2018-08-24 18:09:23 +00:00
|
|
|
.else
|
2020-08-11 16:47:00 +00:00
|
|
|
.if defined(LINKER_FEATURES) && !${LINKER_FEATURES:Mifunc-noplt}
|
|
|
|
.warning "Linker ${LD} does not support -z ifunc-noplt -> ifunc calls are unoptimized."
|
|
|
|
.else
|
2019-05-14 18:26:39 +00:00
|
|
|
LDFLAGS+= -z notext -z ifunc-noplt
|
2018-08-04 16:56:39 +00:00
|
|
|
.endif
|
2018-03-06 14:18:45 +00:00
|
|
|
.endif
|
2020-08-11 16:47:00 +00:00
|
|
|
.endif # ${MACHINE_CPUARCH} == "amd64"
|
2018-03-06 14:18:45 +00:00
|
|
|
|
2020-01-07 23:18:31 +00:00
|
|
|
.if ${MACHINE_CPUARCH} == "riscv"
|
|
|
|
# Hack: Work around undefined weak symbols being out of range when linking with
|
|
|
|
# LLD (address is a PC-relative calculation, and BFD works around this by
|
|
|
|
# rewriting the instructions to generate an absolute address of 0); -fPIE
|
|
|
|
# avoids this since it uses the GOT for all extern symbols, which is overly
|
|
|
|
# inefficient for us. Drop once undefined weak symbols work with medany.
|
|
|
|
.if ${LINKER_TYPE} == "lld"
|
|
|
|
CFLAGS+= -fPIE
|
|
|
|
.endif
|
|
|
|
.endif
|
|
|
|
|
2021-03-31 21:04:55 +00:00
|
|
|
NORMAL_C= ${CC} -c ${CFLAGS} ${WERROR} ${.IMPSRC}
|
Add built-in ccache build support via WITH_CCACHE_BUILD option.
ccache is mostly beneficial for frequent builds where -DNO_CLEAN is not
used to achieve a safe pseudo-incremental build. This is explained in
more detail upstream [1] [2]. It incurs about a 20%-28% hit to populate the
cache, but with a full cache saves 30-50% in build times. When combined with
the WITH_FAST_DEPEND feature it saves up to 65% since ccache does cache the
resulting dependency file, which it does not do when using mkdep(1)/'CC
-E'. Stats are provided at the end of this message.
This removes the need to modify /etc/make.conf with the CC:= and CXX:=
lines which conflicted with external compiler support [3] (causing the
bootstrap compiler to not be built which lead to obscure failures [4]),
incorrectly invoked ccache in various stages, required CCACHE_CPP2 to avoid
Clang errors with parenthesis, and did not work with META_MODE.
The option name was picked to match the existing option in ports. This
feature is available for both in-src and out-of-src builds that use
/usr/share/mk.
Linking, assembly compiles, and pre-processing avoid using ccache since it is
only overhead. ccache does nothing special in these modes, although there is
no harm in calling it for them.
CCACHE_COMPILERCHECK is set to 'content' when using the in-tree bootstrap
compiler to hash the content of the compiler binary to determine if it
should be a cache miss. For external compilers the 'mtime' option is used
as it is more efficient and likely to be correct. Future work may optimize the
'content' check using the same checks as whether a bootstrap compiler is needed
to be built.
The CCACHE_CPP2 pessimization is currently default in our devel/ccache
port due to Clang requiring it. Clang's -Wparentheses-equality,
-Wtautological-compare, and -Wself-assign warnings do not mix well with
compiling already-pre-processed code that may have expanded macros that
trigger the warnings. GCC has so far not had this issue so it is allowed to
disable the CCACHE_CPP2 default in our port.
Sharing a cache between multiple checkouts, or systems, is explained in
the ccache manual. Sharing a cache over NFS would likely not be worth
it, but syncing cache directories between systems may be useful for an
organization. There is also a memcached backend available [5]. Due to using
an object directory outside of the source directory though you will need to
ensure that both are in the same prefix and all users use the same layout. A
possible working layout is as follows:
Source: /some/prefix/src1
Source: /some/prefix/src2
Source: /some/prefix/src3
Objdir: /some/prefix/obj
Environment: CCACHE_BASEDIR='${SRCTOP:H}' MAKEOBJDIRPREFIX='${SRCTOP:H}/obj'
This will use src*/../obj as the MAKEOBJDIRPREFIX and tells ccache to replace
all absolute paths to be relative. Using something like this is required due
to -I and -o flags containing both SRC and OBJDIR absolute paths that ccache
adds into its hash for the object without CCACHE_BASEDIR.
distcc can be hooked into by setting CCACHE_PREFIX=/usr/local/bin/distcc.
I have not personally tested this and assume it will not mix well with
using the bootstrap compiler.
The cache from buildworld can be reused in a subdir by first running
'make buildenv' (from r290424).
Note that the cache is currently different depending on whether -j is
used or not due to ccache enabling -fdiagnostics-color automatically if
stderr is a TTY, which bmake only does if not using -j.
The system I used for testing was:
WITNESS
Build options: -j20 WITH_LLDB=yes WITH_DEBUG_FILES=yes WITH_CCACHE_BUILD=yes
DISK: ZFS 3-way mirror with very slow disks using SSD l2arc/log.
The arc was fully populated with src tree files and ccache objects.
RAM: 76GiB
CPU: Intel(R) Xeon(R) CPU L5520 @2.27GHz
2 package(s) x 4 core(s) x 2 SMT threads = hw.ncpu=16
The WITH_FAST_DEPEND feature was used for comparison here as well to show
the dramatic time savings with a full cache.
buildworld:
x buildworld-before
+ buildworld-ccache-empty
* buildworld-ccache-full
% buildworld-ccache-full-fastdep
# buildworld-fastdep
+-------------------------------------------------------------------------------+
|% * # +|
|% * # +|
|% * # xxx +|
| |A |
| A|
| A |
|A |
| A |
+-------------------------------------------------------------------------------+
N Min Max Median Avg Stddev
x 3 3744.13 3794.31 3752.25 3763.5633 26.935139
+ 3 4519 4525.04 4520.73 4521.59 3.1104823
Difference at 95.0% confidence
758.027 +/- 43.4565
20.1412% +/- 1.15466%
(Student's t, pooled s = 19.1726)
* 3 1823.08 1827.2 1825.62 1825.3 2.0785572
Difference at 95.0% confidence
-1938.26 +/- 43.298
-51.5007% +/- 1.15045%
(Student's t, pooled s = 19.1026)
% 3 1266.96 1279.37 1270.47 1272.2667 6.3971113
Difference at 95.0% confidence
-2491.3 +/- 44.3704
-66.1952% +/- 1.17895%
(Student's t, pooled s = 19.5758)
# 3 3153.34 3155.16 3154.2 3154.2333 0.91045776
Difference at 95.0% confidence
-609.33 +/- 43.1943
-16.1902% +/- 1.1477%
(Student's t, pooled s = 19.0569)
buildkernel:
x buildkernel-before
+ buildkernel-ccache-empty
* buildkernel-ccache-empty-fastdep
% buildkernel-ccache-full
# buildkernel-ccache-full-fastdep
@ buildkernel-fastdep
+-------------------------------------------------------------------------------+
|# @ % * |
|# @ % * x + |
|# @ % * xx ++|
| MA |
| MA|
| A |
| A |
|A |
| A |
+-------------------------------------------------------------------------------+
N Min Max Median Avg Stddev
x 3 571.57 573.94 571.79 572.43333 1.3094401
+ 3 727.97 731.91 728.06 729.31333 2.2492295
Difference at 95.0% confidence
156.88 +/- 4.17129
27.4058% +/- 0.728695%
(Student's t, pooled s = 1.84034)
* 3 527.1 528.29 528.08 527.82333 0.63516402
Difference at 95.0% confidence
-44.61 +/- 2.33254
-7.79305% +/- 0.407478%
(Student's t, pooled s = 1.02909)
% 3 400.4 401.05 400.62 400.69 0.3306055
Difference at 95.0% confidence
-171.743 +/- 2.16453
-30.0023% +/- 0.378128%
(Student's t, pooled s = 0.954969)
# 3 201.94 203.34 202.28 202.52 0.73020545
Difference at 95.0% confidence
-369.913 +/- 2.40293
-64.6212% +/- 0.419774%
(Student's t, pooled s = 1.06015)
@ 3 369.12 370.57 369.3 369.66333 0.79033748
Difference at 95.0% confidence
-202.77 +/- 2.45131
-35.4225% +/- 0.428227%
(Student's t, pooled s = 1.0815)
[1] https://ccache.samba.org/performance.html
[2] http://www.mail-archive.com/ccache@lists.samba.org/msg00576.html
[3] https://reviews.freebsd.org/D3484
[5] https://github.com/jrosdahl/ccache/pull/30
PR: 182944 [4]
MFC after: 3 weeks
Sponsored by: EMC / Isilon Storage Division
Relnotes: yes
2015-11-08 00:50:18 +00:00
|
|
|
NORMAL_S= ${CC:N${CCACHE_BIN}} -c ${ASM_CFLAGS} ${WERROR} ${.IMPSRC}
|
2021-03-31 21:04:55 +00:00
|
|
|
NORMAL_C_NOWERROR= ${CC} -c ${CFLAGS} ${.IMPSRC}
|
2001-11-02 21:34:20 +00:00
|
|
|
|
2002-10-19 16:47:13 +00:00
|
|
|
NORMAL_M= ${AWK} -f $S/tools/makeobjops.awk ${.IMPSRC} -c ; \
|
2021-03-31 21:04:55 +00:00
|
|
|
${CC} -c ${CFLAGS} ${WERROR} ${.PREFIX}.c
|
2001-11-02 21:34:20 +00:00
|
|
|
|
2012-08-31 21:10:38 +00:00
|
|
|
NORMAL_FW= uudecode -o ${.TARGET} ${.ALLSRC}
|
2020-12-17 20:31:17 +00:00
|
|
|
NORMAL_FWO= ${CC:N${CCACHE_BIN}} -c ${ASM_CFLAGS} ${WERROR} -o ${.TARGET} \
|
Pre-quote macros passed to .incbin to avoid unwanted substitution
Currently for the MFS, firmware and VDSO template assembly files we pass
the path to include with .incbin unquoted and use __XSTRING within the
assembly file to stringify it. However, __XSTRING doesn't just perform a
single level of expansion, it performs the normal full expansion of the
macro, and so if the path itself happens to tokenise to something that
includes a defined macro in it that will itself be substituted. For
example, with #define MACRO 1, a path like /path/containing/MACRO/in/it
will expand to /path/containing/1/in/it and then, when stringified, end
up as "/path/containing/1/in/it", not the intended string. Normally,
macros have names that start or end witih underscores and are unlikely
to appear in a tokenised path (even if technically they could), but now
that we've switched to GNU C as of commit ec41a96daaa6 ("sys: Switch the
kernel's C standard from C99 to GNU99.") there are a few new macros
defined which don't start or end with underscores: unix, which is always
defined to 1, and i386, which is defined to 1 on i386. The former
probably doesn't appear in user paths in practice, but the latter has
been seen to and is likely quite common in the wild.
Fix this by defining the macro pre-quoted instead of using __XSTRING.
Note that technically we don't need to do this for vdso_wrap.S today as
all the paths passed to it are safe file names with no user-controlled
prefix but we should do it anyway for consistency and robustness against
future changes.
This allows make tinderbox to pass when built with source and object
directories inside ~/path-with-unix, which would otherwise expand to
~/path-with-1 and break.
PR: 272744
Fixes: ec41a96daaa6 ("sys: Switch the kernel's C standard from C99 to GNU99.")
2023-07-28 04:08:43 +00:00
|
|
|
$S/kern/firmw.S -DFIRMW_FILE=\""${.ALLSRC:M*.fw}"\" \
|
2020-12-17 20:31:17 +00:00
|
|
|
-DFIRMW_SYMBOL="${.ALLSRC:M*.fw:C/[-.\/]/_/g}"
|
2012-08-31 20:54:30 +00:00
|
|
|
|
2018-01-08 20:14:16 +00:00
|
|
|
# for ZSTD in the kernel (include zstd/lib/freebsd before other CFLAGS)
|
2020-12-25 15:42:41 +00:00
|
|
|
ZSTD_C= ${CC} -c -DZSTD_HEAPMODE=1 -I$S/contrib/zstd/lib/freebsd ${CFLAGS} \
|
|
|
|
-I$S/contrib/zstd/lib -I$S/contrib/zstd/lib/common ${WERROR} \
|
2021-03-31 21:04:55 +00:00
|
|
|
-Wno-missing-prototypes -U__BMI__ -DZSTD_NO_INTRINSICS ${.IMPSRC}
|
2019-08-08 16:54:22 +00:00
|
|
|
# https://github.com/facebook/zstd/commit/812e8f2a [zstd 1.4.1]
|
|
|
|
# "Note that [GCC] autovectorization still does not do a good job on the
|
|
|
|
# optimized version, so it's turned off via attribute and flag. I found
|
|
|
|
# that neither attribute nor command-line flag were entirely successful in
|
|
|
|
# turning off vectorization, which is why there were both."
|
|
|
|
.if ${COMPILER_TYPE} == "gcc"
|
|
|
|
ZSTD_DECOMPRESS_BLOCK_FLAGS= -fno-tree-vectorize
|
|
|
|
.endif
|
2018-01-08 20:14:16 +00:00
|
|
|
|
Merge OpenZFS support in to HEAD.
The primary benefit is maintaining a completely shared
code base with the community allowing FreeBSD to receive
new features sooner and with less effort.
I would advise against doing 'zpool upgrade'
or creating indispensable pools using new
features until this change has had a month+
to soak.
Work on merging FreeBSD support in to what was
at the time "ZFS on Linux" began in August 2018.
I first publicly proposed transitioning FreeBSD
to (new) OpenZFS on December 18th, 2018. FreeBSD
support in OpenZFS was finally completed in December
2019. A CFT for downstreaming OpenZFS support in
to FreeBSD was first issued on July 8th. All issues
that were reported have been addressed or, for
a couple of less critical matters there are
pull requests in progress with OpenZFS. iXsystems
has tested and dogfooded extensively internally.
The TrueNAS 12 release is based on OpenZFS with
some additional features that have not yet made
it upstream.
Improvements include:
project quotas, encrypted datasets,
allocation classes, vectorized raidz,
vectorized checksums, various command line
improvements, zstd compression.
Thanks to those who have helped along the way:
Ryan Moeller, Allan Jude, Zack Welch, and many
others.
Sponsored by: iXsystems, Inc.
Differential Revision: https://reviews.freebsd.org/D25872
2020-08-25 02:21:27 +00:00
|
|
|
ZINCDIR=$S/contrib/openzfs/include
|
2015-06-10 15:53:39 +00:00
|
|
|
# Common for dtrace / zfs
|
Merge OpenZFS support in to HEAD.
The primary benefit is maintaining a completely shared
code base with the community allowing FreeBSD to receive
new features sooner and with less effort.
I would advise against doing 'zpool upgrade'
or creating indispensable pools using new
features until this change has had a month+
to soak.
Work on merging FreeBSD support in to what was
at the time "ZFS on Linux" began in August 2018.
I first publicly proposed transitioning FreeBSD
to (new) OpenZFS on December 18th, 2018. FreeBSD
support in OpenZFS was finally completed in December
2019. A CFT for downstreaming OpenZFS support in
to FreeBSD was first issued on July 8th. All issues
that were reported have been addressed or, for
a couple of less critical matters there are
pull requests in progress with OpenZFS. iXsystems
has tested and dogfooded extensively internally.
The TrueNAS 12 release is based on OpenZFS with
some additional features that have not yet made
it upstream.
Improvements include:
project quotas, encrypted datasets,
allocation classes, vectorized raidz,
vectorized checksums, various command line
improvements, zstd compression.
Thanks to those who have helped along the way:
Ryan Moeller, Allan Jude, Zack Welch, and many
others.
Sponsored by: iXsystems, Inc.
Differential Revision: https://reviews.freebsd.org/D25872
2020-08-25 02:21:27 +00:00
|
|
|
CDDL_CFLAGS= \
|
|
|
|
-DFREEBSD_NAMECACHE \
|
|
|
|
-D_SYS_VMEM_H_ \
|
|
|
|
-D__KERNEL \
|
|
|
|
-D__KERNEL__ \
|
|
|
|
-nostdinc \
|
|
|
|
-include $S/modules/zfs/static_ccompile.h \
|
|
|
|
-I${ZINCDIR} \
|
|
|
|
-I${ZINCDIR}/os/freebsd \
|
|
|
|
-I${ZINCDIR}/os/freebsd/spl \
|
|
|
|
-I${ZINCDIR}/os/freebsd/zfs \
|
|
|
|
-I$S/modules/zfs \
|
|
|
|
-I$S/contrib/openzfs/module/zstd/include \
|
|
|
|
${CFLAGS} \
|
|
|
|
-Wno-cast-qual \
|
2020-12-24 20:34:18 +00:00
|
|
|
-Wno-duplicate-decl-specifier \
|
|
|
|
-Wno-missing-braces \
|
|
|
|
-Wno-missing-prototypes \
|
Merge OpenZFS support in to HEAD.
The primary benefit is maintaining a completely shared
code base with the community allowing FreeBSD to receive
new features sooner and with less effort.
I would advise against doing 'zpool upgrade'
or creating indispensable pools using new
features until this change has had a month+
to soak.
Work on merging FreeBSD support in to what was
at the time "ZFS on Linux" began in August 2018.
I first publicly proposed transitioning FreeBSD
to (new) OpenZFS on December 18th, 2018. FreeBSD
support in OpenZFS was finally completed in December
2019. A CFT for downstreaming OpenZFS support in
to FreeBSD was first issued on July 8th. All issues
that were reported have been addressed or, for
a couple of less critical matters there are
pull requests in progress with OpenZFS. iXsystems
has tested and dogfooded extensively internally.
The TrueNAS 12 release is based on OpenZFS with
some additional features that have not yet made
it upstream.
Improvements include:
project quotas, encrypted datasets,
allocation classes, vectorized raidz,
vectorized checksums, various command line
improvements, zstd compression.
Thanks to those who have helped along the way:
Ryan Moeller, Allan Jude, Zack Welch, and many
others.
Sponsored by: iXsystems, Inc.
Differential Revision: https://reviews.freebsd.org/D25872
2020-08-25 02:21:27 +00:00
|
|
|
-Wno-parentheses \
|
2020-12-24 20:34:18 +00:00
|
|
|
-Wno-pointer-arith \
|
|
|
|
-Wno-strict-prototypes \
|
Merge OpenZFS support in to HEAD.
The primary benefit is maintaining a completely shared
code base with the community allowing FreeBSD to receive
new features sooner and with less effort.
I would advise against doing 'zpool upgrade'
or creating indispensable pools using new
features until this change has had a month+
to soak.
Work on merging FreeBSD support in to what was
at the time "ZFS on Linux" began in August 2018.
I first publicly proposed transitioning FreeBSD
to (new) OpenZFS on December 18th, 2018. FreeBSD
support in OpenZFS was finally completed in December
2019. A CFT for downstreaming OpenZFS support in
to FreeBSD was first issued on July 8th. All issues
that were reported have been addressed or, for
a couple of less critical matters there are
pull requests in progress with OpenZFS. iXsystems
has tested and dogfooded extensively internally.
The TrueNAS 12 release is based on OpenZFS with
some additional features that have not yet made
it upstream.
Improvements include:
project quotas, encrypted datasets,
allocation classes, vectorized raidz,
vectorized checksums, various command line
improvements, zstd compression.
Thanks to those who have helped along the way:
Ryan Moeller, Allan Jude, Zack Welch, and many
others.
Sponsored by: iXsystems, Inc.
Differential Revision: https://reviews.freebsd.org/D25872
2020-08-25 02:21:27 +00:00
|
|
|
-Wno-switch \
|
2020-12-24 20:34:18 +00:00
|
|
|
-Wno-undef \
|
|
|
|
-Wno-uninitialized \
|
Merge OpenZFS support in to HEAD.
The primary benefit is maintaining a completely shared
code base with the community allowing FreeBSD to receive
new features sooner and with less effort.
I would advise against doing 'zpool upgrade'
or creating indispensable pools using new
features until this change has had a month+
to soak.
Work on merging FreeBSD support in to what was
at the time "ZFS on Linux" began in August 2018.
I first publicly proposed transitioning FreeBSD
to (new) OpenZFS on December 18th, 2018. FreeBSD
support in OpenZFS was finally completed in December
2019. A CFT for downstreaming OpenZFS support in
to FreeBSD was first issued on July 8th. All issues
that were reported have been addressed or, for
a couple of less critical matters there are
pull requests in progress with OpenZFS. iXsystems
has tested and dogfooded extensively internally.
The TrueNAS 12 release is based on OpenZFS with
some additional features that have not yet made
it upstream.
Improvements include:
project quotas, encrypted datasets,
allocation classes, vectorized raidz,
vectorized checksums, various command line
improvements, zstd compression.
Thanks to those who have helped along the way:
Ryan Moeller, Allan Jude, Zack Welch, and many
others.
Sponsored by: iXsystems, Inc.
Differential Revision: https://reviews.freebsd.org/D25872
2020-08-25 02:21:27 +00:00
|
|
|
-Wno-unknown-pragmas \
|
2020-12-24 20:34:18 +00:00
|
|
|
-Wno-unused \
|
Merge OpenZFS support in to HEAD.
The primary benefit is maintaining a completely shared
code base with the community allowing FreeBSD to receive
new features sooner and with less effort.
I would advise against doing 'zpool upgrade'
or creating indispensable pools using new
features until this change has had a month+
to soak.
Work on merging FreeBSD support in to what was
at the time "ZFS on Linux" began in August 2018.
I first publicly proposed transitioning FreeBSD
to (new) OpenZFS on December 18th, 2018. FreeBSD
support in OpenZFS was finally completed in December
2019. A CFT for downstreaming OpenZFS support in
to FreeBSD was first issued on July 8th. All issues
that were reported have been addressed or, for
a couple of less critical matters there are
pull requests in progress with OpenZFS. iXsystems
has tested and dogfooded extensively internally.
The TrueNAS 12 release is based on OpenZFS with
some additional features that have not yet made
it upstream.
Improvements include:
project quotas, encrypted datasets,
allocation classes, vectorized raidz,
vectorized checksums, various command line
improvements, zstd compression.
Thanks to those who have helped along the way:
Ryan Moeller, Allan Jude, Zack Welch, and many
others.
Sponsored by: iXsystems, Inc.
Differential Revision: https://reviews.freebsd.org/D25872
2020-08-25 02:21:27 +00:00
|
|
|
-include ${ZINCDIR}/os/freebsd/spl/sys/ccompile.h \
|
|
|
|
-I$S/cddl/contrib/opensolaris/uts/common \
|
|
|
|
-I$S -I$S/cddl/compat/opensolaris
|
2021-03-31 21:04:55 +00:00
|
|
|
CDDL_C= ${CC} -c ${CDDL_CFLAGS} ${WERROR} ${.IMPSRC}
|
2015-06-10 15:53:39 +00:00
|
|
|
|
2012-03-27 21:23:56 +00:00
|
|
|
# Special flags for managing the compat compiles for ZFS
|
2022-11-16 20:25:24 +00:00
|
|
|
ZFS_CFLAGS+= -I$S/contrib/openzfs/module/icp/include \
|
|
|
|
${CDDL_CFLAGS} -DBUILDING_ZFS -DHAVE_UIO_ZEROCOPY \
|
2023-07-17 09:12:53 +00:00
|
|
|
-DWITH_NETDUMP -D__KERNEL__ -D_SYS_CONDVAR_H_ -DSMP
|
Merge OpenZFS support in to HEAD.
The primary benefit is maintaining a completely shared
code base with the community allowing FreeBSD to receive
new features sooner and with less effort.
I would advise against doing 'zpool upgrade'
or creating indispensable pools using new
features until this change has had a month+
to soak.
Work on merging FreeBSD support in to what was
at the time "ZFS on Linux" began in August 2018.
I first publicly proposed transitioning FreeBSD
to (new) OpenZFS on December 18th, 2018. FreeBSD
support in OpenZFS was finally completed in December
2019. A CFT for downstreaming OpenZFS support in
to FreeBSD was first issued on July 8th. All issues
that were reported have been addressed or, for
a couple of less critical matters there are
pull requests in progress with OpenZFS. iXsystems
has tested and dogfooded extensively internally.
The TrueNAS 12 release is based on OpenZFS with
some additional features that have not yet made
it upstream.
Improvements include:
project quotas, encrypted datasets,
allocation classes, vectorized raidz,
vectorized checksums, various command line
improvements, zstd compression.
Thanks to those who have helped along the way:
Ryan Moeller, Allan Jude, Zack Welch, and many
others.
Sponsored by: iXsystems, Inc.
Differential Revision: https://reviews.freebsd.org/D25872
2020-08-25 02:21:27 +00:00
|
|
|
|
|
|
|
.if ${MACHINE_ARCH} == "amd64"
|
2022-06-23 17:42:55 +00:00
|
|
|
ZFS_CFLAGS+= -D__x86_64 -DHAVE_SSE2 -DHAVE_SSSE3 -DHAVE_SSE4_1 -DHAVE_SSE4_2 \
|
|
|
|
-DHAVE_AVX -DHAVE_AVX2 -DHAVE_AVX512F -DHAVE_AVX512VL -DHAVE_AVX512BW
|
Merge OpenZFS support in to HEAD.
The primary benefit is maintaining a completely shared
code base with the community allowing FreeBSD to receive
new features sooner and with less effort.
I would advise against doing 'zpool upgrade'
or creating indispensable pools using new
features until this change has had a month+
to soak.
Work on merging FreeBSD support in to what was
at the time "ZFS on Linux" began in August 2018.
I first publicly proposed transitioning FreeBSD
to (new) OpenZFS on December 18th, 2018. FreeBSD
support in OpenZFS was finally completed in December
2019. A CFT for downstreaming OpenZFS support in
to FreeBSD was first issued on July 8th. All issues
that were reported have been addressed or, for
a couple of less critical matters there are
pull requests in progress with OpenZFS. iXsystems
has tested and dogfooded extensively internally.
The TrueNAS 12 release is based on OpenZFS with
some additional features that have not yet made
it upstream.
Improvements include:
project quotas, encrypted datasets,
allocation classes, vectorized raidz,
vectorized checksums, various command line
improvements, zstd compression.
Thanks to those who have helped along the way:
Ryan Moeller, Allan Jude, Zack Welch, and many
others.
Sponsored by: iXsystems, Inc.
Differential Revision: https://reviews.freebsd.org/D25872
2020-08-25 02:21:27 +00:00
|
|
|
.endif
|
|
|
|
|
|
|
|
.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "powerpc" || \
|
2020-08-25 19:04:54 +00:00
|
|
|
${MACHINE_ARCH} == "powerpcspe" || ${MACHINE_ARCH} == "arm"
|
Merge OpenZFS support in to HEAD.
The primary benefit is maintaining a completely shared
code base with the community allowing FreeBSD to receive
new features sooner and with less effort.
I would advise against doing 'zpool upgrade'
or creating indispensable pools using new
features until this change has had a month+
to soak.
Work on merging FreeBSD support in to what was
at the time "ZFS on Linux" began in August 2018.
I first publicly proposed transitioning FreeBSD
to (new) OpenZFS on December 18th, 2018. FreeBSD
support in OpenZFS was finally completed in December
2019. A CFT for downstreaming OpenZFS support in
to FreeBSD was first issued on July 8th. All issues
that were reported have been addressed or, for
a couple of less critical matters there are
pull requests in progress with OpenZFS. iXsystems
has tested and dogfooded extensively internally.
The TrueNAS 12 release is based on OpenZFS with
some additional features that have not yet made
it upstream.
Improvements include:
project quotas, encrypted datasets,
allocation classes, vectorized raidz,
vectorized checksums, various command line
improvements, zstd compression.
Thanks to those who have helped along the way:
Ryan Moeller, Allan Jude, Zack Welch, and many
others.
Sponsored by: iXsystems, Inc.
Differential Revision: https://reviews.freebsd.org/D25872
2020-08-25 02:21:27 +00:00
|
|
|
ZFS_CFLAGS+= -DBITS_PER_LONG=32
|
|
|
|
.else
|
|
|
|
ZFS_CFLAGS+= -DBITS_PER_LONG=64
|
|
|
|
.endif
|
|
|
|
|
|
|
|
|
2012-03-27 21:23:56 +00:00
|
|
|
ZFS_ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${ZFS_CFLAGS}
|
2021-03-31 21:04:55 +00:00
|
|
|
ZFS_C= ${CC} -c ${ZFS_CFLAGS} ${WERROR} ${.IMPSRC}
|
|
|
|
ZFS_RPC_C= ${CC} -c ${ZFS_CFLAGS} -DHAVE_RPC_TYPES ${WERROR} ${.IMPSRC}
|
2012-03-27 21:23:56 +00:00
|
|
|
ZFS_S= ${CC} -c ${ZFS_ASM_CFLAGS} ${WERROR} ${.IMPSRC}
|
|
|
|
|
2022-03-01 00:26:00 +00:00
|
|
|
# ATH driver
|
2022-03-02 05:54:58 +00:00
|
|
|
ATH_CFLAGS= -I${SRCTOP}/sys/dev/ath ${NO_WUNUSED_BUT_SET_VARIABLE}
|
2022-03-01 00:26:00 +00:00
|
|
|
ATH_C= ${CC} -c ${CFLAGS} ${WERROR} ${ATH_CFLAGS} ${.IMPSRC}
|
Merge OpenZFS support in to HEAD.
The primary benefit is maintaining a completely shared
code base with the community allowing FreeBSD to receive
new features sooner and with less effort.
I would advise against doing 'zpool upgrade'
or creating indispensable pools using new
features until this change has had a month+
to soak.
Work on merging FreeBSD support in to what was
at the time "ZFS on Linux" began in August 2018.
I first publicly proposed transitioning FreeBSD
to (new) OpenZFS on December 18th, 2018. FreeBSD
support in OpenZFS was finally completed in December
2019. A CFT for downstreaming OpenZFS support in
to FreeBSD was first issued on July 8th. All issues
that were reported have been addressed or, for
a couple of less critical matters there are
pull requests in progress with OpenZFS. iXsystems
has tested and dogfooded extensively internally.
The TrueNAS 12 release is based on OpenZFS with
some additional features that have not yet made
it upstream.
Improvements include:
project quotas, encrypted datasets,
allocation classes, vectorized raidz,
vectorized checksums, various command line
improvements, zstd compression.
Thanks to those who have helped along the way:
Ryan Moeller, Allan Jude, Zack Welch, and many
others.
Sponsored by: iXsystems, Inc.
Differential Revision: https://reviews.freebsd.org/D25872
2020-08-25 02:21:27 +00:00
|
|
|
|
2015-06-10 15:53:39 +00:00
|
|
|
# Special flags for managing the compat compiles for DTrace
|
|
|
|
DTRACE_CFLAGS= -DBUILDING_DTRACE ${CDDL_CFLAGS} -I$S/cddl/dev/dtrace -I$S/cddl/dev/dtrace/${MACHINE_CPUARCH}
|
|
|
|
.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
|
|
|
|
DTRACE_CFLAGS+= -I$S/cddl/contrib/opensolaris/uts/intel -I$S/cddl/dev/dtrace/x86
|
|
|
|
.endif
|
Merge OpenZFS support in to HEAD.
The primary benefit is maintaining a completely shared
code base with the community allowing FreeBSD to receive
new features sooner and with less effort.
I would advise against doing 'zpool upgrade'
or creating indispensable pools using new
features until this change has had a month+
to soak.
Work on merging FreeBSD support in to what was
at the time "ZFS on Linux" began in August 2018.
I first publicly proposed transitioning FreeBSD
to (new) OpenZFS on December 18th, 2018. FreeBSD
support in OpenZFS was finally completed in December
2019. A CFT for downstreaming OpenZFS support in
to FreeBSD was first issued on July 8th. All issues
that were reported have been addressed or, for
a couple of less critical matters there are
pull requests in progress with OpenZFS. iXsystems
has tested and dogfooded extensively internally.
The TrueNAS 12 release is based on OpenZFS with
some additional features that have not yet made
it upstream.
Improvements include:
project quotas, encrypted datasets,
allocation classes, vectorized raidz,
vectorized checksums, various command line
improvements, zstd compression.
Thanks to those who have helped along the way:
Ryan Moeller, Allan Jude, Zack Welch, and many
others.
Sponsored by: iXsystems, Inc.
Differential Revision: https://reviews.freebsd.org/D25872
2020-08-25 02:21:27 +00:00
|
|
|
DTRACE_CFLAGS+= -I$S/cddl/contrib/opensolaris/common/util -I$S -DDIS_MEM -DSMP -I$S/cddl/compat/opensolaris
|
|
|
|
DTRACE_CFLAGS+= -I$S/cddl/contrib/opensolaris/uts/common
|
2015-06-10 15:53:39 +00:00
|
|
|
DTRACE_ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${DTRACE_CFLAGS}
|
2021-03-31 21:04:55 +00:00
|
|
|
DTRACE_C= ${CC} -c ${DTRACE_CFLAGS} ${WERROR} ${.IMPSRC}
|
2015-11-16 22:37:28 +00:00
|
|
|
DTRACE_S= ${CC} -c ${DTRACE_ASM_CFLAGS} ${WERROR} ${.IMPSRC}
|
2015-06-10 15:53:39 +00:00
|
|
|
|
2023-02-13 15:19:00 +00:00
|
|
|
# zlib code supports systems that are quite old, but will fix this issue once C2x gets radified.
|
|
|
|
# see https://github.com/madler/zlib/issues/633 for details
|
2023-02-13 19:00:50 +00:00
|
|
|
ZLIB_CFLAGS= -Wno-cast-qual ${NO_WDEPRECATED_NON_PROTOTYPE} ${NO_WSTRICT_PROTOTYPES}
|
2023-02-13 15:19:00 +00:00
|
|
|
ZLIB_C= ${CC} -c ${CFLAGS} ${WERROR} ${ZLIB_CFLAGS} ${.IMPSRC}
|
|
|
|
|
2015-06-10 15:53:39 +00:00
|
|
|
# Special flags for managing the compat compiles for DTrace/FBT
|
Merge OpenZFS support in to HEAD.
The primary benefit is maintaining a completely shared
code base with the community allowing FreeBSD to receive
new features sooner and with less effort.
I would advise against doing 'zpool upgrade'
or creating indispensable pools using new
features until this change has had a month+
to soak.
Work on merging FreeBSD support in to what was
at the time "ZFS on Linux" began in August 2018.
I first publicly proposed transitioning FreeBSD
to (new) OpenZFS on December 18th, 2018. FreeBSD
support in OpenZFS was finally completed in December
2019. A CFT for downstreaming OpenZFS support in
to FreeBSD was first issued on July 8th. All issues
that were reported have been addressed or, for
a couple of less critical matters there are
pull requests in progress with OpenZFS. iXsystems
has tested and dogfooded extensively internally.
The TrueNAS 12 release is based on OpenZFS with
some additional features that have not yet made
it upstream.
Improvements include:
project quotas, encrypted datasets,
allocation classes, vectorized raidz,
vectorized checksums, various command line
improvements, zstd compression.
Thanks to those who have helped along the way:
Ryan Moeller, Allan Jude, Zack Welch, and many
others.
Sponsored by: iXsystems, Inc.
Differential Revision: https://reviews.freebsd.org/D25872
2020-08-25 02:21:27 +00:00
|
|
|
FBT_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
|
2015-06-10 15:53:39 +00:00
|
|
|
.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
|
|
|
|
FBT_CFLAGS+= -I$S/cddl/dev/fbt/x86
|
|
|
|
.endif
|
2021-03-31 21:04:55 +00:00
|
|
|
FBT_C= ${CC} -c ${FBT_CFLAGS} ${WERROR} ${.IMPSRC}
|
2015-06-10 15:53:39 +00:00
|
|
|
|
2011-11-30 18:11:49 +00:00
|
|
|
.if ${MK_CTF} != "no"
|
2011-11-29 18:52:02 +00:00
|
|
|
NORMAL_CTFCONVERT= ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
|
2011-11-30 18:11:49 +00:00
|
|
|
.elif ${MAKE_VERSION} >= 5201111300
|
|
|
|
NORMAL_CTFCONVERT=
|
2011-11-29 08:38:47 +00:00
|
|
|
.else
|
2011-11-30 18:11:49 +00:00
|
|
|
NORMAL_CTFCONVERT= @:
|
2011-11-29 08:38:47 +00:00
|
|
|
.endif
|
2008-05-23 03:53:49 +00:00
|
|
|
|
2015-10-29 08:28:39 +00:00
|
|
|
# Linux Kernel Programming Interface C-flags
|
2022-09-23 21:25:07 +00:00
|
|
|
LINUXKPI_INCLUDES= -I$S/compat/linuxkpi/common/include \
|
|
|
|
-I$S/compat/linuxkpi/dummy/include
|
2015-10-29 08:28:39 +00:00
|
|
|
LINUXKPI_C= ${NORMAL_C} ${LINUXKPI_INCLUDES}
|
|
|
|
|
2011-03-21 09:40:01 +00:00
|
|
|
# Infiniband C flags. Correct include paths and omit errors that linux
|
|
|
|
# does not honor.
|
2017-09-16 16:17:08 +00:00
|
|
|
OFEDINCLUDES= -I$S/ofed/include -I$S/ofed/include/uapi ${LINUXKPI_INCLUDES}
|
2022-02-07 20:47:51 +00:00
|
|
|
OFEDNOERR= -Wno-cast-qual -Wno-pointer-arith
|
2017-09-16 16:17:08 +00:00
|
|
|
OFEDCFLAGS= ${CFLAGS:N-I*} -DCONFIG_INFINIBAND_USER_MEM \
|
|
|
|
${OFEDINCLUDES} ${CFLAGS:M-I*} ${OFEDNOERR}
|
2021-03-31 21:04:55 +00:00
|
|
|
OFED_C_NOIMP= ${CC} -c -o ${.TARGET} ${OFEDCFLAGS} ${WERROR}
|
2011-03-21 09:40:01 +00:00
|
|
|
OFED_C= ${OFED_C_NOIMP} ${.IMPSRC}
|
|
|
|
|
2019-05-08 10:49:05 +00:00
|
|
|
# mlxfw C flags.
|
|
|
|
MLXFW_C= ${OFED_C_NOIMP} \
|
|
|
|
-I${SRCTOP}/sys/contrib/xz-embedded/freebsd \
|
|
|
|
-I${SRCTOP}/sys/contrib/xz-embedded/linux/lib/xz \
|
|
|
|
${.IMPSRC}
|
|
|
|
|
2018-07-03 21:02:21 +00:00
|
|
|
GEN_CFILES= $S/$M/$M/genassym.c ${MFILES:T:S/.m$/.c/}
|
2005-03-29 11:23:25 +00:00
|
|
|
SYSTEM_CFILES= config.c env.c hints.c vnode_if.c
|
2001-11-02 21:34:20 +00:00
|
|
|
SYSTEM_DEP= Makefile ${SYSTEM_OBJS}
|
2003-02-28 21:59:14 +00:00
|
|
|
SYSTEM_OBJS= locore.o ${MDOBJS} ${OBJS}
|
|
|
|
SYSTEM_OBJS+= ${SYSTEM_CFILES:.c=.o}
|
2022-02-14 02:24:36 +00:00
|
|
|
SYSTEM_OBJS+= force-dynamic-hack.pico
|
Fix MFS builds when both MD_ROOT_SIZE and MFS_IMAGE are specified
MD_ROOT_SIZE and embed_mfs.sh were basically retired as part of
https://reviews.freebsd.org/D2903 .
However, when building a kernel with 'options MD_ROOT_SIZE' specified, this
results in a non-working MFS, as within sys/dev/md/md.c we fall within the
wrong # ifdef.
This patch implements the following:
* Allow kernels to be built without the MD_ROOT_SIZE option, which results
in a kernel built as per D2903.
* Allow kernels to be built with the MD_ROOT_SIZE option, which results
in a kernel built similarly to the pre-D2903 way, with the following
differences:
* The MFS is now put in a separate section within the kernel (oldmfs,
so it differs from the mfs section introduced by D2903).
* embed_mfs.sh is changed, so it looks up the oldmfs section within the
kernel, gets its size and offset, sees if the MFS will fit within the
allocated oldmfs section and only if all is well does a dd of the MFS
image into the kernel.
Submitted by: Stanislav Galabov <sgalabov@gmail.com>
Reviewed by: brooks, imp
Differential Revision: https://reviews.freebsd.org/D5093
2016-02-02 07:02:51 +00:00
|
|
|
|
2020-02-02 08:27:20 +00:00
|
|
|
KEYMAP=kbdcontrol -P ${SRCTOP}/share/vt/keymaps -P ${SRCTOP}/share/syscons/keymaps
|
|
|
|
KEYMAP_FIX=sed -e 's/^static keymap_t.* = /static keymap_t key_map = /' -e 's/^static accentmap_t.* = /static accentmap_t accent_map = /'
|
|
|
|
|
Fix MFS builds when both MD_ROOT_SIZE and MFS_IMAGE are specified
MD_ROOT_SIZE and embed_mfs.sh were basically retired as part of
https://reviews.freebsd.org/D2903 .
However, when building a kernel with 'options MD_ROOT_SIZE' specified, this
results in a non-working MFS, as within sys/dev/md/md.c we fall within the
wrong # ifdef.
This patch implements the following:
* Allow kernels to be built without the MD_ROOT_SIZE option, which results
in a kernel built as per D2903.
* Allow kernels to be built with the MD_ROOT_SIZE option, which results
in a kernel built similarly to the pre-D2903 way, with the following
differences:
* The MFS is now put in a separate section within the kernel (oldmfs,
so it differs from the mfs section introduced by D2903).
* embed_mfs.sh is changed, so it looks up the oldmfs section within the
kernel, gets its size and offset, sees if the MFS will fit within the
allocated oldmfs section and only if all is well does a dd of the MFS
image into the kernel.
Submitted by: Stanislav Galabov <sgalabov@gmail.com>
Reviewed by: brooks, imp
Differential Revision: https://reviews.freebsd.org/D5093
2016-02-02 07:02:51 +00:00
|
|
|
MD_ROOT_SIZE_CONFIGURED!= grep MD_ROOT_SIZE opt_md.h || true ; echo
|
2015-08-13 15:16:34 +00:00
|
|
|
.if ${MFS_IMAGE:Uno} != "no"
|
Fix MFS builds when both MD_ROOT_SIZE and MFS_IMAGE are specified
MD_ROOT_SIZE and embed_mfs.sh were basically retired as part of
https://reviews.freebsd.org/D2903 .
However, when building a kernel with 'options MD_ROOT_SIZE' specified, this
results in a non-working MFS, as within sys/dev/md/md.c we fall within the
wrong # ifdef.
This patch implements the following:
* Allow kernels to be built without the MD_ROOT_SIZE option, which results
in a kernel built as per D2903.
* Allow kernels to be built with the MD_ROOT_SIZE option, which results
in a kernel built similarly to the pre-D2903 way, with the following
differences:
* The MFS is now put in a separate section within the kernel (oldmfs,
so it differs from the mfs section introduced by D2903).
* embed_mfs.sh is changed, so it looks up the oldmfs section within the
kernel, gets its size and offset, sees if the MFS will fit within the
allocated oldmfs section and only if all is well does a dd of the MFS
image into the kernel.
Submitted by: Stanislav Galabov <sgalabov@gmail.com>
Reviewed by: brooks, imp
Differential Revision: https://reviews.freebsd.org/D5093
2016-02-02 07:02:51 +00:00
|
|
|
.if empty(MD_ROOT_SIZE_CONFIGURED)
|
2015-08-13 15:16:34 +00:00
|
|
|
SYSTEM_OBJS+= embedfs_${MFS_IMAGE:T:R}.o
|
|
|
|
.endif
|
Fix MFS builds when both MD_ROOT_SIZE and MFS_IMAGE are specified
MD_ROOT_SIZE and embed_mfs.sh were basically retired as part of
https://reviews.freebsd.org/D2903 .
However, when building a kernel with 'options MD_ROOT_SIZE' specified, this
results in a non-working MFS, as within sys/dev/md/md.c we fall within the
wrong # ifdef.
This patch implements the following:
* Allow kernels to be built without the MD_ROOT_SIZE option, which results
in a kernel built as per D2903.
* Allow kernels to be built with the MD_ROOT_SIZE option, which results
in a kernel built similarly to the pre-D2903 way, with the following
differences:
* The MFS is now put in a separate section within the kernel (oldmfs,
so it differs from the mfs section introduced by D2903).
* embed_mfs.sh is changed, so it looks up the oldmfs section within the
kernel, gets its size and offset, sees if the MFS will fit within the
allocated oldmfs section and only if all is well does a dd of the MFS
image into the kernel.
Submitted by: Stanislav Galabov <sgalabov@gmail.com>
Reviewed by: brooks, imp
Differential Revision: https://reviews.freebsd.org/D5093
2016-02-02 07:02:51 +00:00
|
|
|
.endif
|
2019-12-25 22:33:47 +00:00
|
|
|
SYSTEM_LD_BASECMD= \
|
|
|
|
${LD} -m ${LD_EMULATION} -Bdynamic -T ${LDSCRIPT} ${_LDFLAGS} \
|
2017-04-05 03:05:04 +00:00
|
|
|
--no-warn-mismatch --warn-common --export-dynamic \
|
2019-12-25 22:33:47 +00:00
|
|
|
--dynamic-linker /red/herring -X
|
|
|
|
SYSTEM_LD= @${SYSTEM_LD_BASECMD} -o ${.TARGET} ${SYSTEM_OBJS} vers.o
|
2023-02-25 18:33:22 +00:00
|
|
|
SYSTEM_LD_TAIL= @${SIZE} ${.TARGET} ; chmod 755 ${.TARGET}
|
2008-02-02 07:52:24 +00:00
|
|
|
SYSTEM_DEP+= ${LDSCRIPT}
|
2001-11-02 21:34:20 +00:00
|
|
|
|
2015-07-04 05:43:45 +00:00
|
|
|
# Calculate path for .m files early, if needed.
|
2018-03-10 02:09:36 +00:00
|
|
|
.if !defined(NO_MODULES) && !defined(__MPATH) && !make(install) && \
|
|
|
|
(empty(.MAKEFLAGS:M-V) || defined(NO_SKIP_MPATH))
|
2015-07-04 05:43:45 +00:00
|
|
|
__MPATH!=find ${S:tA}/ -name \*_if.m
|
|
|
|
.endif
|
|
|
|
|
2002-01-05 06:21:06 +00:00
|
|
|
# MKMODULESENV is set here so that port makefiles can augment
|
|
|
|
# them.
|
|
|
|
|
2011-04-30 17:51:39 +00:00
|
|
|
MKMODULESENV+= MAKEOBJDIRPREFIX=${.OBJDIR}/modules KMODDIR=${KODIR}
|
2010-07-15 23:32:53 +00:00
|
|
|
MKMODULESENV+= MACHINE_CPUARCH=${MACHINE_CPUARCH}
|
2014-02-04 05:35:04 +00:00
|
|
|
MKMODULESENV+= MACHINE=${MACHINE} MACHINE_ARCH=${MACHINE_ARCH}
|
2015-02-10 15:15:08 +00:00
|
|
|
MKMODULESENV+= MODULES_EXTRA="${MODULES_EXTRA}" WITHOUT_MODULES="${WITHOUT_MODULES}"
|
2017-07-19 22:06:35 +00:00
|
|
|
MKMODULESENV+= ARCH_FLAGS="${ARCH_FLAGS}"
|
2002-02-17 21:00:20 +00:00
|
|
|
.if (${KERN_IDENT} == LINT)
|
|
|
|
MKMODULESENV+= ALL_MODULES=LINT
|
|
|
|
.endif
|
2002-01-05 06:21:06 +00:00
|
|
|
.if defined(MODULES_OVERRIDE)
|
|
|
|
MKMODULESENV+= MODULES_OVERRIDE="${MODULES_OVERRIDE}"
|
|
|
|
.endif
|
|
|
|
.if defined(DEBUG)
|
2004-02-13 10:40:54 +00:00
|
|
|
MKMODULESENV+= DEBUG_FLAGS="${DEBUG}"
|
2002-01-05 06:21:06 +00:00
|
|
|
.endif
|
2016-07-22 17:31:14 +00:00
|
|
|
.if !defined(NO_MODULES)
|
2015-12-01 21:19:16 +00:00
|
|
|
MKMODULESENV+= __MPATH="${__MPATH}"
|
2016-07-22 17:31:14 +00:00
|
|
|
.endif
|
2012-09-12 14:19:40 +00:00
|
|
|
|
2013-11-29 20:19:00 +00:00
|
|
|
# Detect kernel config options that force stack frames to be turned on.
|
2012-09-12 14:19:40 +00:00
|
|
|
DDB_ENABLED!= grep DDB opt_ddb.h || true ; echo
|
2023-01-03 17:54:15 +00:00
|
|
|
DTRACE_ENABLED!=grep KDTRACE_FRAME opt_kdtrace.h || true ; echo
|
2012-09-12 14:19:40 +00:00
|
|
|
HWPMC_ENABLED!= grep HWPMC opt_hwpmc_hooks.h || true ; echo
|