[google-perftools] fix glibc malloc hook issue (for now)

Tom Callaway spot at fedoraproject.org
Wed Jun 29 13:54:21 UTC 2011


commit 2c51faaf8f2f863cda6d80e8578192684afd3a9e
Author: Tom "spot" Callaway <tcallawa at redhat.com>
Date:   Wed Jun 29 09:54:09 2011 -0400

    fix glibc malloc hook issue (for now)

 google-perftools-1.7-glibc-malloc-fix.patch |   50 +++++++++++++++++++++++++++
 google-perftools.spec                       |    8 ++++-
 2 files changed, 57 insertions(+), 1 deletions(-)
---
diff --git a/google-perftools-1.7-glibc-malloc-fix.patch b/google-perftools-1.7-glibc-malloc-fix.patch
new file mode 100644
index 0000000..54114c5
--- /dev/null
+++ b/google-perftools-1.7-glibc-malloc-fix.patch
@@ -0,0 +1,50 @@
+diff -up google-perftools-1.7/src/debugallocation.cc.glibc-malloc-fix google-perftools-1.7/src/debugallocation.cc
+--- google-perftools-1.7/src/debugallocation.cc.glibc-malloc-fix	2011-06-29 09:48:12.586532246 -0400
++++ google-perftools-1.7/src/debugallocation.cc	2011-06-29 09:49:43.154245503 -0400
+@@ -84,6 +84,13 @@
+ # define MAP_ANONYMOUS MAP_ANON
+ #endif
+ 
++// GLibc 2.14+ requires the hook functions be declared volatile, based on the
++// value of the define __MALLOC_HOOK_VOLATILE. For compatibility with
++// older/non-GLibc implementations, provide an empty definition.
++#if !defined(__MALLOC_HOOK_VOLATILE)
++#define __MALLOC_HOOK_VOLATILE
++#endif
++
+ // ========================================================================= //
+ 
+ DEFINE_bool(malloctrace,
+@@ -1135,7 +1142,7 @@ static void *MemalignOverride(size_t ali
+   MallocHook::InvokeNewHook(p, size);
+   return p;
+ }
+-void *(*__memalign_hook)(size_t, size_t, const void *) = MemalignOverride;
++void *(*__MALLOC_HOOK_VOLATILE __memalign_hook)(size_t, size_t, const void *) = MemalignOverride;
+ 
+ extern "C" void* memalign(size_t align, size_t size) __THROW {
+   void *p = do_debug_memalign(align, size);
+diff -up google-perftools-1.7/src/tcmalloc.cc.glibc-malloc-fix google-perftools-1.7/src/tcmalloc.cc
+--- google-perftools-1.7/src/tcmalloc.cc.glibc-malloc-fix	2010-12-18 05:20:37.000000000 -0500
++++ google-perftools-1.7/src/tcmalloc.cc	2011-06-29 09:46:55.786789156 -0400
+@@ -137,6 +137,13 @@
+ # define WIN32_DO_PATCHING 1
+ #endif
+ 
++// GLibc 2.14+ requires the hook functions be declared volatile, based on the
++// value of the define __MALLOC_HOOK_VOLATILE. For compatibility with
++// older/non-GLibc implementations, provide an empty definition.
++#if !defined(__MALLOC_HOOK_VOLATILE)
++#define __MALLOC_HOOK_VOLATILE
++#endif
++
+ using STL_NAMESPACE::max;
+ using STL_NAMESPACE::numeric_limits;
+ using STL_NAMESPACE::vector;
+@@ -1669,5 +1676,5 @@ static void *MemalignOverride(size_t ali
+   MallocHook::InvokeNewHook(result, size);
+   return result;
+ }
+-void *(*__memalign_hook)(size_t, size_t, const void *) = MemalignOverride;
++void *(*__MALLOC_HOOK_VOLATILE __memalign_hook)(size_t, size_t, const void *) = MemalignOverride;
+ #endif  // #ifndef TCMALLOC_FOR_DEBUGALLOCATION
diff --git a/google-perftools.spec b/google-perftools.spec
index b796fa7..89753e7 100644
--- a/google-perftools.spec
+++ b/google-perftools.spec
@@ -1,6 +1,6 @@
 Name:		google-perftools
 Version:	1.7
-Release:	3%{?dist}
+Release:	4%{?dist}
 License:	BSD
 Group:		Development/Tools
 Summary:	Very fast malloc and performance analysis tools
@@ -8,6 +8,7 @@ URL:		http://code.google.com/p/google-perftools/
 Source0:	http://google-perftools.googlecode.com/files/google-perftools-%{version}.tar.gz
 # http://code.google.com/p/google-perftools/issues/detail?id=309
 Patch0:		google-perftools-1.7-broken-comment-style.patch
+Patch1:		google-perftools-1.7-glibc-malloc-fix.patch
 BuildRoot:	%{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 # ppc64 still broken, bz 238390
 ExclusiveArch:	%{ix86} x86_64 ppc
@@ -33,6 +34,7 @@ Libraries and headers for developing applications that use google-perftools.
 %prep
 %setup -q
 %patch0 -p1 -b .commentfix
+%patch1 -p1 -b .glibc-malloc-fix
 
 %build
 CXXFLAGS=`echo $RPM_OPT_FLAGS -DTCMALLOC_LARGE_PAGES| sed -e 's/-Wp,-D_FORTIFY_SOURCE=2//g'`
@@ -80,6 +82,10 @@ rm -rf $RPM_BUILD_ROOT
 %{_libdir}/pkgconfig/*.pc
 
 %changelog
+* Wed Jun 29 2011 Tom Callaway <spot at fedoraproject.org> - 1.7-4
+- fix tcmalloc compile against current glibc, fix derived from:
+  http://src.chromium.org/viewvc/chrome?view=rev&revision=89800
+
 * Thu May 12 2011 Tom Callaway <spot at fedoraproject.org> - 1.7-3
 - add Requires: graphviz, gv for pprof
 


More information about the scm-commits mailing list