We seem to run into trouble with regular glibc malloc on Linux, so use
jemalloc instead of glibc's malloc.
This can be disabled using --disable-jemalloc
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3216
d4fa192b-c00b-0410-8231-
f00ffab90ce4
$(top_builddir)/lib/libvarnish/libvarnish.la \
$(top_builddir)/lib/libvarnishcompat/libvarnishcompat.la \
$(top_builddir)/lib/libvcl/libvcl.la \
+ @JEMALLOC_LDADD@ \
${DL_LIBS} ${PTHREAD_LIBS} ${NET_LIBS} ${LIBM}
EXTRA_DIST = default.vcl
AC_DEFINE_UNQUOTED([VCC_CC],"$VCC_CC",[C compiler command line for VCL code])
+# Use jemalloc on Linux
+JEMALLOC_SUBDIR=
+JEMALLOC_LDADD=
+AC_ARG_ENABLE(jemalloc,
+AS_HELP_STRING([--disable-jemalloc],[do not use jemalloc (default is yes on Linux, no everywhere else)]),
+[if "x$enableval" = "xyes"; then
+ JEMALLOC_SUBDIR=libjemalloc
+ JEMALLOC_LDADD='$(top_builddir)/lib/libjemalloc/libjemalloc_mt.la'
+fi],
+[case $host in #(
+*-*-linux*)
+ JEMALLOC_SUBDIR=libjemalloc
+ JEMALLOC_LDADD='$(top_builddir)/lib/libjemalloc/libjemalloc_mt.la'
+ ;; #(
+*)
+ true
+ ;;
+esac])
+
+AC_SUBST(JEMALLOC_SUBDIR)
+AC_SUBST(JEMALLOC_LDADD)
+
# Generate output
AC_CONFIG_FILES([
Makefile
lib/libvarnishapi/Makefile
lib/libvarnishcompat/Makefile
lib/libvcl/Makefile
+ lib/libjemalloc/Makefile
man/Makefile
redhat/Makefile
varnishapi.pc
libvarnish \
libvarnishapi \
libvarnishcompat \
- libvcl
+ libvcl \
+ @JEMALLOC_SUBDIR@
+++ /dev/null
-CFLAGS := -O3 -g
-# See source code comments to avoid memory leaks when enabling MALLOC_MAG.
-#CPPFLAGS := -DMALLOC_PRODUCTION -DMALLOC_MAG
-CPPFLAGS := -DMALLOC_PRODUCTION
-
-all: libjemalloc.so.0 libjemalloc_mt.so.0
-
-jemalloc_linux_mt.o: jemalloc_linux.c
- gcc $(CFLAGS) -c -DPIC -fPIC $(CPPFLAGS) -D__isthreaded=true -o $@ $+
-
-jemalloc_linux.o: jemalloc_linux.c
- gcc $(CFLAGS) -c -DPIC -fPIC $(CPPFLAGS) -D__isthreaded=false -o $@ $+
-
-libjemalloc_mt.so.0: jemalloc_linux_mt.o
- gcc -shared -lpthread -o $@ $+
- ln -sf $@ libjemalloc_mt.so
-
-libjemalloc.so.0: jemalloc_linux.o
- gcc -shared -lpthread -o $@ $+
- ln -sf $@ libjemalloc.so
-
-clean:
- rm -f *.o *.so.0 *.so
--- /dev/null
+# See source code comments to avoid memory leaks when enabling MALLOC_MAG.
+#CPPFLAGS := -DMALLOC_PRODUCTION -DMALLOC_MAG
+AM_CPPFLAGS := -DMALLOC_PRODUCTION
+
+#all: libjemalloc.so.0 libjemalloc_mt.so.0
+
+noinst_LTLIBRARIES = libjemalloc_mt.la
+
+libjemalloc_mt_la_LIBADD = ${PTHREAD_LIBS}
+libjemalloc_mt_la_LDFLAGS = -version-info 0:0:0 -static
+libjemalloc_mt_la_CFLAGS = -D__isthreaded=true
+
+libjemalloc_mt_la_SOURCES = jemalloc_linux.c
+
+#jemalloc_linux.o: jemalloc_linux.c
+# gcc $(CFLAGS) -c -DPIC -fPIC $(CPPFLAGS) -D__isthreaded=false -o $@ $+
+
+#libjemalloc_mt.so.0: jemalloc_linux_mt.o
+# gcc -shared -lpthread -o $@ $+
+# ln -sf $@ libjemalloc_mt.so
+
+#libjemalloc.so.0: jemalloc_linux.o
+# gcc -shared -lpthread -o $@ $+
+# ln -sf $@ libjemalloc.so
+
+#clean:
+# rm -f *.o *.so.0 *.so