From 09e32b2fddf5f673f76e2fffa415a73d99a6f309 Mon Sep 17 00:00:00 2001 From: Brooks Davis Date: Fri, 1 Sep 2023 17:42:39 +0100 Subject: [PATCH] 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(-) create mode 100644 tools/build/options/LIBC_MALLOC diff --git a/lib/libc/stdlib/malloc/Makefile.inc b/lib/libc/stdlib/malloc/Makefile.inc index bce4353fe80..3bae4ff1505 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 1183a820216..d7112cf5717 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 00000000000..ee1883f3ee5 --- /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.