Backout changesets beed1c584a22, 9b2413915a5e (bug 868814), 1f34ebc9eb00, 80555e0558a3 (bug 1141660), 22aea188dac5 (bug 1141731) to give us more time to figure the situation with the SDK. a=lizzard
authorMike Hommey <mh+mozilla@glandium.org>
Thu, 11 Jun 2015 01:51:00 -0400
changeset 267735 dde4eeaaa7ad22a0c55cc0f11a927aca2b790b57
parent 267734 c7499d2cdf329b2cc0f806d3b9b598fde9bd549e
child 267736 37c99d72de9a10d7b017f90541ec922ad7dcb85e
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslizzard
bugs868814, 1141660, 1141731
milestone39.0
backs outbeed1c584a2264aab11aa41484083ba49ba4c0ab
9b2413915a5ecb437051286f1330fbff534516fe
Backout changesets beed1c584a22, 9b2413915a5e (bug 868814), 1f34ebc9eb00, 80555e0558a3 (bug 1141660), 22aea188dac5 (bug 1141731) to give us more time to figure the situation with the SDK. a=lizzard
b2g/installer/package-manifest.in
browser/installer/package-manifest.in
build/gecko_templates.mozbuild
configure.in
ipc/app/moz.build
layout/media/moz.build
memory/mozalloc/moz.build
memory/mozalloc/mozalloc.cpp
memory/mozalloc/mozalloc.h
memory/mozalloc/mozalloc_abort.cpp
memory/mozalloc/mozalloc_abort.h
memory/mozalloc/mozalloc_oom.cpp
memory/mozalloc/mozalloc_oom.h
memory/mozalloc/msvc_raise_wrappers.cpp
memory/mozalloc/msvc_raise_wrappers.h
memory/mozalloc/msvc_throw_wrapper.cpp
memory/mozalloc/staticruntime/moz.build
mobile/android/installer/package-manifest.in
security/manager/ssl/tests/unit/tlsserver/cmd/moz.build
testing/mochitest/ssltunnel/moz.build
toolkit/library/moz.build
toolkit/mozapps/installer/upload-files.mk
xpcom/glue/moz.build
xpcom/glue/nomozalloc/Makefile.in
xpcom/glue/nomozalloc/moz.build
xulrunner/installer/Makefile.in
--- a/b2g/installer/package-manifest.in
+++ b/b2g/installer/package-manifest.in
@@ -64,16 +64,17 @@
 #ifndef MOZ_STATIC_JS
 @BINPATH@/@DLL_PREFIX@mozjs@DLL_SUFFIX@
 #endif
 #ifndef MOZ_FOLD_LIBS
 @BINPATH@/@DLL_PREFIX@plc4@DLL_SUFFIX@
 @BINPATH@/@DLL_PREFIX@plds4@DLL_SUFFIX@
 @BINPATH@/@DLL_PREFIX@nspr4@DLL_SUFFIX@
 #endif
+@BINPATH@/@DLL_PREFIX@mozalloc@DLL_SUFFIX@
 #ifdef MOZ_DMD
 @BINPATH@/@DLL_PREFIX@dmd@DLL_SUFFIX@
 #endif
 #ifdef XP_MACOSX
 @BINPATH@/XUL
 #else
 @BINPATH@/@DLL_PREFIX@xul@DLL_SUFFIX@
 #endif
--- a/browser/installer/package-manifest.in
+++ b/browser/installer/package-manifest.in
@@ -62,16 +62,17 @@
 @RESPATH@/updater.ini
 #endif
 
 [xpcom]
 @RESPATH@/dependentlibs.list
 #ifdef GKMEDIAS_SHARED_LIBRARY
 @BINPATH@/@DLL_PREFIX@gkmedias@DLL_SUFFIX@
 #endif
+@BINPATH@/@DLL_PREFIX@mozalloc@DLL_SUFFIX@
 #ifdef MOZ_SHARED_MOZGLUE
 @BINPATH@/@DLL_PREFIX@mozglue@DLL_SUFFIX@
 #endif
 #ifndef MOZ_STATIC_JS
 @BINPATH@/@DLL_PREFIX@mozjs@DLL_SUFFIX@
 #endif
 #ifdef MOZ_DMD
 @BINPATH@/@DLL_PREFIX@dmd@DLL_SUFFIX@
--- a/build/gecko_templates.mozbuild
+++ b/build/gecko_templates.mozbuild
@@ -27,25 +27,22 @@ def GeckoBinary(linkage='dependent', msv
     '''
     if msvcrt == 'dynamic' or CONFIG['OS_ARCH'] != 'WINNT':
         xpcomglue = 'xpcomglue'
     elif msvcrt == 'static':
         USE_STATIC_LIBS = True
         xpcomglue = 'xpcomglue_staticruntime'
         if not CONFIG['GNU_CC']:
             mozglue = None
-            if linkage == 'dependent':
-                USE_LIBS += [
-                    'mozalloc_staticruntime',
-                ]
     else:
         error('msvcrt must be "dynamic" or "static"')
 
     if linkage == 'dependent':
         USE_LIBS += [
+            'mozalloc',
             'nspr',
             '%s_s' % xpcomglue,
             'xul',
         ]
     elif linkage == 'standalone':
         DEFINES['XPCOM_GLUE'] = True
 
         USE_LIBS += [
--- a/configure.in
+++ b/configure.in
@@ -9082,21 +9082,19 @@ case "$host" in
     FIXED_EGREP="egrep"
     ;;
 esac
 
 # Run jemalloc configure script
 
 if test -z "$MOZ_NATIVE_JEMALLOC" -a "$MOZ_MEMORY" && test -n "$MOZ_JEMALLOC3" -o -n "$MOZ_REPLACE_MALLOC"; then
   ac_configure_args="--build=$build --host=$target --enable-stats --with-jemalloc-prefix=je_ --disable-valgrind"
-  # We're using memalign for _aligned_malloc in memory/build/mozmemory_wrap.c
-  # on Windows, so just export memalign on all platforms.
-  ac_configure_args="$ac_configure_args ac_cv_func_memalign=yes"
   if test -n "$MOZ_REPLACE_MALLOC"; then
-    # When using replace_malloc, we always want valloc exported from jemalloc.
+    # When using replace_malloc, we always want memalign and valloc exported from jemalloc.
+    ac_configure_args="$ac_configure_args ac_cv_func_memalign=yes"
     ac_configure_args="$ac_configure_args ac_cv_func_valloc=yes"
   fi
   if test -n "$MOZ_JEMALLOC3"; then
     case "${OS_ARCH}" in
       WINNT|Darwin)
         # We want jemalloc functions to be kept hidden on both Mac and Windows
         # See memory/build/mozmemory_wrap.h for details.
         ac_configure_args="$ac_configure_args --without-export"
--- a/ipc/app/moz.build
+++ b/ipc/app/moz.build
@@ -10,26 +10,23 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'andr
         'MozillaRuntimeMainAndroid.cpp',
     ]
 else:
     kwargs = {
         'linkage': None,
     }
     if CONFIG['MOZ_SANDBOX'] and CONFIG['OS_ARCH'] == 'WINNT':
         kwargs['msvcrt'] = 'static'
-        if not CONFIG['GNU_CC']:
-            USE_LIBS += [
-                'mozalloc_staticruntime',
-            ]
     GeckoProgram(CONFIG['MOZ_CHILD_PROCESS_NAME'], **kwargs)
 
     SOURCES += [
         'MozillaRuntimeMain.cpp',
     ]
     USE_LIBS += [
+        'mozalloc',
         'nspr',
         'xul',
     ]
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 LOCAL_INCLUDES += [
     '/toolkit/xre',
@@ -49,16 +46,17 @@ if CONFIG['MOZ_SANDBOX'] and CONFIG['OS_
         '/security',
         '/security/sandbox/chromium',
     ]
     USE_LIBS += [
         'rlz',
         'sandbox_staticruntime_s',
     ]
     DELAYLOAD_DLLS += [
+        'mozalloc.dll',
         'nss3.dll',
         'xul.dll'
     ]
     DEFINES['HASH_NODE_ID_WITH_DEVICE_ID'] = 1;
     SOURCES += [
         'sha256.c',
     ]
 
--- a/layout/media/moz.build
+++ b/layout/media/moz.build
@@ -5,16 +5,17 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 with Files('**'):
     BUG_COMPONENT = ('Core', 'Video/Audio')
 
 if CONFIG['GKMEDIAS_SHARED_LIBRARY']:
     GeckoSharedLibrary('gkmedias', linkage=None)
     USE_LIBS += [
+        'mozalloc',
         'nspr',
     ]
 else:
     Library('gkmedias')
 
 
 if CONFIG['MOZ_WEBRTC']:
     DIRS += ['webrtc']
--- a/memory/mozalloc/moz.build
+++ b/memory/mozalloc/moz.build
@@ -33,26 +33,23 @@ if CONFIG['WRAP_STL_INCLUDES']:
             ]
 
 UNIFIED_SOURCES += [
     'mozalloc.cpp',
     'mozalloc_abort.cpp',
     'mozalloc_oom.cpp',
 ]
 
-FINAL_LIBRARY = 'mozglue'
+if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
+    Library('mozalloc')
+else:
+    GeckoSharedLibrary('mozalloc', linkage=None)
+    SDK_LIBRARY = True
 
 # The strndup declaration in string.h is in an ifdef __USE_GNU section
 DEFINES['_GNU_SOURCE'] = True
 
 GENERATED_INCLUDES += ['/xpcom']
 
 DISABLE_STL_WRAPPING = True
 
 if CONFIG['CLANG_CXX'] or CONFIG['_MSC_VER']:
     FAIL_ON_WARNINGS = True
-
-DEFINES['IMPL_MFBT'] = True
-
-if CONFIG['_MSC_VER']:
-    DIRS += ['staticruntime']
-
-LOCAL_INCLUDES += ['/memory/build']
--- a/memory/mozalloc/mozalloc.cpp
+++ b/memory/mozalloc/mozalloc.cpp
@@ -1,191 +1,154 @@
 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: sw=4 ts=4 et :
  */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include <stddef.h>             // for size_t
-
-// Building with USE_STATIC_LIBS = True sets -MT instead of -MD. -MT sets _MT,
-// while -MD sets _MT and _DLL.
-#if defined(_MT) && !defined(_DLL)
-#define MOZ_STATIC_RUNTIME
-#endif
-
-#if defined(MOZ_MEMORY) && !defined(MOZ_STATIC_RUNTIME)
-// mozalloc.cpp is part of the same library as mozmemory, thus MOZ_MEMORY_IMPL
-// is needed.
-#define MOZ_MEMORY_IMPL
-#include "mozmemory_wrap.h"
-
-#if defined(XP_MACOSX)
-#include <malloc/malloc.h> // for malloc_size
-#endif
-
-// See mozmemory_wrap.h for more details. This file is part of libmozglue, so
-// it needs to use _impl suffixes. However, with libmozglue growing, this is
-// becoming cumbersome, so we will likely use a malloc.h wrapper of some sort
-// and allow the use of the functions without a _impl suffix.
-#define MALLOC_DECL(name, return_type, ...) \
-  extern "C" MOZ_MEMORY_API return_type name ## _impl(__VA_ARGS__);
-#define MALLOC_FUNS MALLOC_FUNCS_MALLOC
-#include "malloc_decls.h"
-
-extern "C" MOZ_MEMORY_API char *strdup_impl(const char *);
-extern "C" MOZ_MEMORY_API char *strndup_impl(const char *, size_t);
-
-#else
-// When jemalloc is disabled, or when building the static runtime variant,
-// we need not to use the suffixes.
-
-#if defined(MALLOC_H)
-#  include MALLOC_H             // for memalign, valloc, malloc_size, malloc_us
-#endif // if defined(MALLOC_H)
-#include <stdlib.h>             // for malloc, free
-#if defined(XP_UNIX)
-#  include <unistd.h>           // for valloc on *BSD
-#endif //if defined(XP_UNIX)
-
-#define malloc_impl malloc
-#define posix_memalign_impl posix_memalign
-#define calloc_impl calloc
-#define realloc_impl realloc
-#define free_impl free
-#define memalign_impl memalign
-#define valloc_impl valloc
-#define malloc_usable_size_impl malloc_usable_size
-#define strdup_impl strdup
-#define strndup_impl strndup
-
-#endif
-
 #include <errno.h>
 #include <new>                  // for std::bad_alloc
 #include <string.h>
 
 #include <sys/types.h>
 
+#if defined(MALLOC_H)
+#  include MALLOC_H             // for memalign, valloc, malloc_size, malloc_usable_size
+#endif // if defined(MALLOC_H)
+#include <stddef.h>             // for size_t
+#include <stdlib.h>             // for malloc, free
+#if defined(XP_UNIX)
+#  include <unistd.h>           // for valloc on *BSD
+#endif //if defined(XP_UNIX)
+
+#if defined(XP_WIN)
+#  define MOZALLOC_EXPORT __declspec(dllexport)
+#endif
+
 #include "mozilla/mozalloc.h"
 #include "mozilla/mozalloc_oom.h"  // for mozalloc_handle_oom
 
+/* Windows doesn't have malloc_usable_size, but jemalloc has */
+#if defined(MOZ_MEMORY_WINDOWS)
+extern "C" size_t malloc_usable_size(const void *ptr);
+#endif
+
 #ifdef __GNUC__
 #define LIKELY(x)    (__builtin_expect(!!(x), 1))
 #define UNLIKELY(x)  (__builtin_expect(!!(x), 0))
 #else
 #define LIKELY(x)    (x)
 #define UNLIKELY(x)  (x)
 #endif
 
 void
 moz_free(void* ptr)
 {
-    free_impl(ptr);
+    free(ptr);
 }
 
 void*
 moz_xmalloc(size_t size)
 {
-    void* ptr = malloc_impl(size);
+    void* ptr = malloc(size);
     if (UNLIKELY(!ptr && size)) {
         mozalloc_handle_oom(size);
         return moz_xmalloc(size);
     }
     return ptr;
 }
 void*
 moz_malloc(size_t size)
 {
-    return malloc_impl(size);
+    return malloc(size);
 }
 
 void*
 moz_xcalloc(size_t nmemb, size_t size)
 {
-    void* ptr = calloc_impl(nmemb, size);
+    void* ptr = calloc(nmemb, size);
     if (UNLIKELY(!ptr && nmemb && size)) {
         mozalloc_handle_oom(size);
         return moz_xcalloc(nmemb, size);
     }
     return ptr;
 }
 void*
 moz_calloc(size_t nmemb, size_t size)
 {
-    return calloc_impl(nmemb, size);
+    return calloc(nmemb, size);
 }
 
 void*
 moz_xrealloc(void* ptr, size_t size)
 {
-    void* newptr = realloc_impl(ptr, size);
+    void* newptr = realloc(ptr, size);
     if (UNLIKELY(!newptr && size)) {
         mozalloc_handle_oom(size);
         return moz_xrealloc(ptr, size);
     }
     return newptr;
 }
 void*
 moz_realloc(void* ptr, size_t size)
 {
-    return realloc_impl(ptr, size);
+    return realloc(ptr, size);
 }
 
 char*
 moz_xstrdup(const char* str)
 {
-    char* dup = strdup_impl(str);
+    char* dup = strdup(str);
     if (UNLIKELY(!dup)) {
         mozalloc_handle_oom(0);
         return moz_xstrdup(str);
     }
     return dup;
 }
 char*
 moz_strdup(const char* str)
 {
-    return strdup_impl(str);
+    return strdup(str);
 }
 
 #if defined(HAVE_STRNDUP)
 char*
 moz_xstrndup(const char* str, size_t strsize)
 {
-    char* dup = strndup_impl(str, strsize);
+    char* dup = strndup(str, strsize);
     if (UNLIKELY(!dup)) {
         mozalloc_handle_oom(strsize);
         return moz_xstrndup(str, strsize);
     }
     return dup;
 }
 char*
 moz_strndup(const char* str, size_t strsize)
 {
-    return strndup_impl(str, strsize);
+    return strndup(str, strsize);
 }
 #endif  // if defined(HAVE_STRNDUP)
 
 #if defined(HAVE_POSIX_MEMALIGN)
 int
 moz_xposix_memalign(void **ptr, size_t alignment, size_t size)
 {
-    int err = posix_memalign_impl(ptr, alignment, size);
+    int err = posix_memalign(ptr, alignment, size);
     if (UNLIKELY(err && ENOMEM == err)) {
         mozalloc_handle_oom(size);
         return moz_xposix_memalign(ptr, alignment, size);
     }
     // else: (0 == err) or (EINVAL == err)
     return err;
 }
 int
 moz_posix_memalign(void **ptr, size_t alignment, size_t size)
 {
-    int code = posix_memalign_impl(ptr, alignment, size);
+    int code = posix_memalign(ptr, alignment, size);
     if (code)
         return code;
 
 #if defined(XP_MACOSX)
     // Workaround faulty OSX posix_memalign, which provides memory with the
     // incorrect alignment sometimes, but returns 0 as if nothing was wrong.
     size_t mask = alignment - 1;
     if (((size_t)(*ptr) & mask) != 0) {
@@ -199,64 +162,62 @@ moz_posix_memalign(void **ptr, size_t al
 
 }
 #endif // if defined(HAVE_POSIX_MEMALIGN)
 
 #if defined(HAVE_MEMALIGN)
 void*
 moz_xmemalign(size_t boundary, size_t size)
 {
-    void* ptr = memalign_impl(boundary, size);
+    void* ptr = memalign(boundary, size);
     if (UNLIKELY(!ptr && EINVAL != errno)) {
         mozalloc_handle_oom(size);
         return moz_xmemalign(boundary, size);
     }
     // non-NULL ptr or errno == EINVAL
     return ptr;
 }
 void*
 moz_memalign(size_t boundary, size_t size)
 {
-    return memalign_impl(boundary, size);
+    return memalign(boundary, size);
 }
 #endif // if defined(HAVE_MEMALIGN)
 
 #if defined(HAVE_VALLOC)
 void*
 moz_xvalloc(size_t size)
 {
-    void* ptr = valloc_impl(size);
+    void* ptr = valloc(size);
     if (UNLIKELY(!ptr)) {
         mozalloc_handle_oom(size);
         return moz_xvalloc(size);
     }
     return ptr;
 }
 void*
 moz_valloc(size_t size)
 {
-    return valloc_impl(size);
+    return valloc(size);
 }
 #endif // if defined(HAVE_VALLOC)
 
-#ifndef MOZ_STATIC_RUNTIME
 size_t
 moz_malloc_usable_size(void *ptr)
 {
     if (!ptr)
         return 0;
 
 #if defined(XP_MACOSX)
     return malloc_size(ptr);
 #elif defined(HAVE_MALLOC_USABLE_SIZE) || defined(MOZ_MEMORY)
-    return malloc_usable_size_impl(ptr);
+    return malloc_usable_size(ptr);
 #elif defined(XP_WIN)
     return _msize(ptr);
 #else
     return 0;
 #endif
 }
 
 size_t moz_malloc_size_of(const void *ptr)
 {
     return moz_malloc_usable_size((void *)ptr);
 }
-#endif
--- a/memory/mozalloc/mozalloc.h
+++ b/memory/mozalloc/mozalloc.h
@@ -19,20 +19,33 @@
 #endif
 #include "xpcom-config.h"
 
 #if defined(__cplusplus)
 #include "mozilla/fallible.h"
 #include "mozilla/TemplateLib.h"
 #endif
 #include "mozilla/Attributes.h"
-#include "mozilla/Types.h"
 
 #define MOZALLOC_HAVE_XMALLOC
 
+#if defined(MOZALLOC_EXPORT)
+/* do nothing: it's been defined to __declspec(dllexport) by
+ * mozalloc*.cpp on platforms where that's required. */
+#elif defined(XP_WIN)
+#  define MOZALLOC_EXPORT __declspec(dllimport)
+#elif defined(HAVE_VISIBILITY_ATTRIBUTE)
+/* Make sure symbols are still exported even if we're wrapped in a
+ * |visibility push(hidden)| blanket. */
+#  define MOZALLOC_EXPORT __attribute__ ((visibility ("default")))
+#else
+#  define MOZALLOC_EXPORT
+#endif
+
+
 #if defined(MOZ_ALWAYS_INLINE_EVEN_DEBUG)
 #  define MOZALLOC_INLINE MOZ_ALWAYS_INLINE_EVEN_DEBUG
 #elif defined(HAVE_FORCEINLINE)
 #  define MOZALLOC_INLINE __forceinline
 #else
 #  define MOZALLOC_INLINE inline
 #endif
 
@@ -57,83 +70,83 @@ extern "C" {
  * NULL pointers if memory is exhausted: their return value must be
  * checked.
  *
  * All these allocation functions are *guaranteed* to return a pointer
  * to memory allocated in such a way that that memory can be freed by
  * passing that pointer to |moz_free()|.
  */
 
-MFBT_API
+MOZALLOC_EXPORT
 void moz_free(void* ptr);
 
-MFBT_API void* moz_xmalloc(size_t size)
+MOZALLOC_EXPORT void* moz_xmalloc(size_t size)
     NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
 
-MFBT_API
+MOZALLOC_EXPORT
 void* moz_malloc(size_t size)
     NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
 
 
-MFBT_API void* moz_xcalloc(size_t nmemb, size_t size)
+MOZALLOC_EXPORT void* moz_xcalloc(size_t nmemb, size_t size)
     NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
 
-MFBT_API void* moz_calloc(size_t nmemb, size_t size)
+MOZALLOC_EXPORT void* moz_calloc(size_t nmemb, size_t size)
     NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
 
 
-MFBT_API void* moz_xrealloc(void* ptr, size_t size)
+MOZALLOC_EXPORT void* moz_xrealloc(void* ptr, size_t size)
     NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
 
-MFBT_API void* moz_realloc(void* ptr, size_t size)
+MOZALLOC_EXPORT void* moz_realloc(void* ptr, size_t size)
     NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
 
 
-MFBT_API char* moz_xstrdup(const char* str)
+MOZALLOC_EXPORT char* moz_xstrdup(const char* str)
     NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
 
-MFBT_API char* moz_strdup(const char* str)
+MOZALLOC_EXPORT char* moz_strdup(const char* str)
     NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
 
-MFBT_API size_t moz_malloc_usable_size(void *ptr);
+MOZALLOC_EXPORT size_t moz_malloc_usable_size(void *ptr);
 
-MFBT_API size_t moz_malloc_size_of(const void *ptr);
+MOZALLOC_EXPORT size_t moz_malloc_size_of(const void *ptr);
 
 #if defined(HAVE_STRNDUP)
-MFBT_API char* moz_xstrndup(const char* str, size_t strsize)
+MOZALLOC_EXPORT char* moz_xstrndup(const char* str, size_t strsize)
     NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
 
-MFBT_API char* moz_strndup(const char* str, size_t strsize)
+MOZALLOC_EXPORT char* moz_strndup(const char* str, size_t strsize)
     NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
 #endif /* if defined(HAVE_STRNDUP) */
 
 
 #if defined(HAVE_POSIX_MEMALIGN)
-MFBT_API int moz_xposix_memalign(void **ptr, size_t alignment, size_t size)
+MOZALLOC_EXPORT int moz_xposix_memalign(void **ptr, size_t alignment, size_t size)
     NS_WARN_UNUSED_RESULT;
 
-MFBT_API int moz_posix_memalign(void **ptr, size_t alignment, size_t size)
+MOZALLOC_EXPORT int moz_posix_memalign(void **ptr, size_t alignment, size_t size)
     NS_WARN_UNUSED_RESULT;
 #endif /* if defined(HAVE_POSIX_MEMALIGN) */
 
 
 #if defined(HAVE_MEMALIGN)
-MFBT_API void* moz_xmemalign(size_t boundary, size_t size)
+MOZALLOC_EXPORT void* moz_xmemalign(size_t boundary, size_t size)
     NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
 
-MFBT_API void* moz_memalign(size_t boundary, size_t size)
+MOZALLOC_EXPORT void* moz_memalign(size_t boundary, size_t size)
     NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
 #endif /* if defined(HAVE_MEMALIGN) */
 
 
 #if defined(HAVE_VALLOC)
-MFBT_API void* moz_xvalloc(size_t size)
+MOZALLOC_EXPORT void* moz_xvalloc(size_t size)
     NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
 
-MFBT_API void* moz_valloc(size_t size)
+MOZALLOC_EXPORT void* moz_valloc(size_t size)
     NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
 #endif /* if defined(HAVE_VALLOC) */
 
 
 #ifdef __cplusplus
 } /* extern "C" */
 #endif /* ifdef __cplusplus */
 
@@ -158,17 +171,17 @@ MFBT_API void* moz_valloc(size_t size)
  * throw that exception.  This declaration is consistent with the rule
  * that |::operator new() throw(std::bad_alloc)| will never return NULL.
  */
 
 /* NB: This is defined just to silence vacuous warnings about symbol
  * visibility on OS X/gcc. These symbols are force-inline and not
  * exported. */
 #if defined(XP_MACOSX)
-#  define MOZALLOC_EXPORT_NEW MFBT_API
+#  define MOZALLOC_EXPORT_NEW MOZALLOC_EXPORT
 #else
 #  define MOZALLOC_EXPORT_NEW
 #endif
 
 #if defined(ANDROID)
 /*
  * It's important to always specify 'throw()' in GCC because it's used to tell
  * GCC that 'new' may return null. That makes GCC null-check the result before
--- a/memory/mozalloc/mozalloc_abort.cpp
+++ b/memory/mozalloc/mozalloc_abort.cpp
@@ -1,15 +1,19 @@
 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: sw=4 ts=4 et :
  */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+#if defined(XP_WIN)
+#  define MOZALLOC_EXPORT __declspec(dllexport)
+#endif
+
 #include "mozilla/mozalloc_abort.h"
 
 #ifdef ANDROID
 # include <android/log.h>
 #endif
 #ifdef MOZ_WIDGET_ANDROID
 # include "APKOpen.h"
 # include "dlfcn.h"
--- a/memory/mozalloc/mozalloc_abort.h
+++ b/memory/mozalloc/mozalloc_abort.h
@@ -4,25 +4,37 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_mozalloc_abort_h
 #define mozilla_mozalloc_abort_h
 
 #include "mozilla/Attributes.h"
-#include "mozilla/Types.h"
+
+#if defined(MOZALLOC_EXPORT)
+// do nothing: it's been defined to __declspec(dllexport) by
+// mozalloc*.cpp on platforms where that's required
+#elif defined(XP_WIN)
+#  define MOZALLOC_EXPORT __declspec(dllimport)
+#elif defined(HAVE_VISIBILITY_ATTRIBUTE)
+/* Make sure symbols are still exported even if we're wrapped in a
+ * |visibility push(hidden)| blanket. */
+#  define MOZALLOC_EXPORT __attribute__ ((visibility ("default")))
+#else
+#  define MOZALLOC_EXPORT
+#endif
 
 /**
  * Terminate this process in such a way that breakpad is triggered, if
  * at all possible.
  *
  * Note: MOZ_NORETURN seems to break crash stacks on ARM, so we don't
  * use that annotation there.
  */
-MFBT_API
+MOZALLOC_EXPORT
 #if !defined(__arm__)
   MOZ_NORETURN
 #endif
   void mozalloc_abort(const char* const msg);
 
 
 #endif  /* ifndef mozilla_mozalloc_abort_h */
--- a/memory/mozalloc/mozalloc_oom.cpp
+++ b/memory/mozalloc/mozalloc_oom.cpp
@@ -1,15 +1,19 @@
 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: sw=4 ts=4 et :
  */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+#if defined(XP_WIN)
+#  define MOZALLOC_EXPORT __declspec(dllexport)
+#endif
+
 #include "mozilla/mozalloc_abort.h"
 #include "mozilla/mozalloc_oom.h"
 #include "mozilla/Assertions.h"
 
 static mozalloc_oom_abort_handler gAbortHandler;
 
 #define OOM_MSG_LEADER "out of memory: 0x"
 #define OOM_MSG_DIGITS "0000000000000000" // large enough for 2^64
--- a/memory/mozalloc/mozalloc_oom.h
+++ b/memory/mozalloc/mozalloc_oom.h
@@ -5,27 +5,44 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_mozalloc_oom_h
 #define mozilla_mozalloc_oom_h
 
 #include "mozalloc.h"
 
+#if defined(MOZALLOC_EXPORT)
+// do nothing: it's been defined to __declspec(dllexport) by
+// mozalloc*.cpp on platforms where that's required
+#elif defined(XP_WIN)
+#  define MOZALLOC_EXPORT __declspec(dllimport)
+#elif defined(HAVE_VISIBILITY_ATTRIBUTE)
+/* Make sure symbols are still exported even if we're wrapped in a
+ * |visibility push(hidden)| blanket. */
+#  define MOZALLOC_EXPORT __attribute__ ((visibility ("default")))
+#else
+#  define MOZALLOC_EXPORT
+#endif
+
+
 /**
- * Called when memory is critically low.  Returns iff it was able to
+ * Called when memory is critically low.  Returns iff it was able to 
  * remedy the critical memory situation; if not, it will abort().
+ * 
+ * We have to re-#define MOZALLOC_EXPORT because this header can be
+ * used indepedently of mozalloc.h.
  */
-MFBT_API void mozalloc_handle_oom(size_t requestedSize);
+MOZALLOC_EXPORT void mozalloc_handle_oom(size_t requestedSize);
 
 /**
  * Called by embedders (specifically Mozilla breakpad) which wants to be
  * notified of an intentional abort, to annotate any crash report with
  * the size of the allocation on which we aborted.
  */
 typedef void (*mozalloc_oom_abort_handler)(size_t size);
-MFBT_API void mozalloc_set_oom_abort_handler(mozalloc_oom_abort_handler handler);
+MOZALLOC_EXPORT void mozalloc_set_oom_abort_handler(mozalloc_oom_abort_handler handler);
 
 /* TODO: functions to query system memory usage and register
  * critical-memory handlers. */
 
 
 #endif /* ifndef mozilla_mozalloc_oom_h */
--- a/memory/mozalloc/msvc_raise_wrappers.cpp
+++ b/memory/mozalloc/msvc_raise_wrappers.cpp
@@ -2,16 +2,20 @@
  * vim: sw=4 ts=4 et :
  */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include <stdio.h>
 
+#if defined(XP_WIN)
+#  define MOZALLOC_EXPORT __declspec(dllexport)
+#endif
+
 #include "mozalloc_abort.h"
 
 #define MOZALLOC_DONT_WRAP_RAISE_FUNCTIONS
 #include "mozilla/throw_msvc.h"
 
 __declspec(noreturn) static void abort_from_exception(const char* const which,
                                                       const char* const what);
 static void
--- a/memory/mozalloc/msvc_raise_wrappers.h
+++ b/memory/mozalloc/msvc_raise_wrappers.h
@@ -18,21 +18,21 @@
 #include "mozilla/mozalloc_abort.h"
 
 namespace std {
 
 // NB: user code is not supposed to touch the std:: namespace.  We're
 // doing this after careful review because we want to define our own
 // exception throwing semantics.  Don't try this at home!
 
-MFBT_API __declspec(noreturn) void moz_Xinvalid_argument(const char*);
-MFBT_API __declspec(noreturn) void moz_Xlength_error(const char*);
-MFBT_API __declspec(noreturn) void moz_Xout_of_range(const char*);
-MFBT_API __declspec(noreturn) void moz_Xoverflow_error(const char*);
-MFBT_API __declspec(noreturn) void moz_Xruntime_error(const char*);
+MOZALLOC_EXPORT __declspec(noreturn) void moz_Xinvalid_argument(const char*);
+MOZALLOC_EXPORT __declspec(noreturn) void moz_Xlength_error(const char*);
+MOZALLOC_EXPORT __declspec(noreturn) void moz_Xout_of_range(const char*);
+MOZALLOC_EXPORT __declspec(noreturn) void moz_Xoverflow_error(const char*);
+MOZALLOC_EXPORT __declspec(noreturn) void moz_Xruntime_error(const char*);
 
 } // namespace std
 
 #ifndef MOZALLOC_DONT_WRAP_RAISE_FUNCTIONS
 
 #  define _Xinvalid_argument  moz_Xinvalid_argument
 #  define _Xlength_error      moz_Xlength_error
 #  define _Xout_of_range      moz_Xout_of_range
--- a/memory/mozalloc/msvc_throw_wrapper.cpp
+++ b/memory/mozalloc/msvc_throw_wrapper.cpp
@@ -2,16 +2,20 @@
  * vim: sw=4 ts=4 et :
  */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include <exception>
 
+#if defined(XP_WIN)
+#  define MOZALLOC_EXPORT __declspec(dllexport)
+#endif
+
 #include "mozilla/mozalloc_abort.h"
 
 namespace std {
 
 // NB: user code is not supposed to touch the std:: namespace.  We're
 // doing this after careful review because we want to define our own
 // exception throwing semantics.  Don't try this at home!
 
deleted file mode 100644
--- a/memory/mozalloc/staticruntime/moz.build
+++ /dev/null
@@ -1,38 +0,0 @@
-# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
-# vim: set filetype=python:
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-NO_VISIBILITY_FLAGS = True
-
-if CONFIG['MOZ_MSVC_STL_WRAP_RAISE'] or CONFIG['MOZ_MSVC_STL_WRAP_Throw']:
-    build_msvc_wrappers = 1
-else:
-    build_msvc_wrappers = 0
-
-if CONFIG['WRAP_STL_INCLUDES']:
-    DEFINES['_HAS_EXCEPTIONS'] = 0
-    if build_msvc_wrappers:
-        SOURCES += [
-            '../msvc_raise_wrappers.cpp',
-            '../msvc_throw_wrapper.cpp',
-        ]
-
-UNIFIED_SOURCES += [
-    '../mozalloc.cpp',
-    '../mozalloc_abort.cpp',
-    '../mozalloc_oom.cpp',
-]
-
-GENERATED_INCLUDES += ['/xpcom']
-
-DISABLE_STL_WRAPPING = True
-
-FAIL_ON_WARNINGS = True
-
-DEFINES['IMPL_MFBT'] = True
-
-USE_STATIC_LIBS = True
-
-Library('mozalloc_staticruntime')
--- a/mobile/android/installer/package-manifest.in
+++ b/mobile/android/installer/package-manifest.in
@@ -37,16 +37,17 @@
 #ifdef MOZ_DMD
 @BINPATH@/@DLL_PREFIX@dmd@DLL_SUFFIX@
 #endif
 #ifndef MOZ_FOLD_LIBS
 @BINPATH@/@DLL_PREFIX@plc4@DLL_SUFFIX@
 @BINPATH@/@DLL_PREFIX@plds4@DLL_SUFFIX@
 @BINPATH@/@DLL_PREFIX@nspr4@DLL_SUFFIX@
 #endif
+@BINPATH@/@DLL_PREFIX@mozalloc@DLL_SUFFIX@
 @BINPATH@/@DLL_PREFIX@omxplugin@DLL_SUFFIX@
 @BINPATH@/@DLL_PREFIX@omxplugingb@DLL_SUFFIX@
 @BINPATH@/@DLL_PREFIX@omxplugingb235@DLL_SUFFIX@
 @BINPATH@/@DLL_PREFIX@omxpluginhc@DLL_SUFFIX@
 @BINPATH@/@DLL_PREFIX@omxpluginkk@DLL_SUFFIX@
 @BINPATH@/@DLL_PREFIX@xul@DLL_SUFFIX@
 
 @BINPATH@/@DLL_PREFIX@nssckbi@DLL_SUFFIX@
--- a/security/manager/ssl/tests/unit/tlsserver/cmd/moz.build
+++ b/security/manager/ssl/tests/unit/tlsserver/cmd/moz.build
@@ -13,16 +13,17 @@ GeckoSimplePrograms([
     'OCSPStaplingServer',
 ], linkage=None)
 
 LOCAL_INCLUDES += [
     '../lib',
 ]
 
 USE_LIBS += [
+    'mozalloc',
     'mozillapkix',
     'nspr',
     'nss',
     'pkixtestutil',
     'tlsserver',
 ]
 
 CXXFLAGS += CONFIG['TK_CFLAGS']
--- a/testing/mochitest/ssltunnel/moz.build
+++ b/testing/mochitest/ssltunnel/moz.build
@@ -6,15 +6,16 @@
 
 GeckoProgram('ssltunnel', linkage=None)
 
 SOURCES += [
     'ssltunnel.cpp',
 ]
 
 USE_LIBS += [
+    'mozalloc',
     'nspr',
     'nss',
 ]
 
 # This isn't XPCOM code, but it wants to use STL, so disable the STL
 # wrappers
 DISABLE_STL_WRAPPING = True
--- a/toolkit/library/moz.build
+++ b/toolkit/library/moz.build
@@ -108,16 +108,17 @@ USE_LIBS += [
 
 if CONFIG['MOZ_SANDBOX'] and CONFIG['OS_ARCH'] == 'WINNT':
     USE_LIBS += [
         'sandboxbroker',
     ]
 
 USE_LIBS += [
     'gkmedias',
+    'mozalloc',
     'nspr',
     'nss',
     'sqlite',
     'zlib',
 ]
 
 if CONFIG['USE_ICU']:
     USE_LIBS += [
--- a/toolkit/mozapps/installer/upload-files.mk
+++ b/toolkit/mozapps/installer/upload-files.mk
@@ -265,16 +265,17 @@ endif #Create an RPM file
 ifeq ($(MOZ_PKG_FORMAT),APK)
 
 JAVA_CLASSPATH = $(ANDROID_SDK)/android.jar
 include $(MOZILLA_DIR)/config/android-common.mk
 
 DIST_FILES =
 
 # Place the files in the order they are going to be opened by the linker
+DIST_FILES += libmozalloc.so
 ifndef MOZ_FOLD_LIBS
 DIST_FILES += \
   libnspr4.so \
   libplc4.so \
   libplds4.so \
   libmozsqlite3.so \
   libnssutil3.so \
   $(NULL)
--- a/xpcom/glue/moz.build
+++ b/xpcom/glue/moz.build
@@ -2,17 +2,17 @@
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 with Files('nsString*'):
     BUG_COMPONENT = ('Core', 'String')
 
-DIRS += ['standalone']
+DIRS += ['standalone', 'nomozalloc']
 
 # On win we build two glue libs - glue linked to crt dlls here and in staticruntime we build
 # a statically linked glue lib.
 if CONFIG['OS_ARCH'] == 'WINNT':
     DIRS += ['staticruntime']
 
 EXPORTS += [
     'MainThreadUtils.h',
new file mode 100644
--- /dev/null
+++ b/xpcom/glue/nomozalloc/Makefile.in
@@ -0,0 +1,8 @@
+# vim:set ts=8 sw=8 sts=8 noet:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+DIST_INSTALL	= 1
+# Force to build a static library only
+NO_EXPAND_LIBS = 1
new file mode 100644
--- /dev/null
+++ b/xpcom/glue/nomozalloc/moz.build
@@ -0,0 +1,49 @@
+# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+include('../objs.mozbuild')
+
+UNIFIED_SOURCES += xpcom_gluens_src_cppsrcs
+UNIFIED_SOURCES += xpcom_glue_src_cppsrcs
+
+UNIFIED_SOURCES += [
+    '../GenericModule.cpp',
+    '../nsStringAPI.cpp',
+]
+
+Library('xpcomglue_s_nomozalloc')
+
+SDK_LIBRARY = True
+
+# we don't want the shared lib, but we want to force the creation of a static lib.
+FORCE_STATIC_LIB = True
+
+if CONFIG['_MSC_VER']:
+    DEFINES['_USE_ANSI_CPP'] = True
+    # Don't include directives about which CRT to use
+    CFLAGS += ['-Zl']
+    CXXFLAGS += ['-Zl']
+
+DEFINES['MOZ_NO_MOZALLOC'] = True
+
+LOCAL_INCLUDES += [
+    '../../build',
+]
+
+# Pretend we're statically linking the CRT, even though we might not be: this
+# avoids "msvcrp" and assembly dependencies from creeping into the directives
+# for this library on Windows.
+USE_STATIC_LIBS = True
+
+# Don't use STL wrappers here (i.e. wrapped <new>); they require mozalloc
+DISABLE_STL_WRAPPING = True
+
+FAIL_ON_WARNINGS = True
+
+# Include fallible for third party code using the xpcom glue
+USE_LIBS += [
+    'fallible',
+]
--- a/xulrunner/installer/Makefile.in
+++ b/xulrunner/installer/Makefile.in
@@ -51,17 +51,17 @@ NSPR_VERSION=$(shell $(NSPR_CONFIG) --ve
 else
 pkg_config_files += mozilla-nspr.pc
 NSPR_NAME=mozilla-nspr
 FULL_NSPR_CFLAGS=-I\$${includedir}
 FULL_NSPR_LIBS=$(subst $(prefix),\$${sdkdir},$(shell $(DEPTH)/nsprpub/config/nspr-config --libs))
 NSPR_VERSION=$(shell $(DEPTH)/nsprpub/config/nspr-config --version)
 endif
 
-MOZ_XUL_LINK = -lxpcomglue_s -lxul
+MOZ_XUL_LINK = -lxpcomglue_s -lxul -lmozalloc
 ifdef JS_SHARED_LIBRARY
 MOZ_JS_LINK = -lmozjs
 else
 MOZ_JS_LINK = $(MOZ_XUL_LINK)
 endif
 
 $(warning FULL_NSPR_CFLAGS=$(FULL_NSPR_CFLAGS))