Skip to content

Instantly share code, notes, and snippets.

@dplummer
Created June 30, 2011 20:50
Show Gist options
  • Save dplummer/1057210 to your computer and use it in GitHub Desktop.
Save dplummer/1057210 to your computer and use it in GitHub Desktop.
ree tcmalloc patch fix for glibc 2.14
diff -urB a/distro/google-perftools-1.7/src/tcmalloc.cc b/distro/google-perftools-1.7/src/tcmalloc.cc
--- a/distro/google-perftools-1.7/src/tcmalloc.cc
+++ b/distro/google-perftools-1.7/src/tcmalloc.cc
@@ -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 @@
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
@dplummer
Copy link
Author

For RVM install with rvm install ree --patch tcmalloc.patch

@mwolfetech
Copy link

Thanks! I also needed this patch http://redmine.ruby-lang.org/attachments/1931/stdout-rouge-fix.patch to install ree-1.8.7-2011.03 on a system with glibc 2.14

rvm install ree-1.8.7-2011.03 --patch tcmalloc.patch --patch stdout-rouge-fix.patch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment