Turn MALLOC_PRODUCTION into a regular src.conf(5) option

For historical reasons, defining MALLOC_PRODUCTION in /etc/make.conf has
been used to turn off potentially expensive debug checks and statistics
gathering in the implementation of malloc(3).

It seems more consistent to turn this into a regular src.conf(5) option,
e.g. WITH_MALLOC_PRODUCTION / WITHOUT_MALLOC_PRODUCTION. This can then
be toggled similar to any other source build option, and turned on or
off by default for e.g. stable branches.

Reviewed by:	imp, #manpages
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D26337
This commit is contained in:
Dimitry Andric 2020-09-05 23:30:17 +00:00
parent 12cb97fb37
commit 7d4374f65f
9 changed files with 25 additions and 15 deletions

View File

@ -22,9 +22,9 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 13.x IS SLOW:
debugging flags in userland, and various verbose features in the debugging flags in userland, and various verbose features in the
kernel. Many developers choose to disable these features on build kernel. Many developers choose to disable these features on build
machines to maximize performance. (To completely disable malloc machines to maximize performance. (To completely disable malloc
debugging, define MALLOC_PRODUCTION in /etc/make.conf, or to merely debugging, define WITH_MALLOC_PRODUCTION in /etc/src.conf and rebuild
disable the most expensive debugging functionality run world, or to merely disable the most expensive debugging functionality
"ln -s 'abort:false,junk:false' /etc/malloc.conf".) at runtime, run "ln -s 'abort:false,junk:false' /etc/malloc.conf".)
20200824: 20200824:
OpenZFS support has been integrated. Do not upgrade root pools until OpenZFS support has been integrated. Do not upgrade root pools until

View File

@ -14,7 +14,7 @@ index 7fecda7c..d5ca5e86 100644
+ <option>--with-malloc-conf=abort_conf:false</option>. + <option>--with-malloc-conf=abort_conf:false</option>.
+ Additionally, <option>--enable-debug</option> is enabled in development + Additionally, <option>--enable-debug</option> is enabled in development
+ versions of FreeBSD (controlled by the + versions of FreeBSD (controlled by the
+ <constant>MALLOC_PRODUCTION</constant> make variable).</para> + <constant>MK_MALLOC_PRODUCTION</constant> make variable).</para>
+ +
</refsect1> </refsect1>
<refsynopsisdiv> <refsynopsisdiv>

View File

@ -43,7 +43,7 @@ The following configuration options are enabled in libc\*(Aqs built\-in jemalloc
\fB\-\-with\-malloc\-conf=abort_conf:false\fR\&. Additionally, \fB\-\-with\-malloc\-conf=abort_conf:false\fR\&. Additionally,
\fB\-\-enable\-debug\fR \fB\-\-enable\-debug\fR
is enabled in development versions of FreeBSD (controlled by the is enabled in development versions of FreeBSD (controlled by the
\fBMALLOC_PRODUCTION\fR \fBMK_MALLOC_PRODUCTION\fR
make variable)\&. make variable)\&.
.SH "SYNOPSIS" .SH "SYNOPSIS"
.sp .sp

View File

@ -45,6 +45,6 @@ MLINKS+= \
jemalloc.3 nallocx.3 \ jemalloc.3 nallocx.3 \
jemalloc.3 malloc.conf.5 jemalloc.3 malloc.conf.5
.if defined(MALLOC_PRODUCTION) .if ${MK_MALLOC_PRODUCTION} != "no"
CFLAGS+= -DMALLOC_PRODUCTION CFLAGS+= -DMALLOC_PRODUCTION
.endif .endif

View File

@ -401,12 +401,6 @@ console driver to
and allow access over FireWire(IEEE1394) using and allow access over FireWire(IEEE1394) using
.Xr dconschat 8 . .Xr dconschat 8 .
Currently, only i386 and amd64 are supported. Currently, only i386 and amd64 are supported.
.It Va MALLOC_PRODUCTION
.Pq Vt bool
Set this to disable assertions and statistics gathering in
.Xr malloc 3 .
It also defaults the A and J runtime options to off.
Disabled by default on -CURRENT.
.It Va MAN_ARCH .It Va MAN_ARCH
.Pq Vt str .Pq Vt str
Space-delimited list of one or more MACHINE and/or MACHINE_ARCH values Space-delimited list of one or more MACHINE and/or MACHINE_ARCH values

View File

@ -1,6 +1,6 @@
.\" DO NOT EDIT-- this file is @generated by tools/build/options/makeman. .\" DO NOT EDIT-- this file is @generated by tools/build/options/makeman.
.\" $FreeBSD$ .\" $FreeBSD$
.Dd July 6, 2020 .Dd September 5, 2020
.Dt SRC.CONF 5 .Dt SRC.CONF 5
.Os .Os
.Sh NAME .Sh NAME
@ -1104,6 +1104,11 @@ if executed as an unprivileged user.
See See
.Xr tests 7 .Xr tests 7
for more details. for more details.
.It Va WITH_MALLOC_PRODUCTION
Set to disable assertions and statistics gathering in
.Xr malloc 3 .
It also defaults the A and J runtime options to off.
Disabled by default on -CURRENT.
.It Va WITHOUT_MAN .It Va WITHOUT_MAN
Set to not build manual pages. Set to not build manual pages.
When set, these options are also in effect: When set, these options are also in effect:
@ -1278,12 +1283,12 @@ Enable building openldap support for kerberos.
Set to not build LLVM's OpenMP runtime. Set to not build LLVM's OpenMP runtime.
.Pp .Pp
This is a default setting on This is a default setting on
arm/armv6, arm/armv7, arm64/aarch64, mips/mips, mips/mips64, powerpc/powerpc, riscv/riscv64 and riscv/riscv64sf. arm/armv6, arm/armv7, mips/mips, mips/mips64, powerpc/powerpc, riscv/riscv64 and riscv/riscv64sf.
.It Va WITH_OPENMP .It Va WITH_OPENMP
Set to build LLVM's OpenMP runtime. Set to build LLVM's OpenMP runtime.
.Pp .Pp
This is a default setting on This is a default setting on
amd64/amd64, i386/i386 and powerpc/powerpc64. amd64/amd64, arm64/aarch64, i386/i386 and powerpc/powerpc64.
.It Va WITHOUT_OPENSSH .It Va WITHOUT_OPENSSH
Set to not build OpenSSH. Set to not build OpenSSH.
.It Va WITHOUT_OPENSSL .It Va WITHOUT_OPENSSL

View File

@ -213,6 +213,7 @@ __DEFAULT_NO_OPTIONS = \
LOADER_FORCE_LE \ LOADER_FORCE_LE \
LOADER_VERBOSE \ LOADER_VERBOSE \
LOADER_VERIEXEC_PASS_MANIFEST \ LOADER_VERIEXEC_PASS_MANIFEST \
MALLOC_PRODUCTION \
OFED_EXTRA \ OFED_EXTRA \
OPENLDAP \ OPENLDAP \
REPRODUCIBLE_BUILD \ REPRODUCIBLE_BUILD \

View File

@ -0,0 +1,5 @@
.\" $FreeBSD$
Set to enable assertions and statistics gathering in
.Xr malloc 3 .
It also defaults the A and J runtime options to on.
Enabled by default on -CURRENT.

View File

@ -0,0 +1,5 @@
.\" $FreeBSD$
Set to disable assertions and statistics gathering in
.Xr malloc 3 .
It also defaults the A and J runtime options to off.
Disabled by default on -CURRENT.