components/desktop/thunderbird/patches/firefox31-43-solaris_jemalloc_linkage.patch
This patch makes it so jemalloc is not included in firefox. Not accepted by
the upstream community.
Put jemalloc inside libxul. Then need firefox to depend on libxul
and build jemalloc library.
Remove lines - do not include memory for every program
Need to create/add our own versions of the functions malloc_usable, jemalloc_stats, etc.
Remove mozalloc library
Check if we have jemalloc; if not, skip it.
Build libxul and use flags -Wl,-z,interpose, needed to build the library.
--- comm-esr31/mozilla/browser/app/Makefile.in.orig 2015-06-04 17:42:51.441312058 -0700
+++ comm-esr31/mozilla/browser/app/Makefile.in 2015-06-04 17:42:51.478117039 -0700
@@ -30,6 +30,12 @@
$(XPCOM_STANDALONE_GLUE_LDOPTS) \
$(NULL)
+ifdef MOZ_MEMORY
+ifeq ($(OS_ARCH),SunOS)
+LIBS += $(LIBXUL_LIBS)
+endif
+endif
+
ifdef MOZ_LINKER
LIBS += $(MOZ_ZLIB_LIBS)
endif
--- comm-esr31/mozilla/config/jemalloc_solaris.map.orig 1969-12-31 16:00:00.000000000 -0800
+++ comm-esr31/mozilla/config/jemalloc_solaris.map 2015-06-04 17:42:51.478209751 -0700
@@ -0,0 +1,12 @@
+{
+ global:
+ calloc = NODIRECT;
+ free = NODIRECT;
+ jemalloc_stats = NODIRECT;
+ malloc = NODIRECT;
+ malloc_usable_size = NODIRECT;
+ memalign = NODIRECT;
+ posix_memalign = NODIRECT;
+ realloc = NODIRECT;
+ valloc = NODIRECT;
+};
--- comm-esr31/mozilla//configure.orig 2015-06-04 17:42:51.444508647 -0700
+++ comm-esr31/mozilla//configure 2015-06-04 17:42:51.480874311 -0700
@@ -24162,9 +24162,6 @@
fi
else
MOZ_GLUE_PROGRAM_LDFLAGS='$(MKSHLIB_FORCE_ALL) $(call EXPAND_LIBNAME_PATH,mozglue,$(LIBXUL_DIST)/lib)'
- if test "$MOZ_MEMORY" = 1 -o \( "$LIBXUL_SDK" -a -f "$LIBXUL_SDK/lib/${LIB_PREFIX}memory.${LIB_SUFFIX}" \); then
- MOZ_GLUE_PROGRAM_LDFLAGS="$MOZ_GLUE_PROGRAM_LDFLAGS "'$(call EXPAND_LIBNAME_PATH,memory,$(LIBXUL_DIST)/lib)'
- fi
MOZ_GLUE_PROGRAM_LDFLAGS="$MOZ_GLUE_PROGRAM_LDFLAGS "'$(MKSHLIB_UNFORCE_ALL)'
if test -n "$GNU_CC"; then
MOZ_GLUE_PROGRAM_LDFLAGS="$MOZ_GLUE_PROGRAM_LDFLAGS -rdynamic"
--- comm-esr31/mozilla/memory/mozalloc/mozalloc.cpp.orig 2015-06-04 17:42:51.453412680 -0700
+++ comm-esr31/mozilla/memory/mozalloc/mozalloc.cpp 2015-06-04 17:42:51.481002191 -0700
@@ -200,6 +200,14 @@
}
#endif // if defined(HAVE_VALLOC)
+#if defined(MOZ_MEMORY_SOLARIS)
+#include "jemalloc_types.h"
+extern "C" {
+extern size_t malloc_usable_size(const void *ptr);
+extern void jemalloc_stats(jemalloc_stats_t* stats);
+}
+#endif
+
size_t
moz_malloc_usable_size(void *ptr)
{
@@ -209,7 +217,22 @@
#if defined(XP_MACOSX)
return malloc_size(ptr);
#elif defined(HAVE_MALLOC_USABLE_SIZE) || defined(MOZ_MEMORY)
+#if defined(SOLARIS)
+ static bool checked = false;
+ static bool using_jemalloc = false;
+ if (!checked) {
+ checked = true;
+ jemalloc_stats_t stats;
+ jemalloc_stats(&stats);
+ using_jemalloc = stats.allocated;
+ }
+ if (using_jemalloc)
+ return malloc_usable_size(ptr);
+ else
+ return 0;
+#else
return malloc_usable_size(ptr);
+#endif
#elif defined(XP_WIN)
return _msize(ptr);
#else
--- comm-esr31/mozilla/security/manager/ssl/tests/unit/tlsserver/cmd/Makefile.in.orig 2015-06-04 17:42:51.459223858 -0700
+++ comm-esr31/mozilla/security/manager/ssl/tests/unit/tlsserver/cmd/Makefile.in 2015-06-04 17:42:51.481099560 -0700
@@ -9,7 +9,6 @@
LIBS = \
$(NSPR_LIBS) \
$(NSS_LIBS) \
- $(MOZALLOC_LIB) \
../../../../../../pkix/$(LIB_PREFIX)mozillapkix.$(LIB_SUFFIX) \
../../../../../../pkix/test/lib/$(LIB_PREFIX)pkixtestutil.$(LIB_SUFFIX) \
../lib/$(LIB_PREFIX)tlsserver.$(LIB_SUFFIX) \
--- comm-esr31/mozilla/storage/src/mozStorageService.cpp.orig 2015-06-04 17:42:51.464827762 -0700
+++ comm-esr31/mozilla/storage/src/mozStorageService.cpp 2015-06-04 17:42:51.481242977 -0700
@@ -503,9 +503,14 @@
int rc;
#ifdef MOZ_STORAGE_MEMORY
- rc = ::sqlite3_config(SQLITE_CONFIG_MALLOC, &memMethods);
- if (rc != SQLITE_OK)
- return convertResultCode(rc);
+ // in case other malloc library is PRELOAD-ed
+ void *test_jemalloc = malloc(4);
+ if (::moz_malloc_usable_size(test_jemalloc)) {
+ rc = ::sqlite3_config(SQLITE_CONFIG_MALLOC, &memMethods);
+ if (rc != SQLITE_OK)
+ return convertResultCode(rc);
+ }
+ free(test_jemalloc);
#endif
// Explicitly initialize sqlite3. Although this is implicitly called by
--- comm-esr31/mozilla/toolkit/library/Makefile.in.orig 2015-06-04 17:42:51.470433696 -0700
+++ comm-esr31/mozilla/toolkit/library/Makefile.in 2015-06-04 17:42:51.481334017 -0700
@@ -24,6 +24,16 @@
include $(topsrcdir)/config/rules.mk
+ifdef MOZ_MEMORY
+ifeq ($(OS_ARCH),SunOS)
+EXTRA_DSO_LDOPTS += $(call EXPAND_LIBNAME_PATH,memory,$(LIBXUL_DIST)/lib) -Wl,-M $(topsrcdir)/config/jemalloc_solaris.map -Wl,-z,interpose
+endif
+endif
+
+ifeq ($(OS_ARCH),SunOS)
+EXTRA_DSO_LDOPTS += -lintl_unicharutil_util_internal -lxpt -lm -Wl,-z,defs
+endif
+
.PHONY: gtestxul
gtestxul:
$(MAKE) -C gtest libs LINK_GTEST=1
--- comm-esr31/mozilla/toolkit/library/libxul.mk.orig 2015-06-04 17:42:51.475797585 -0700
+++ comm-esr31/mozilla/toolkit/library/libxul.mk 2015-06-04 17:42:51.481432770 -0700
@@ -253,3 +253,13 @@
ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
OS_LIBS += $(call EXPAND_LIBNAME,usp10 oleaut32)
endif
+
+ifdef MOZ_MEMORY
+ifeq ($(OS_ARCH),SunOS)
+EXTRA_DSO_LDOPTS += $(call EXPAND_LIBNAME_PATH,memory,$(LIBXUL_DIST)/lib) -Wl,-M $(topsrcdir)/config/jemalloc_solaris.map -Wl,-z,interpose
+endif
+endif
+
+ifeq ($(OS_ARCH),SunOS)
+EXTRA_DSO_LDOPTS += -lintl_unicharutil_util_internal -lxpt -lm -Wl,-z,defs
+endif