summaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2018-05-09 15:44:35 +0100
committerEmmanuele Bassi <ebassi@gnome.org>2018-05-09 15:44:35 +0100
commit7d0567ac84c97e5357b8997a4c9e4fa7541c917b (patch)
tree023899e388a790fbd9764a5408a4e799a431fb74 /configure.ac
parent3d2ab4680dd056e0731220fa387cc79456ae01cc (diff)
downloadglib-slice-jemalloc.tar.gz
Allow replacing the GSlice allocator with jemallocslice-jemalloc
The jemalloc allocator implementation comes from the BSD world, and it's used in various places, including: * Mozilla * Rust * Android * Cassandra * MariaDB * Redis More info: http://jemalloc.net Currently, support is enabled by default on Linux, but you have to opt in using `G_SLICE=use-jemalloc`.
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac24
1 files changed, 24 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 823c45bda..bc3e0645c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -130,6 +130,7 @@ case "$host" in
glib_dir_separator='\\\\'
glib_searchpath_separator=';'
glib_cv_stack_grows=no
+ glib_jemalloc_default=no
# Unfortunately the mingw implementations of C99-style snprintf and vsnprintf
# don't seem to be quite good enough, at least not in mingw-runtime-3.14.
# (Sorry, I don't know exactly what is the problem, but it is related to
@@ -155,6 +156,7 @@ case "$host" in
glib_pollfd_format='%d'
glib_dir_separator='/'
glib_searchpath_separator=':'
+ glib_jemalloc_default=yes
;;
esac
case $host in
@@ -256,6 +258,10 @@ AC_ARG_ENABLE(mem_pools,
[AS_HELP_STRING([--disable-mem-pools],
[disable all glib memory pools])],,
[disable_mem_pools=no])
+AC_ARG_ENABLE(jemalloc,
+ [AS_HELP_STRING([--disable-jemalloc],
+ [disable jemalloc])],,
+ [enable_jemalloc="$glib_jemalloc_default"])
GLIB_TESTS
@@ -273,6 +279,24 @@ AS_IF([test "x$disable_mem_pools" = "xno"], [
AC_MSG_RESULT([yes])
])
+PKG_CHECK_MODULES(JEMALLOC, [jemalloc], [has_jemalloc=yes], [has_jemalloc=no])
+AC_MSG_CHECKING([whether jemalloc should be used in GSlice])
+AS_IF([test "x$enable_jemalloc" = xyes], [
+ AS_IF([test "x$has_jemalloc" = xyes], [
+ AC_DEFINE(ENABLE_JEMALLOC, 1, [Whether to enable jemalloc as the GSlice allocator])
+ AC_MSG_RESULT([yes])
+ JEMALLOC_REQUIRES="jemalloc"
+ ], [
+ AC_MSG_ERROR([jemalloc is not available])
+ ])
+], [
+ AC_MSG_RESULT([no])
+ JEMALLOC_REQUIRES=""
+])
+AC_SUBST(JEMALLOC_CFLAGS)
+AC_SUBST(JEMALLOC_LIBS)
+AC_SUBST(JEMALLOC_REQUIRES)
+
dnl location to install runtime libraries, e.g. ../../lib to install
dnl to /lib if libdir is /usr/lib
AC_ARG_WITH(runtime-libdir,