[tor-commits] [tor/master] Merge branch 'with_malloc_squashed'

nickm at torproject.org nickm at torproject.org
Fri Aug 3 11:38:53 UTC 2018


commit bb1f29423263d2285e318ff190c3692b9d41b6ff
Merge: ae157b79e abde9fb42
Author: Nick Mathewson <nickm at torproject.org>
Date:   Fri Aug 3 07:35:23 2018 -0400

    Merge branch 'with_malloc_squashed'

 changes/ticket20424 |  5 ++++
 configure.ac        | 71 ++++++++++++++++++++++++++++++++++++++++++++---------
 2 files changed, 65 insertions(+), 11 deletions(-)

diff --cc configure.ac
index ebd415374,d414d0253..ea19e3fef
--- a/configure.ac
+++ b/configure.ac
@@@ -1793,24 -1764,71 +1791,75 @@@ AC_ARG_WITH(tcmalloc
  AS_HELP_STRING(--with-tcmalloc, [use tcmalloc memory allocation library]),
  [ tcmalloc=yes ], [ tcmalloc=no ])
  
- if test "x$tcmalloc" = "xyes"; then
-    LDFLAGS="-ltcmalloc $LDFLAGS"
- fi
+ default_malloc=system
  
- using_custom_malloc=no
- if test "x$enable_openbsd_malloc" = "xyes"; then
-    using_custom_malloc=yes
+ if test "x$enable_openbsd_malloc" = "xyes" ; then
+   AC_MSG_NOTICE([The --enable-openbsd-malloc argument is deprecated; use --with-malloc=openbsd instead.])
+   default_malloc=openbsd
  fi
+ 
  if test "x$tcmalloc" = "xyes"; then
-    using_custom_malloc=yes
+   AC_MSG_NOTICE([The --with-tcmalloc argument is deprecated; use --with-malloc=tcmalloc instead.])
+   default_malloc=tcmalloc
  fi
- if test "$using_custom_malloc" = "no"; then
-    AC_CHECK_FUNCS(mallinfo)
+ 
+ AC_ARG_WITH(malloc,
+    AS_HELP_STRING([--with-malloc=[system,jemalloc,tcmalloc,openbsd]],
+                   [select special malloc implementation [system]]),
+    [ malloc="$with_malloc" ], [ malloc="$default_malloc" ])
+ 
+ AS_CASE([$malloc],
+   [tcmalloc], [
+       PKG_CHECK_MODULES([TCMALLOC],
+ 			[libtcmalloc],
+ 			have_tcmalloc=yes,
+ 			have_tcmalloc=no)
+ 
+       if test "x$have_tcmalloc" = "xno" ; then
+           AC_MSG_ERROR([Unable to find tcmalloc requested by --with-malloc.])
+       fi
+ 
+       CFLAGS="$CFLAGS $TCMALLOC_CFLAGS"
+       LIBS="$TCMALLOC_LIBS $LIBS"
+   ],
+ 
+   [jemalloc], [
+       PKG_CHECK_MODULES([JEMALLOC],
+ 		        [jemalloc],
+ 			have_jemalloc=yes,
+ 			have_jemalloc=no)
+ 
+       if test "x$have_tcmalloc" = "xno" ; then
+           AC_MSG_ERROR([Unable to find jemalloc requested by --with-malloc.])
+       fi
+ 
+       CFLAGS="$CFLAGS $JEMALLOC_CFLAGS"
+       LIBS="$JEMALLOC_LIBS $LIBS"
+       using_custom_malloc=yes
+   ],
+ 
+   [openbsd], [
+     enable_openbsd_malloc=yes
+   ],
+ 
+   [system], [
+      # handle this later, including the jemalloc fallback
+     AC_CHECK_FUNCS(mallinfo)
+   ],
+ 
+   [AC_MSG_ERROR([--with-malloc=`$with_malloc' not supported, see --help])
+ ])
+ 
+ AM_CONDITIONAL(USE_OPENBSD_MALLOC, test "x$enable_openbsd_malloc" = "xyes")
+ 
+ if test "$malloc" != "system"; then
+   # Tell the C compiler not to use the system allocator functions.
+   TOR_CHECK_CFLAGS([-fno-builtin-malloc -fno-builtin-realloc -fno-builtin-calloc -fno-builtin-free])
  fi
 +if test "$using_custom_malloc" = "yes"; then
 +  # Tell the C compiler not to use the system allocator functions.
 +  TOR_CHECK_CFLAGS([-fno-builtin-malloc -fno-builtin-realloc -fno-builtin-calloc -fno-builtin-free])
 +fi
  
  # By default, we're going to assume we don't have mlockall()
  # bionic and other platforms have various broken mlockall subsystems.





More information about the tor-commits mailing list