Disable config from file or envvar with build flag

This adds a new autoconf flag, --disable-user-config, which disables
reading the configuration from /etc/malloc.conf or the MALLOC_CONF
environment variable. This can be useful when integrating jemalloc in a
binary that internally handles all aspects of the configuration and
shouldn't be impacted by ambient change in the environment.
This commit is contained in:
roblabla
2024-07-30 14:56:42 +02:00
committed by Qi Wang
parent 34c823f147
commit c17bf8b368
3 changed files with 49 additions and 15 deletions

View File

@@ -1401,6 +1401,23 @@ if test "x$enable_stats" = "x1" ; then
fi
AC_SUBST([enable_stats])
dnl Disable reading configuration from file and environment variable
AC_ARG_ENABLE([user_config],
[AS_HELP_STRING([--disable-user-config],
[Do not read malloc config from /etc/malloc.conf or MALLOC_CONF])],
[if test "x$enable_user_config" = "xno" ; then
enable_user_config="0"
else
enable_user_config="1"
fi
],
[enable_user_config="1"]
)
if test "x$enable_user_config" = "x1" ; then
AC_DEFINE([JEMALLOC_CONFIG_ENV], [ ], [ ])
AC_DEFINE([JEMALLOC_CONFIG_FILE], [ ], [ ])
fi
dnl Do not enable smallocx by default.
AC_ARG_ENABLE([experimental_smallocx],
[AS_HELP_STRING([--enable-experimental-smallocx], [Enable experimental smallocx API])],
@@ -2962,6 +2979,7 @@ AC_MSG_RESULT([static libs : ${enable_static}])
AC_MSG_RESULT([autogen : ${enable_autogen}])
AC_MSG_RESULT([debug : ${enable_debug}])
AC_MSG_RESULT([stats : ${enable_stats}])
AC_MSG_RESULT([user_config : ${enable_user_config}])
AC_MSG_RESULT([experimental_smallocx : ${enable_experimental_smallocx}])
AC_MSG_RESULT([prof : ${enable_prof}])
AC_MSG_RESULT([prof-libunwind : ${enable_prof_libunwind}])