components/desktop/thunderbird/patches/firefox31-43-solaris_jemalloc_linkage.patch
changeset 5527 611b2d6efdfe
parent 5526 570ac9aab8b2
child 5528 f2f5af510081
equal deleted inserted replaced
5526:570ac9aab8b2 5527:611b2d6efdfe
     1 This patch makes it so jemalloc is not included in firefox. Not accepted by
       
     2 the upstream community.
       
     3 Put jemalloc inside libxul. Then need firefox to depend on libxul
       
     4 and build jemalloc library.
       
     5 Remove lines - do not include memory for every program
       
     6 Need to create/add our own versions of the functions malloc_usable, jemalloc_stats, etc.
       
     7 Remove mozalloc library
       
     8 Check if we have jemalloc; if not, skip it.
       
     9 Build libxul and use flags -Wl,-z,interpose, needed to build the library.
       
    10 
       
    11 --- comm-esr31/mozilla/browser/app/Makefile.in.orig	2015-06-04 17:42:51.441312058 -0700
       
    12 +++ comm-esr31/mozilla/browser/app/Makefile.in	2015-06-04 17:42:51.478117039 -0700
       
    13 @@ -30,6 +30,12 @@
       
    14  	$(XPCOM_STANDALONE_GLUE_LDOPTS) \
       
    15  	$(NULL)
       
    16  
       
    17 +ifdef MOZ_MEMORY
       
    18 +ifeq ($(OS_ARCH),SunOS)
       
    19 +LIBS += $(LIBXUL_LIBS)
       
    20 +endif
       
    21 +endif
       
    22 +
       
    23  ifdef MOZ_LINKER
       
    24  LIBS += $(MOZ_ZLIB_LIBS)
       
    25  endif
       
    26 --- comm-esr31/mozilla/config/jemalloc_solaris.map.orig	1969-12-31 16:00:00.000000000 -0800
       
    27 +++ comm-esr31/mozilla/config/jemalloc_solaris.map	2015-06-04 17:42:51.478209751 -0700
       
    28 @@ -0,0 +1,12 @@
       
    29 +{
       
    30 +    global:
       
    31 +        calloc             = NODIRECT;
       
    32 +        free               = NODIRECT;
       
    33 +        jemalloc_stats     = NODIRECT;
       
    34 +        malloc             = NODIRECT;
       
    35 +        malloc_usable_size = NODIRECT;
       
    36 +        memalign           = NODIRECT;
       
    37 +        posix_memalign     = NODIRECT;
       
    38 +        realloc            = NODIRECT;
       
    39 +        valloc             = NODIRECT;
       
    40 +};
       
    41 --- comm-esr31/mozilla//configure.orig	2015-06-04 17:42:51.444508647 -0700
       
    42 +++ comm-esr31/mozilla//configure	2015-06-04 17:42:51.480874311 -0700
       
    43 @@ -24162,9 +24162,6 @@
       
    44    fi
       
    45  else
       
    46      MOZ_GLUE_PROGRAM_LDFLAGS='$(MKSHLIB_FORCE_ALL) $(call EXPAND_LIBNAME_PATH,mozglue,$(LIBXUL_DIST)/lib)'
       
    47 -      if test "$MOZ_MEMORY" = 1 -o \( "$LIBXUL_SDK" -a -f "$LIBXUL_SDK/lib/${LIB_PREFIX}memory.${LIB_SUFFIX}" \); then
       
    48 -    MOZ_GLUE_PROGRAM_LDFLAGS="$MOZ_GLUE_PROGRAM_LDFLAGS "'$(call EXPAND_LIBNAME_PATH,memory,$(LIBXUL_DIST)/lib)'
       
    49 -  fi
       
    50    MOZ_GLUE_PROGRAM_LDFLAGS="$MOZ_GLUE_PROGRAM_LDFLAGS "'$(MKSHLIB_UNFORCE_ALL)'
       
    51    if test -n "$GNU_CC"; then
       
    52          MOZ_GLUE_PROGRAM_LDFLAGS="$MOZ_GLUE_PROGRAM_LDFLAGS -rdynamic"
       
    53 --- comm-esr31/mozilla/memory/mozalloc/mozalloc.cpp.orig	2015-06-04 17:42:51.453412680 -0700
       
    54 +++ comm-esr31/mozilla/memory/mozalloc/mozalloc.cpp	2015-06-04 17:42:51.481002191 -0700
       
    55 @@ -200,6 +200,14 @@
       
    56  }
       
    57  #endif // if defined(HAVE_VALLOC)
       
    58  
       
    59 +#if defined(MOZ_MEMORY_SOLARIS)
       
    60 +#include "jemalloc_types.h"
       
    61 +extern "C" {
       
    62 +extern size_t malloc_usable_size(const void *ptr);
       
    63 +extern void jemalloc_stats(jemalloc_stats_t* stats);
       
    64 +}
       
    65 +#endif
       
    66 +
       
    67  size_t
       
    68  moz_malloc_usable_size(void *ptr)
       
    69  {
       
    70 @@ -209,7 +217,22 @@
       
    71  #if defined(XP_MACOSX)
       
    72      return malloc_size(ptr);
       
    73  #elif defined(HAVE_MALLOC_USABLE_SIZE) || defined(MOZ_MEMORY)
       
    74 +#if defined(SOLARIS)
       
    75 +    static bool checked = false;
       
    76 +    static bool using_jemalloc = false;
       
    77 +    if (!checked) {
       
    78 +        checked = true;
       
    79 +        jemalloc_stats_t stats;
       
    80 +        jemalloc_stats(&stats);
       
    81 +        using_jemalloc = stats.allocated;
       
    82 +    }
       
    83 +    if (using_jemalloc)
       
    84 +        return malloc_usable_size(ptr);
       
    85 +    else
       
    86 +        return 0;
       
    87 +#else
       
    88      return malloc_usable_size(ptr);
       
    89 +#endif
       
    90  #elif defined(XP_WIN)
       
    91      return _msize(ptr);
       
    92  #else
       
    93 --- comm-esr31/mozilla/security/manager/ssl/tests/unit/tlsserver/cmd/Makefile.in.orig	2015-06-04 17:42:51.459223858 -0700
       
    94 +++ comm-esr31/mozilla/security/manager/ssl/tests/unit/tlsserver/cmd/Makefile.in	2015-06-04 17:42:51.481099560 -0700
       
    95 @@ -9,7 +9,6 @@
       
    96  LIBS = \
       
    97    $(NSPR_LIBS) \
       
    98    $(NSS_LIBS) \
       
    99 -  $(MOZALLOC_LIB) \
       
   100    ../../../../../../pkix/$(LIB_PREFIX)mozillapkix.$(LIB_SUFFIX) \
       
   101    ../../../../../../pkix/test/lib/$(LIB_PREFIX)pkixtestutil.$(LIB_SUFFIX) \
       
   102    ../lib/$(LIB_PREFIX)tlsserver.$(LIB_SUFFIX) \
       
   103 --- comm-esr31/mozilla/storage/src/mozStorageService.cpp.orig	2015-06-04 17:42:51.464827762 -0700
       
   104 +++ comm-esr31/mozilla/storage/src/mozStorageService.cpp	2015-06-04 17:42:51.481242977 -0700
       
   105 @@ -503,9 +503,14 @@
       
   106    int rc;
       
   107  
       
   108  #ifdef MOZ_STORAGE_MEMORY
       
   109 -  rc = ::sqlite3_config(SQLITE_CONFIG_MALLOC, &memMethods);
       
   110 -  if (rc != SQLITE_OK)
       
   111 -    return convertResultCode(rc);
       
   112 +  // in case other malloc library is PRELOAD-ed
       
   113 +  void *test_jemalloc = malloc(4);
       
   114 +  if (::moz_malloc_usable_size(test_jemalloc)) {
       
   115 +    rc = ::sqlite3_config(SQLITE_CONFIG_MALLOC, &memMethods);
       
   116 +    if (rc != SQLITE_OK)
       
   117 +      return convertResultCode(rc);
       
   118 +  }
       
   119 +  free(test_jemalloc);
       
   120  #endif
       
   121  
       
   122    // Explicitly initialize sqlite3.  Although this is implicitly called by
       
   123 --- comm-esr31/mozilla/toolkit/library/Makefile.in.orig	2015-06-04 17:42:51.470433696 -0700
       
   124 +++ comm-esr31/mozilla/toolkit/library/Makefile.in	2015-06-04 17:42:51.481334017 -0700
       
   125 @@ -24,6 +24,16 @@
       
   126  
       
   127  include $(topsrcdir)/config/rules.mk
       
   128  
       
   129 +ifdef MOZ_MEMORY
       
   130 +ifeq ($(OS_ARCH),SunOS)
       
   131 +EXTRA_DSO_LDOPTS += $(call EXPAND_LIBNAME_PATH,memory,$(LIBXUL_DIST)/lib) -Wl,-M $(topsrcdir)/config/jemalloc_solaris.map -Wl,-z,interpose
       
   132 +endif
       
   133 +endif
       
   134 +
       
   135 +ifeq ($(OS_ARCH),SunOS)
       
   136 +EXTRA_DSO_LDOPTS += -lintl_unicharutil_util_internal -lxpt -lm -Wl,-z,defs
       
   137 +endif
       
   138 +
       
   139  .PHONY: gtestxul
       
   140  gtestxul:
       
   141  	$(MAKE) -C gtest libs LINK_GTEST=1
       
   142 --- comm-esr31/mozilla/toolkit/library/libxul.mk.orig	2015-06-04 17:42:51.475797585 -0700
       
   143 +++ comm-esr31/mozilla/toolkit/library/libxul.mk	2015-06-04 17:42:51.481432770 -0700
       
   144 @@ -253,3 +253,13 @@
       
   145  ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
       
   146  OS_LIBS += $(call EXPAND_LIBNAME,usp10 oleaut32)
       
   147  endif
       
   148 +
       
   149 +ifdef MOZ_MEMORY
       
   150 +ifeq ($(OS_ARCH),SunOS)
       
   151 +EXTRA_DSO_LDOPTS += $(call EXPAND_LIBNAME_PATH,memory,$(LIBXUL_DIST)/lib) -Wl,-M $(topsrcdir)/config/jemalloc_solaris.map -Wl,-z,interpose
       
   152 +endif
       
   153 +endif
       
   154 +
       
   155 +ifeq ($(OS_ARCH),SunOS)
       
   156 +EXTRA_DSO_LDOPTS += -lintl_unicharutil_util_internal -lxpt -lm -Wl,-z,defs
       
   157 +endif