From 7d4374f65f7b3df3d2567029c510f2e1576f0f69 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sat, 5 Sep 2020 23:30:17 +0000 Subject: [PATCH] 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 --- UPDATING | 6 +++--- contrib/jemalloc/FREEBSD-diffs | 2 +- contrib/jemalloc/doc/jemalloc.3 | 2 +- lib/libc/stdlib/jemalloc/Makefile.inc | 2 +- share/man/man5/make.conf.5 | 6 ------ share/man/man5/src.conf.5 | 11 ++++++++--- share/mk/src.opts.mk | 1 + tools/build/options/WITHOUT_MALLOC_PRODUCTION | 5 +++++ tools/build/options/WITH_MALLOC_PRODUCTION | 5 +++++ 9 files changed, 25 insertions(+), 15 deletions(-) create mode 100644 tools/build/options/WITHOUT_MALLOC_PRODUCTION create mode 100644 tools/build/options/WITH_MALLOC_PRODUCTION diff --git a/UPDATING b/UPDATING index ee971126e6f1..24db0cfcfe82 100644 --- a/UPDATING +++ b/UPDATING @@ -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 kernel. Many developers choose to disable these features on build machines to maximize performance. (To completely disable malloc - debugging, define MALLOC_PRODUCTION in /etc/make.conf, or to merely - disable the most expensive debugging functionality run - "ln -s 'abort:false,junk:false' /etc/malloc.conf".) + debugging, define WITH_MALLOC_PRODUCTION in /etc/src.conf and rebuild + world, or to merely disable the most expensive debugging functionality + at runtime, run "ln -s 'abort:false,junk:false' /etc/malloc.conf".) 20200824: OpenZFS support has been integrated. Do not upgrade root pools until diff --git a/contrib/jemalloc/FREEBSD-diffs b/contrib/jemalloc/FREEBSD-diffs index 9e1939bfecfe..5da015086501 100644 --- a/contrib/jemalloc/FREEBSD-diffs +++ b/contrib/jemalloc/FREEBSD-diffs @@ -14,7 +14,7 @@ index 7fecda7c..d5ca5e86 100644 + . + Additionally, is enabled in development + versions of FreeBSD (controlled by the -+ MALLOC_PRODUCTION make variable). ++ MK_MALLOC_PRODUCTION make variable). + diff --git a/contrib/jemalloc/doc/jemalloc.3 b/contrib/jemalloc/doc/jemalloc.3 index d65166f14445..a4ea3e1f54a9 100644 --- a/contrib/jemalloc/doc/jemalloc.3 +++ b/contrib/jemalloc/doc/jemalloc.3 @@ -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\-\-enable\-debug\fR is enabled in development versions of FreeBSD (controlled by the -\fBMALLOC_PRODUCTION\fR +\fBMK_MALLOC_PRODUCTION\fR make variable)\&. .SH "SYNOPSIS" .sp diff --git a/lib/libc/stdlib/jemalloc/Makefile.inc b/lib/libc/stdlib/jemalloc/Makefile.inc index 00242e70b97d..facfd6003451 100644 --- a/lib/libc/stdlib/jemalloc/Makefile.inc +++ b/lib/libc/stdlib/jemalloc/Makefile.inc @@ -45,6 +45,6 @@ MLINKS+= \ jemalloc.3 nallocx.3 \ jemalloc.3 malloc.conf.5 -.if defined(MALLOC_PRODUCTION) +.if ${MK_MALLOC_PRODUCTION} != "no" CFLAGS+= -DMALLOC_PRODUCTION .endif diff --git a/share/man/man5/make.conf.5 b/share/man/man5/make.conf.5 index 78f8350b8392..7cb28c865151 100644 --- a/share/man/man5/make.conf.5 +++ b/share/man/man5/make.conf.5 @@ -401,12 +401,6 @@ console driver to and allow access over FireWire(IEEE1394) using .Xr dconschat 8 . 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 .Pq Vt str Space-delimited list of one or more MACHINE and/or MACHINE_ARCH values diff --git a/share/man/man5/src.conf.5 b/share/man/man5/src.conf.5 index a13056968d4d..e91d7cbb1265 100644 --- a/share/man/man5/src.conf.5 +++ b/share/man/man5/src.conf.5 @@ -1,6 +1,6 @@ .\" DO NOT EDIT-- this file is @generated by tools/build/options/makeman. .\" $FreeBSD$ -.Dd July 6, 2020 +.Dd September 5, 2020 .Dt SRC.CONF 5 .Os .Sh NAME @@ -1104,6 +1104,11 @@ if executed as an unprivileged user. See .Xr tests 7 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 Set to not build manual pages. 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. .Pp 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 Set to build LLVM's OpenMP runtime. .Pp 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 Set to not build OpenSSH. .It Va WITHOUT_OPENSSL diff --git a/share/mk/src.opts.mk b/share/mk/src.opts.mk index 0ad6314695ff..619bfc3c9c58 100644 --- a/share/mk/src.opts.mk +++ b/share/mk/src.opts.mk @@ -213,6 +213,7 @@ __DEFAULT_NO_OPTIONS = \ LOADER_FORCE_LE \ LOADER_VERBOSE \ LOADER_VERIEXEC_PASS_MANIFEST \ + MALLOC_PRODUCTION \ OFED_EXTRA \ OPENLDAP \ REPRODUCIBLE_BUILD \ diff --git a/tools/build/options/WITHOUT_MALLOC_PRODUCTION b/tools/build/options/WITHOUT_MALLOC_PRODUCTION new file mode 100644 index 000000000000..c2ab449a0c56 --- /dev/null +++ b/tools/build/options/WITHOUT_MALLOC_PRODUCTION @@ -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. diff --git a/tools/build/options/WITH_MALLOC_PRODUCTION b/tools/build/options/WITH_MALLOC_PRODUCTION new file mode 100644 index 000000000000..f6ef3f7fef73 --- /dev/null +++ b/tools/build/options/WITH_MALLOC_PRODUCTION @@ -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.