Bug 441324, part 3: Configure and build changes for libmozalloc. r=bsmedberg
authorChris Jones <jones.chris.g@gmail.com>
Wed, 03 Mar 2010 23:02:57 -0600
changeset 38924 81bd90ae58996af98822ee4fe1cacc35f328ca95
parent 38923 5257693bcfbf901398bce97f823b5ba95b43dd53
child 38925 130a52770a7b4ee8621777ded51484bb10869a99
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg
bugs441324
milestone1.9.3a3pre
Bug 441324, part 3: Configure and build changes for libmozalloc. r=bsmedberg
Makefile.in
browser/installer/package-manifest.in
build/Makefile.in
config/config.mk
configure.in
js/ctypes/tests/Makefile.in
js/src/config/config.mk
memory/mozalloc/Makefile.in
modules/plugin/default/windows/Makefile.in
toolkit/components/faststart/Makefile.in
toolkit/library/Makefile.in
widget/src/xremoteclient/Makefile.in
xpcom/build/Makefile.in
xpcom/stub/Makefile.in
--- a/Makefile.in
+++ b/Makefile.in
@@ -56,23 +56,20 @@ default::
 TIERS += base
 
 #
 # tier "base" - basic setup
 #
 tier_base_dirs = \
 	config \
 	build \
+	memory \
 	probes \
 	$(NULL)
 
-ifdef MOZ_MEMORY
-tier_base_dirs += memory/jemalloc
-endif
-
 ifdef COMPILE_ENVIRONMENT
 include $(topsrcdir)/$(MOZ_BUILD_APP)/build.mk
 endif
 
 TIERS += testharness
 
 # test harnesses
 ifdef ENABLE_TESTS
--- a/browser/installer/package-manifest.in
+++ b/browser/installer/package-manifest.in
@@ -40,16 +40,17 @@
 
 [xpcom]
 @BINPATH@/dependentlibs.list
 @BINPATH@/@DLL_PREFIX@mozjs@DLL_SUFFIX@
 @BINPATH@/@DLL_PREFIX@plc4@DLL_SUFFIX@
 @BINPATH@/@DLL_PREFIX@plds4@DLL_SUFFIX@
 @BINPATH@/@DLL_PREFIX@xpcom@DLL_SUFFIX@
 @BINPATH@/@DLL_PREFIX@nspr4@DLL_SUFFIX@
+@BINPATH@/@DLL_PREFIX@mozalloc@DLL_SUFFIX@
 #ifdef XP_MACOSX
 @BINPATH@/XUL
 #else
 @BINPATH@/@DLL_PREFIX@xul@DLL_SUFFIX@
 #endif
 #ifdef MOZ_IPC
 @BINPATH@/mozilla-runtime@BIN_SUFFIX@
 #endif
--- a/build/Makefile.in
+++ b/build/Makefile.in
@@ -51,19 +51,19 @@ endif
 
 ifeq (WINNT,$(OS_ARCH))
 DIRS = win32
 endif
 
 ifdef WINCE
 # We need jemalloc built before the shunt
 ifdef MOZ_MEMORY
-DIRS += wince/tools $(DEPTH)/memory/jemalloc wince/shunt
+DIRS += wince/tools $(DEPTH)/memory/jemalloc $(DEPTH)/memory/mozalloc wince/shunt
 else
-DIRS += wince/tools wince/shunt
+DIRS += wince/tools $(DEPTH)/memory/mozalloc wince/shunt
 endif
 endif
 
 DIRS += pgo
 
 include $(topsrcdir)/config/rules.mk
 
 # we install to _leaktest/
--- a/config/config.mk
+++ b/config/config.mk
@@ -220,16 +220,17 @@ else
       # the user didn't mention this module explicitly, 
       # but wanted all modules to be compiled with -g
       _DEBUG_CFLAGS += $(MOZ_DEBUG_FLAGS)
       _DEBUG_LDFLAGS += $(MOZ_DEBUG_LDFLAGS)      
     endif
   endif
 endif
 
+MOZALLOC_LIB = $(call EXPAND_MOZLIBNAME,mozalloc)
 
 # append debug flags 
 # (these might have been above when processing MOZ_DBGRINFO_MODULES)
 OS_CFLAGS += $(_DEBUG_CFLAGS)
 OS_CXXFLAGS += $(_DEBUG_CFLAGS)
 OS_LDFLAGS += $(_DEBUG_LDFLAGS)
 
 # XXX: What does this? Bug 482434 filed for better explanation.
--- a/configure.in
+++ b/configure.in
@@ -1061,19 +1061,19 @@ MOZ_JPEG_LIBS='$(call EXPAND_LIBNAME_PAT
 MOZ_ZLIB_CFLAGS=
 MOZ_ZLIB_LIBS='$(call EXPAND_LIBNAME_PATH,mozz,$(DEPTH)/modules/zlib/src)'
 MOZ_BZ2_CFLAGS=
 MOZ_BZ2_LIBS='$(call EXPAND_LIBNAME_PATH,bz2,$(DEPTH)/modules/libbz2/src)'
 MOZ_PNG_CFLAGS=
 MOZ_PNG_LIBS='$(call EXPAND_LIBNAME_PATH,mozpng,$(DEPTH)/modules/libimg/png)'
 
 MOZ_JS_LIBS='-L$(LIBXUL_DIST)/bin -lmozjs'
-DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/bin -lxpcom -lxpcom_core'
+DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/bin -lxpcom -lxpcom_core -lmozalloc'
 MOZ_FIX_LINK_PATHS='-Wl,-rpath-link,$(LIBXUL_DIST)/bin -Wl,-rpath-link,$(prefix)/lib'
-XPCOM_FROZEN_LDOPTS='-L$(LIBXUL_DIST)/bin -lxpcom'
+XPCOM_FROZEN_LDOPTS='-L$(LIBXUL_DIST)/bin -lxpcom -lmozalloc'
 LIBXUL_LIBS='$(XPCOM_FROZEN_LDOPTS) -lxul'
 XPCOM_GLUE_LDOPTS='$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue_s.$(LIB_SUFFIX) $(XPCOM_FROZEN_LDOPTS)'
 XPCOM_STANDALONE_GLUE_LDOPTS='$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue.$(LIB_SUFFIX)'
 
 MOZ_FS_LAYOUT=unix
 
 MOZ_COMPONENT_NSPR_LIBS='-L$(LIBXUL_DIST)/bin $(NSPR_LIBS)'
 
@@ -2093,21 +2093,22 @@ case "$target" in
     MOZ_OPTIMIZE_FLAGS='-Ox'
     AR_FLAGS='-NOLOGO -OUT:"$@"'
     ASM_SUFFIX=asm
     CFLAGS="$CFLAGS -W3 -Gy -Fd\$(COMPILE_PDBFILE)"
     CXXFLAGS="$CXXFLAGS -W3 -Gy -Fd\$(COMPILE_PDBFILE)"
     DLL_PREFIX=
     DOXYGEN=:
     DSO_LDOPTS=-SUBSYSTEM:WINDOWSCE
-    DYNAMIC_XPCOM_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xpcom_core.lib'
+    DYNAMIC_XPCOM_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xpcom_core.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
     GARBAGE=
     IMPORT_LIB_SUFFIX=lib
-    LIBS="$LIBS"
-    LIBXUL_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xul.lib'
+    dnl Need to force-link against mozalloc because it's used in the shunt
+    LIBS="$LIBS \$(LIBXUL_DIST)/lib/mozalloc.lib"
+    LIBXUL_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xul.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
     LIB_PREFIX=
     LIB_SUFFIX=lib 
     MKCSHLIB='$(LD) -NOLOGO -DLL -OUT:$@ $(DSO_LDOPTS)'
     MKSHLIB='$(LD) -NOLOGO -DLL -OUT:$@ $(DSO_LDOPTS)'
     MKSHLIB_FORCE_ALL=
     MKSHLIB_UNFORCE_ALL=
     MOZ_COMPONENT_NSPR_LIBS='$(NSPR_LIBS)'
     MOZ_COMPONENT_NSPR_LIBS='$(NSPR_LIBS)'
@@ -2116,17 +2117,17 @@ case "$target" in
     MOZ_FIX_LINK_PATHS=
     MOZ_JS_LIBS='$(LIBXUL_DIST)/lib/mozjs.lib'
     OBJ_SUFFIX=obj
     RANLIB='echo not_ranlib'
     STRIP='echo not_strip'
     TARGET_NSPR_MDCPUCFG='\"md/_wince.cfg\"'
     UNZIP=unzip
     XARGS=xargs
-    XPCOM_FROZEN_LDOPTS='$(LIBXUL_DIST)/lib/xpcom.lib'
+    XPCOM_FROZEN_LDOPTS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
     ZIP=zip
     LIBIDL_CFLAGS="-I$MOZ_TOOLS_DIR/include ${GLIB_CFLAGS}"
     LIBIDL_LIBS="$MOZ_TOOLS_DIR/lib/libidl-0.6_s.lib $MOZ_TOOLS_DIR/lib/glib-1.2_s.lib"
     STATIC_LIBIDL=1
     MOZ_TREE_FREETYPE=1
 
     AC_DEFINE(HAVE_SNPRINTF)
     AC_DEFINE(_WINDOWS)
@@ -2175,18 +2176,18 @@ case "$target" in
         MKCSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
         RC='$(WINDRES)'
         # Use temp file for windres (bug 213281)
         RCFLAGS='-O coff --use-temp-file'
         # mingw doesn't require kernel32, user32, and advapi32 explicitly
         LIBS="$LIBS -luuid -lgdi32 -lwinmm -lwsock32"
         MOZ_JS_LIBS='-L$(LIBXUL_DIST)/lib -lmozjs'
         MOZ_FIX_LINK_PATHS=
-        DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/lib -lxpcom -lxpcom_core'
-        XPCOM_FROZEN_LDOPTS='-L$(LIBXUL_DIST)/lib -lxpcom'
+        DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/lib -lxpcom -lxpcom_core -lmozalloc'
+        XPCOM_FROZEN_LDOPTS='-L$(LIBXUL_DIST)/lib -lxpcom -lmozalloc'
         DLL_PREFIX=
         IMPORT_LIB_SUFFIX=dll.a
     else
         TARGET_COMPILER_ABI=msvc
         HOST_CC='$(CC)'
         HOST_CXX='$(CXX)'
         HOST_LD='$(LD)'
         if test "$AS_BIN"; then
@@ -2219,19 +2220,19 @@ case "$target" in
         CXXFLAGS="$CXXFLAGS -W3 -Gy -Fd\$(COMPILE_PDBFILE)"
         LIBS="$LIBS kernel32.lib user32.lib gdi32.lib winmm.lib wsock32.lib advapi32.lib"
         MOZ_DEBUG_FLAGS='-Zi'
         MOZ_DEBUG_LDFLAGS='-DEBUG -DEBUGTYPE:CV'
         WARNINGS_AS_ERRORS='-WX'
     	MOZ_OPTIMIZE_FLAGS='-O1'
         MOZ_JS_LIBS='$(LIBXUL_DIST)/lib/mozjs.lib'
         MOZ_FIX_LINK_PATHS=
-        DYNAMIC_XPCOM_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xpcom_core.lib'
-        XPCOM_FROZEN_LDOPTS='$(LIBXUL_DIST)/lib/xpcom.lib'
-        LIBXUL_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xul.lib'
+        DYNAMIC_XPCOM_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xpcom_core.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
+        XPCOM_FROZEN_LDOPTS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
+        LIBXUL_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xul.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
         MOZ_COMPONENT_NSPR_LIBS='$(NSPR_LIBS)'
         if test $_MSC_VER -ge 1400; then
             LDFLAGS="$LDFLAGS -NXCOMPAT"
             dnl For profile-guided optimization
             PROFILE_GEN_CFLAGS="-GL"
             PROFILE_GEN_LDFLAGS="-LTCG:PGINSTRUMENT"
             dnl XXX: PGO builds can fail with warnings treated as errors,
             dnl specifically "no profile data available" appears to be
@@ -4245,16 +4246,63 @@ AC_CACHE_CHECK(for __thread keyword for 
                             [return tlsIsMainThread;],
                             ac_cv_thread_keyword=yes,
                             ac_cv_thread_keyword=no)])
 LDFLAGS=$_SAVE_LDFLAGS
 if test "$ac_cv_thread_keyword" = yes; then
   AC_DEFINE(HAVE_THREAD_TLS_KEYWORD)
 fi
 
+dnl Check for the existence of various allocation headers/functions
+
+MALLOC_H=
+AC_CHECK_HEADER(malloc.h,        [MALLOC_H=malloc.h])
+if test "$MALLOC_H" = ""; then
+  AC_CHECK_HEADER(malloc/malloc.h, [MALLOC_H=malloc/malloc.h])
+  if test "$MALLOC_H" = ""; then
+    AC_CHECK_HEADER(sys/malloc.h,    [MALLOC_H=sys/malloc.h])
+  fi
+fi
+if test "$MALLOC_H" != ""; then
+   AC_DEFINE_UNQUOTED(MALLOC_H, <$MALLOC_H>)
+fi
+
+MOZ_ALLOCATING_FUNCS="strndup posix_memalign memalign valloc"
+AC_CHECK_FUNCS(strndup posix_memalign memalign valloc)
+
+dnl See if compiler supports some gcc-style attributes
+
+AC_CACHE_CHECK(for __attribute__((always_inline)),
+               ac_cv_attribute_always_inline,
+               [AC_TRY_COMPILE([],
+                               [inline void f(void) __attribute__((always_inline));],
+                               ac_cv_attribute_always_inline=yes,
+                               ac_cv_attribute_always_inline=no)])
+
+AC_CACHE_CHECK(for __attribute__((malloc)),
+               ac_cv_attribute_malloc,
+               [AC_TRY_COMPILE([],
+                               [void* f(int) __attribute__((malloc));],
+                               ac_cv_attribute_malloc=yes,
+                               ac_cv_attribute_malloc=no)])
+
+AC_CACHE_CHECK(for __attribute__((warn_unused_result)),
+               ac_cv_attribute_warn_unused,
+               [AC_TRY_COMPILE([],
+                               [int f(void) __attribute__((warn_unused_result));],
+                               ac_cv_attribute_warn_unused=yes,
+                               ac_cv_attribute_warn_unused=no)])
+
+AC_CACHE_CHECK(for __attribute__((noreturn)),
+               ac_cv_attribute_noreturn,
+               [AC_TRY_COMPILE([],
+                               [void f(void) __attribute__((noreturn));],
+                               ac_cv_attribute_noreturn=yes,
+                               ac_cv_attribute_noreturn=no)])
+ 
 dnl End of C++ language/feature checks
 AC_LANG_C
 
 dnl ========================================================
 dnl =  Internationalization checks
 dnl ========================================================
 dnl
 dnl Internationalization and Locale support is different
@@ -4279,16 +4327,50 @@ if test -n "${CPU_ARCH}" -a -n "${TARGET
     TARGET_XPCOM_ABI="${CPU_ARCH}-${TARGET_COMPILER_ABI}"
 fi
 
 dnl Mozilla specific options
 dnl ========================================================
 dnl The macros used for command line options
 dnl are defined in build/autoconf/altoptions.m4.
 
+dnl If the compiler supports these attributes, define them as
+dnl convenience macros.
+if test "$ac_cv_attribute_always_inline" = yes ; then
+  AC_DEFINE(NS_ALWAYS_INLINE, [__attribute__((always_inline))])
+else
+  AC_DEFINE(NS_ALWAYS_INLINE,)
+fi
+
+if test "$ac_cv_attribute_malloc" = yes ; then
+  AC_DEFINE(NS_ATTR_MALLOC, [__attribute__((malloc))])
+else
+  AC_DEFINE(NS_ATTR_MALLOC,)
+fi
+
+if test "$ac_cv_attribute_warn_unused" = yes ; then
+  AC_DEFINE(NS_WARN_UNUSED_RESULT, [__attribute__((warn_unused_result))])
+else
+  AC_DEFINE(NS_WARN_UNUSED_RESULT,)
+fi
+
+if test "$ac_cv_attribute_noreturn" = yes ; then
+  AC_DEFINE(NS_NORETURN, [__attribute__((noreturn))])
+else
+  AC_DEFINE(NS_NORETURN,)
+fi
+
+dnl We can't run TRY_COMPILE tests on Windows, so hard-code some
+dnl features that Windows actually does support.
+
+if test -n "$SKIP_COMPILER_CHECKS"; then
+   dnl Windows has malloc.h
+   AC_DEFINE(MALLOC_H, [<malloc.h>])
+   AC_DEFINE(HAVE_FORCEINLINE)
+fi # SKIP_COMPILER_CHECKS
 
 dnl ========================================================
 dnl =
 dnl = Check for external package dependencies
 dnl =
 dnl ========================================================
 MOZ_ARG_HEADER(External Packages)
 
@@ -6829,16 +6911,23 @@ if test "$MOZ_MEMORY"; then
   *winmo)
     AC_DEFINE(MOZ_MEMORY_WINCE)
     AC_DEFINE(MOZ_MEMORY_WINDOWS)
     ;;
   *)
     AC_MSG_ERROR([--enable-jemalloc not supported on ${target}])
     ;;
   esac
+
+  if test "$OS_ARCH" != "Darwin"; then
+    dnl NB: this must be kept in sync with jemalloc.h
+    AC_DEFINE(HAVE_JEMALLOC_VALLOC)
+    AC_DEFINE(HAVE_JEMALLOC_POSIX_MEMALIGN)
+    AC_DEFINE(HAVE_JEMALLOC_MEMALIGN)
+  fi
 fi
 AC_SUBST(MOZ_MEMORY)
 AC_SUBST(MOZ_MEMORY_LDFLAGS)
 AC_SUBST(WIN32_CRT_SRC_DIR)
 dnl Need to set this for make because NSS doesn't have configure
 AC_SUBST(DLLFLAGS)
 
 dnl ========================================================
--- a/js/ctypes/tests/Makefile.in
+++ b/js/ctypes/tests/Makefile.in
@@ -48,16 +48,17 @@ LIBRARY_NAME = jsctypes-test
 SHORT_LIBNAME = jscttest
 FORCE_SHARED_LIB = 1
 NO_DIST_INSTALL = 1
 
 CPPSRCS = jsctypes-test.cpp
 
 EXTRA_DSO_LDOPTS += \
     $(XPCOM_STANDALONE_GLUE_LDOPTS) \
+    $(MOZALLOC_LIB) \
     $(NSPR_LIBS) \
     $(NULL)
 
 XPCSHELL_TESTS = unit
 
 include $(topsrcdir)/config/rules.mk
 
 xpctestdir = $(testxpcobjdir)/$(MODULE)/unit
--- a/js/src/config/config.mk
+++ b/js/src/config/config.mk
@@ -220,16 +220,17 @@ else
       # the user didn't mention this module explicitly, 
       # but wanted all modules to be compiled with -g
       _DEBUG_CFLAGS += $(MOZ_DEBUG_FLAGS)
       _DEBUG_LDFLAGS += $(MOZ_DEBUG_LDFLAGS)      
     endif
   endif
 endif
 
+MOZALLOC_LIB = $(call EXPAND_MOZLIBNAME,mozalloc)
 
 # append debug flags 
 # (these might have been above when processing MOZ_DBGRINFO_MODULES)
 OS_CFLAGS += $(_DEBUG_CFLAGS)
 OS_CXXFLAGS += $(_DEBUG_CFLAGS)
 OS_LDFLAGS += $(_DEBUG_LDFLAGS)
 
 # XXX: What does this? Bug 482434 filed for better explanation.
--- a/memory/mozalloc/Makefile.in
+++ b/memory/mozalloc/Makefile.in
@@ -45,20 +45,23 @@ include $(DEPTH)/config/autoconf.mk
 
 VISIBILITY_FLAGS=
 
 MODULE		= mozalloc
 LIBRARY_NAME	= mozalloc
 FORCE_SHARED_LIB= 1
 DIST_INSTALL 	= 1
 
+ifeq (,$(filter-out WINCE,$(OS_ARCH)))
 # The wince shunt relies on this library in a somewhat complicated
 # way.  In wince builds, jemalloc replaces the wince libc allocators
 # and moz_* will end up using those symbols at run time.
 export NO_SHUNT	= 1
+OS_LIBS		=
+endif
 
 EXPORTS_NAMESPACES 	= mozilla
 EXPORTS_mozilla 	= mozalloc.h mozalloc_macro_wrappers.h mozalloc_oom.h
 
 CPPSRCS =					\
 	mozalloc.cpp				\
 	mozalloc_oom.cpp			\
 	$(NULL)
--- a/modules/plugin/default/windows/Makefile.in
+++ b/modules/plugin/default/windows/Makefile.in
@@ -56,16 +56,18 @@ CPPSRCS		= \
 		dialogs.cpp \
 		npshell.cpp \
 		npwin.cpp \
 		utils.cpp \
 		$(NULL)
 
 LOCAL_INCLUDES	= -I$(srcdir)
 
+DEFINES += -DXPCOM_GLUE
+
 # plugins should always be shared, even in the "static" build
 FORCE_SHARED_LIB = 1
 
 # Force use of PIC
 FORCE_USE_PIC	= 1
 
 # must link statically with the CRT to avoid problems with VC8
 USE_STATIC_LIBS = 1
--- a/toolkit/components/faststart/Makefile.in
+++ b/toolkit/components/faststart/Makefile.in
@@ -37,16 +37,18 @@
 
 DEPTH     = ../../..
 topsrcdir = @top_srcdir@
 srcdir    = @srcdir@
 VPATH     = @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
+DEFINES += -DMOZ_NO_MOZALLOC
+
 EXTRA_PP_COMPONENTS = \
     FastStartup.js \
     $(NULL)
 
 ifdef _MSC_VER
 ifdef WINCE
 CPPSRCS = \
     faststartstub.cpp \
--- a/toolkit/library/Makefile.in
+++ b/toolkit/library/Makefile.in
@@ -168,17 +168,17 @@ ifndef MOZ_ENABLE_LIBXUL
 EXTRA_DSO_LDOPTS += \
 	$(MOZ_COMPONENT_LIBS) \
 	$(MOZ_JS_LIBS) \
 	$(NULL)
 endif
 
 DEFINES += -DIMPL_XREAPI
 
-EXTRA_DSO_LDOPTS += $(NSPR_LIBS)
+EXTRA_DSO_LDOPTS += $(NSPR_LIBS) $(MOZALLOC_LIB)
 
 ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
 CXXFLAGS	+= $(TK_CFLAGS)
 OS_LIBS += \
 	-framework SystemConfiguration \
 	-framework QuickTime \
 	-framework IOKit \
 	-lcrypto \
--- a/widget/src/xremoteclient/Makefile.in
+++ b/widget/src/xremoteclient/Makefile.in
@@ -46,16 +46,18 @@ VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE		= xremoteclient
 LIBRARY_NAME = xremote_client_s
 FORCE_STATIC_LIB = 1
 
 
+DEFINES += -DXPCOM_GLUE
+
 ifdef MOZ_ENABLE_PHOTON
 	CPPSRCS		+= PhRemoteClient.cpp
 else
 	CPPSRCS		+= XRemoteClient.cpp
 endif
 
 EXTRA_DSO_LDOPTS = \
 		$(XLIBS) $(XLDFLAGS)  \
--- a/xpcom/build/Makefile.in
+++ b/xpcom/build/Makefile.in
@@ -146,17 +146,20 @@ include $(topsrcdir)/ipc/chromium/chromi
 include $(topsrcdir)/config/rules.mk
 
 DEFINES		+= \
 		-D_IMPL_NS_COM \
 		-D_IMPL_NS_STRINGAPI \
 		-DEXPORT_XPT_API \
 		-DEXPORT_XPTC_API
 
-EXTRA_DSO_LDOPTS += $(NSPR_LIBS)
+EXTRA_DSO_LDOPTS +=				\
+	$(MOZALLOC_LIB)				\
+	$(NSPR_LIBS)				\
+	$(NULL)
 
 ifdef TARGET_XPCOM_ABI
 DEFINES += -DTARGET_XPCOM_ABI=\"$(TARGET_XPCOM_ABI)\"
 endif
 
 ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 CXXFLAGS	+= $(TK_CFLAGS)
 EXTRA_DSO_LDOPTS += \
--- a/xpcom/stub/Makefile.in
+++ b/xpcom/stub/Makefile.in
@@ -73,16 +73,17 @@ FORCE_USE_PIC	= 1
 FORCE_SHARED_LIB = 1
 
 EXTRA_DSO_LDOPTS = $(LIBS_DIR)
 
 DEPENDENT_LIBS_LIST += \
 	$(LIB_PREFIX)nspr4$(DLL_SUFFIX) \
 	$(LIB_PREFIX)plc4$(DLL_SUFFIX) \
 	$(LIB_PREFIX)plds4$(DLL_SUFFIX) \
+	$(LIB_PREFIX)mozalloc$(DLL_SUFFIX) \
 	$(NULL)
 
 ifdef MOZ_ENABLE_LIBXUL
 
 DEPENDENT_LIBS_LIST += \
 	$(LIB_PREFIX)nssutil3$(DLL_SUFFIX) \
 	$(LIB_PREFIX)softokn3$(DLL_SUFFIX) \
 	$(LIB_PREFIX)nss3$(DLL_SUFFIX) \
@@ -109,19 +110,23 @@ else #!MOZ_ENABLE_LIBXUL
 
 EXTRA_DSO_LIBS = xpcom_core
 ifeq ($(OS_TARGET),OS2)
 DEPENDENT_LIBS_LIST += xpcomcor.dll
 else
 DEPENDENT_LIBS_LIST += $(LIB_PREFIX)xpcom_core$(DLL_SUFFIX)
 endif
 
-endif
+endif #ifdef MOZ_ENABLE_LIBXUL
 
-EXTRA_DSO_LDOPTS += $(EXTRA_DSO_LIBS) $(NSPR_LIBS)
+EXTRA_DSO_LDOPTS +=				\
+	$(EXTRA_DSO_LIBS)			\
+	$(NSPR_LIBS)				\
+	$(MOZALLOC_LIB)				\
+	$(NULL)
 
 include $(topsrcdir)/config/rules.mk
 
 libs:: $(FINAL_TARGET)/dependentlibs.list
 
 $(FINAL_TARGET)/dependentlibs.list: Makefile.in
 	$(EXIT_ON_ERROR) \
 	( $(foreach dlib,$(DEPENDENT_LIBS_LIST),echo $(dlib);) ) > $@