This updates configure.in to make it search for and link in a modern
malloc library. If none is found the default libc implementation is used.
Search list is sorted by apparent speed, but the benchmarks were a few
years ago so if anyone has info on a better priority order that would be
welcome.
Notes:
malloc is the call searched for to find a library. The alternative
mallopt, mallinfo, and mallocblksize already have build wrappers so we
are not locked into requiring them, though they would be useful.
One weirdness appeared while testing. It seems the special case
disabling of functions for GNU malloc was not working anyway. The
protection wrapper tests later on were overriding the hard-coded disable.
Only one question remains in my mind:
do we need to retain the special case disabling of malloc libraries
or Solaris and FreeBSD?
Amos
--
Please be using
Current Stable Squid 2.7.STABLE9 or 3.1.3
=== modified file 'configure.in'
--- configure.in 2010-05-28 14:15:11 +0000
+++ configure.in 2010-05-29 06:46:14 +0000
@@ -2611,26 +2611,12 @@
fi
dnl end rip
- AC_CHECK_LIB(gnumalloc, main)
- if test "$ac_cv_lib_gnumalloc_main" = "yes"; then
- AC_MSG_NOTICE([Disabling extended malloc functions when using gnumalloc])
- ac_cv_func_mallinfo=no
- ac_cv_func_mallocblksize=no
- ac_cv_func_mallopt=no
- else
- case "$host" in
- *-sun-solaris*)
- AC_MSG_NOTICE([skipping libmalloc check for $host])
- ;;
- i386-*-freebsd*)
- AC_MSG_NOTICE([skipping libmalloc check for $host])
- ;;
- *)
-
- AC_CHECK_LIB(malloc, main)
- ;;
- esac
- fi
+dnl Search for a fast malloc implementation explicitly
+dnl If none of these are found rely on the libc default implementation
+saved_flags=$CXXFLAGS
+CXXFLAGS="$CXXFLAGS -nostdlib"
+AC_SEARCH_LIBS([malloc],[tcmalloc jemalloc dlmalloc ptmalloc3 nedmalloc ptmalloc2 malloc])
+CXXFLAGS=$saved_flags
AC_CHECK_LIB(regex, main, [REGEXLIB="-lregex"])
case "$host_os" in
@@ -3747,7 +3733,7 @@
dnl Need the debugging version of malloc if available
XTRA_OBJS=''
-if test "$ac_cv_lib_malloc_main" = "yes" ; then
+if test "$ac_cv_search_malloc" = "-lmalloc" ; then
if test -r /usr/lib/debug/malloc.o ; then
XTRA_OBJS="$XTRA_OBJS /usr/lib/debug/malloc.o"
fi