Skip to content

Instantly share code, notes, and snippets.

@madx
Created March 6, 2013 14:06
Show Gist options
  • Save madx/5099506 to your computer and use it in GitHub Desktop.
Save madx/5099506 to your computer and use it in GitHub Desktop.
Patched REE 1.8.7 install recipe for ruby-build
build_package_tcmalloc_patch() {
patch source/distro/google-perftools-1.7/src/tcmalloc.cc ~/.rbenv/plugins/ruby-build/share/ruby-build/tcmalloc.patch
}
require_gcc
install_package "ruby-enterprise-1.8.7-2012.02" "http://rubyenterpriseedition.googlecode.com/files/ruby-enterprise-1.8.7-2012.02.tar.gz#8d086d2fe68a4c57ba76228e97fb3116" tcmalloc_patch ree_installer
diff --git a/distro/google-perftools-1.7/src/tcmalloc.cc b/distro/google-perftools-1.7/src/tcmalloc.cc
index 8d94d20..0769425 100644
--- 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 @@ static void *MemalignOverride(size_t align, size_t size, const void *caller)
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment