git: 09e32b2fddf5 - main - libc: add LIBC_MALLOC option
Date: Fri, 01 Sep 2023 16:54:56 UTC
The branch main has been updated by brooks:
URL: https://cgit.FreeBSD.org/src/commit/?id=09e32b2fddf5f673f76e2fffa415a73d99a6f309
commit 09e32b2fddf5f673f76e2fffa415a73d99a6f309
Author: Brooks Davis <brooks@FreeBSD.org>
AuthorDate: 2023-09-01 16:42:39 +0000
Commit: Brooks Davis <brooks@FreeBSD.org>
CommitDate: 2023-09-01 16:54:23 +0000
libc: add LIBC_MALLOC option
This will enable alternative mallocs to be included in the tree and
selected by setting LIBC_MALLOC. As there is only one today (jemalloc)
this option does nothing, but we expect to add other implementations
in the future. This will also reduce diffs to CheriBSD.
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D41660
---
lib/libc/stdlib/malloc/Makefile.inc | 2 +-
share/mk/src.opts.mk | 6 ++++++
tools/build/options/LIBC_MALLOC | 13 +++++++++++++
3 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/lib/libc/stdlib/malloc/Makefile.inc b/lib/libc/stdlib/malloc/Makefile.inc
index bce4353fe80a..3bae4ff1505b 100644
--- a/lib/libc/stdlib/malloc/Makefile.inc
+++ b/lib/libc/stdlib/malloc/Makefile.inc
@@ -1,3 +1,3 @@
SYM_MAPS+=${LIBC_SRCTOP}/stdlib/malloc/Symbol.map
-.include "${LIBC_SRCTOP}/stdlib/malloc/jemalloc/Makefile.inc"
+.include "${LIBC_SRCTOP}/stdlib/malloc/${OPT_LIBC_MALLOC}/Makefile.inc"
diff --git a/share/mk/src.opts.mk b/share/mk/src.opts.mk
index 1183a8202168..d7112cf57178 100644
--- a/share/mk/src.opts.mk
+++ b/share/mk/src.opts.mk
@@ -228,6 +228,12 @@ __DEFAULT_DEPENDENT_OPTIONS= \
LOADER_VERIEXEC_VECTX/LOADER_VERIEXEC \
VERIEXEC/BEARSSL \
+__SINGLE_OPTIONS = \
+ LIBC_MALLOC
+
+__LIBC_MALLOC_OPTIONS= jemalloc
+__LIBC_MALLOC_DEFAULT= jemalloc
+
# MK_*_SUPPORT options which default to "yes" unless their corresponding
# MK_* variable is set to "no".
#
diff --git a/tools/build/options/LIBC_MALLOC b/tools/build/options/LIBC_MALLOC
new file mode 100644
index 000000000000..ee1883f3ee54
--- /dev/null
+++ b/tools/build/options/LIBC_MALLOC
@@ -0,0 +1,13 @@
+Specify the
+.Xr malloc 3
+implementaiton used by libc.
+The default value is
+.Li jemalloc .
+Valid values are:
+.Bl -tag -width indent
+.It Li jemalloc
+.El
+.Pp
+Other implementations are expected in the future in both
+.Fx
+and downstream consumers.