Bug 732124 - Fix for crt link errors with VC11 - build glue using both the static and the dynamic runtime lib, and link accordingly for various components. r=ted
authorJim Mathies <jmathies@mozilla.com>
Mon, 21 May 2012 16:31:03 -0500
changeset 98581 925c8302f34a85ce1064406289e93dbbad7c4888
parent 98580 fe33852b68c79df21be7cb3fb92f170609a8c701
child 98582 a27219d06c499b53f4dcccabad3dd59e1b2871c0
push id1116
push userlsblakk@mozilla.com
push dateMon, 16 Jul 2012 19:38:18 +0000
treeherdermozilla-beta@95f959a8b4dc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted
bugs732124
milestone15.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 732124 - Fix for crt link errors with VC11 - build glue using both the static and the dynamic runtime lib, and link accordingly for various components. r=ted
browser/components/about/Makefile.in
browser/components/build/Makefile.in
browser/components/dirprovider/Makefile.in
browser/components/feeds/src/Makefile.in
browser/components/migration/src/Makefile.in
browser/components/privatebrowsing/src/Makefile.in
browser/components/shell/src/Makefile.in
config/autoconf.mk.in
configure.in
intl/unicharutil/tests/Makefile.in
webapprt/win/Makefile.in
xpcom/glue/Makefile.in
xpcom/glue/nomozalloc/Makefile.in
xpcom/glue/standalone/Makefile.in
xpcom/glue/standalone/staticruntime/Makefile.in
xpcom/glue/staticruntime/Makefile.in
xulrunner/stub/Makefile.in
--- a/browser/components/about/Makefile.in
+++ b/browser/components/about/Makefile.in
@@ -6,21 +6,19 @@ DEPTH     = ../../..
 topsrcdir = @top_srcdir@
 srcdir    = @srcdir@
 VPATH     = @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE = browserabout
 LIBRARY_NAME = browserabout_s
+
 FORCE_STATIC_LIB = 1
-ifndef MOZ_MEMORY
 USE_STATIC_LIBS = 1
-endif
-
 
 EXPORTS_NAMESPACES = mozilla/browser
 
 EXPORTS_mozilla/browser = AboutRedirector.h
 
 CPPSRCS = AboutRedirector.cpp
 
 LOCAL_INCLUDES = -I$(srcdir)/../build
--- a/browser/components/build/Makefile.in
+++ b/browser/components/build/Makefile.in
@@ -11,21 +11,17 @@ include $(DEPTH)/config/autoconf.mk
 
 MODULE = browsercomps
 LIBRARY_NAME = browsercomps
 SHORT_LIBNAME = brwsrcmp
 IS_COMPONENT = 1
 MODULE_NAME = nsBrowserCompsModule
 FORCE_SHARED_LIB = 1
 
-# Statically link the CRT on Windows if building against
-# a XULRunner SDK.
-ifdef LIBXUL_SDK
 USE_STATIC_LIBS = 1
-endif
 
 EXPORTS = nsBrowserCompsCID.h
 
 CPPSRCS = nsModule.cpp \
           $(NULL)
 
 ifeq ($(OS_ARCH),WINNT)
 OS_LIBS	+= $(call EXPAND_LIBNAME,ole32 shell32 shlwapi)
@@ -51,17 +47,17 @@ SHARED_LIBRARY_LIBS = \
 	$(NULL)
 
 ifneq (,$(filter windows cocoa gtk2, $(MOZ_WIDGET_TOOLKIT)))
 SHARED_LIBRARY_LIBS += ../shell/src/$(LIB_PREFIX)shellservice_s.$(LIB_SUFFIX)
 endif
 
 EXTRA_DSO_LDOPTS += \
 	$(call EXPAND_LIBNAME_PATH,unicharutil_external_s,$(LIBXUL_DIST)/lib) \
-	$(XPCOM_GLUE_LDOPTS) \
+	$(XPCOM_STATICRUNTIME_GLUE_LDOPTS) \
 	$(MOZ_COMPONENT_LIBS) \
 	$(NULL)
 
 ifdef JS_SHARED_LIBRARY
 EXTRA_DSO_LDOPTS += $(MOZ_JS_LIBS)
 endif
 
 LOCAL_INCLUDES += -I$(srcdir)/../migration/src
--- a/browser/components/dirprovider/Makefile.in
+++ b/browser/components/dirprovider/Makefile.in
@@ -10,22 +10,17 @@ VPATH     = @srcdir@
 include $(DEPTH)/config/autoconf.mk
 
 MODULE = browserdir
 LIBRARY_NAME = browserdir_s
 
 TEST_DIRS += tests
 
 FORCE_STATIC_LIB = 1
-
-# Because we are an application component, link against the CRT statically
-# (on Windows, but only if we're not building our own CRT for jemalloc)
-ifndef MOZ_MEMORY
-USE_STATIC_LIBS      = 1
-endif
+USE_STATIC_LIBS = 1
 
 EXPORTS_NAMESPACES = mozilla/browser
 EXPORTS_mozilla/browser = DirectoryProvider.h
 
 CPPSRCS = DirectoryProvider.cpp
 
 LOCAL_INCLUDES = -I$(srcdir)/../build
 
--- a/browser/components/feeds/src/Makefile.in
+++ b/browser/components/feeds/src/Makefile.in
@@ -6,20 +6,19 @@ DEPTH		= ../../../..
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE = browser_feeds
 LIBRARY_NAME = browser_feeds_s
+
 FORCE_STATIC_LIB = 1
-ifndef MOZ_MEMORY
 USE_STATIC_LIBS = 1
-endif
 
 DEFINES += \
 	-DMOZ_APP_NAME=$(MOZ_APP_NAME) \
 	-DMOZ_MACBUNDLE_NAME=$(MOZ_MACBUNDLE_NAME) \
 	$(NULL)
 
 EXTRA_COMPONENTS = \
   BrowserFeeds.manifest \
--- a/browser/components/migration/src/Makefile.in
+++ b/browser/components/migration/src/Makefile.in
@@ -6,20 +6,19 @@ DEPTH		= ../../../..
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE		= migration
 LIBRARY_NAME	= migration_s
+
 FORCE_STATIC_LIB = 1
-ifndef MOZ_MEMORY
 USE_STATIC_LIBS = 1
-endif
 
 EXTRA_PP_COMPONENTS = \
   ProfileMigrator.js \
   ChromeProfileMigrator.js \
   FirefoxProfileMigrator.js \
   $(NULL)
 
 ifeq ($(OS_ARCH)_$(GNU_CXX),WINNT_)
--- a/browser/components/privatebrowsing/src/Makefile.in
+++ b/browser/components/privatebrowsing/src/Makefile.in
@@ -6,21 +6,19 @@ DEPTH   = ../../../..
 topsrcdir = @top_srcdir@
 srcdir    = @srcdir@
 VPATH   = @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE = privatebrowsing
 LIBRARY_NAME = privatebrowsing_s
+
 FORCE_STATIC_LIB = 1
-ifndef MOZ_MEMORY
 USE_STATIC_LIBS = 1
-endif
-
 
 CPPSRCS = \
 	nsPrivateBrowsingServiceWrapper.cpp \
 	$(NULL)
 
 LOCAL_INCLUDES = -I$(srcdir)/../../build
 
 EXTRA_COMPONENTS = \
--- a/browser/components/shell/src/Makefile.in
+++ b/browser/components/shell/src/Makefile.in
@@ -6,21 +6,19 @@
 DEPTH   = ../../../..
 topsrcdir = @top_srcdir@
 srcdir    = @srcdir@
 VPATH   = @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE = shellservice
+
 FORCE_STATIC_LIB = 1
-ifndef MOZ_MEMORY
 USE_STATIC_LIBS = 1
-endif
-
 
 ifeq ($(OS_ARCH),WINNT)
 CPPSRCS = nsWindowsShellService.cpp
 else
 ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 CPPSRCS = nsMacShellService.cpp
 else
 ifeq ($(MOZ_WIDGET_TOOLKIT), gtk2)
--- a/config/autoconf.mk.in
+++ b/config/autoconf.mk.in
@@ -472,18 +472,20 @@ NSPR_CFLAGS	= @NSPR_CFLAGS@
 NSPR_LIBS	= @NSPR_LIBS@
 
 NSS_CONFIG	= @NSS_CONFIG@
 NSS_CFLAGS	= @NSS_CFLAGS@
 NSS_LIBS	= @NSS_LIBS@
 NSS_DEP_LIBS	= @NSS_DEP_LIBS@
 NSS_DISABLE_DBM = @NSS_DISABLE_DBM@
 
-XPCOM_GLUE_LDOPTS = @XPCOM_GLUE_LDOPTS@
-XPCOM_STANDALONE_GLUE_LDOPTS = @XPCOM_STANDALONE_GLUE_LDOPTS@
+XPCOM_GLUE_LDOPTS	= @XPCOM_GLUE_LDOPTS@
+XPCOM_STANDALONE_GLUE_LDOPTS	= @XPCOM_STANDALONE_GLUE_LDOPTS@
+XPCOM_STATICRUNTIME_GLUE_LDOPTS	= @XPCOM_STATICRUNTIME_GLUE_LDOPTS@
+XPCOM_STANDALONE_STATICRUNTIME_GLUE_LDOPTS	= @XPCOM_STANDALONE_STATICRUNTIME_GLUE_LDOPTS@
 
 USE_DEPENDENT_LIBS = @USE_DEPENDENT_LIBS@
 
 # UNIX98 iconv support
 LIBICONV = @LIBICONV@
 
 # MKSHLIB_FORCE_ALL is used to force the linker to include all object
 # files present in an archive. MKSHLIB_UNFORCE_ALL reverts the linker
--- a/configure.in
+++ b/configure.in
@@ -1303,16 +1303,28 @@ MOZ_JS_STATIC_LIBS='$(call EXPAND_LIBNAM
 MOZ_JS_SHARED_LIBS='$(call EXPAND_LIBNAME_PATH,mozjs,$(LIBXUL_DIST)/lib)'
 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 -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)'
 
+# These are specially defined on Windows only
+case "$target" in
+*-mingw*)
+  XPCOM_STATICRUNTIME_GLUE_LDOPTS='$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue_staticruntime_s.$(LIB_SUFFIX) $(XPCOM_FROZEN_LDOPTS)'
+  XPCOM_STANDALONE_STATICRUNTIME_GLUE_LDOPTS='$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue_staticruntime.$(LIB_SUFFIX)'
+  ;;
+*)
+  XPCOM_STATICRUNTIME_GLUE_LDOPTS=$XPCOM_GLUE_LDOPTS
+  XPCOM_STANDALONE_STATICRUNTIME_GLUE_LDOPTS=$XPCOM_STANDALONE_GLUE_LDOPTS
+  ;;
+esac
+
 MOZ_FS_LAYOUT=unix
 
 MOZ_COMPONENT_NSPR_LIBS='-L$(LIBXUL_DIST)/bin $(NSPR_LIBS)'
 
 USE_DEPENDENT_LIBS=1
 
 _PLATFORM_DEFAULT_TOOLKIT=cairo-gtk2
 
@@ -8418,16 +8430,18 @@ AC_SUBST(INCREMENTAL_LINKER)
 AC_SUBST(MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS)
 AC_SUBST(MOZ_COMPONENT_NSPR_LIBS)
 
 AC_SUBST(MOZ_FIX_LINK_PATHS)
 AC_SUBST(XPCOM_LIBS)
 AC_SUBST(XPCOM_FROZEN_LDOPTS)
 AC_SUBST(XPCOM_GLUE_LDOPTS)
 AC_SUBST(XPCOM_STANDALONE_GLUE_LDOPTS)
+AC_SUBST(XPCOM_STATICRUNTIME_GLUE_LDOPTS)
+AC_SUBST(XPCOM_STANDALONE_STATICRUNTIME_GLUE_LDOPTS)
 
 AC_SUBST(USE_DEPENDENT_LIBS)
 
 AC_SUBST(MOZ_BUILD_ROOT)
 AC_SUBST(MOZ_OS2_TOOLS)
 
 AC_SUBST(MOZ_POST_DSO_LIB_COMMAND)
 AC_SUBST(MOZ_POST_PROGRAM_COMMAND)
--- a/intl/unicharutil/tests/Makefile.in
+++ b/intl/unicharutil/tests/Makefile.in
@@ -9,26 +9,27 @@ srcdir		= @srcdir@
 VPATH		= @srcdir@
 relativesrcdir = intl/unicharutil/tests
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE		= test_intl_unicharutil
 XPCSHELL_TESTS	= unit
 
+USE_STATIC_LIBS = 1
 
 CPPSRCS		= UnicharSelfTest.cpp \
 		  NormalizationTest.cpp \
 		  $(NULL)
 
 SIMPLE_PROGRAMS	= $(CPPSRCS:.cpp=$(BIN_SUFFIX))
 
 LIBS		= \
-		$(DIST)/lib/$(LIB_PREFIX)xpcomglue_s.$(LIB_SUFFIX) \
-		$(DIST)/lib/$(LIB_PREFIX)unicharutil_external_s.$(LIB_SUFFIX) \
-		$(XPCOM_LIBS) \
-		$(NSPR_LIBS) \
-		$(NULL)
+	$(XPCOM_STATICRUNTIME_GLUE_LDOPTS) \
+	$(DIST)/lib/$(LIB_PREFIX)unicharutil_external_s.$(LIB_SUFFIX) \
+	$(XPCOM_LIBS) \
+	$(NSPR_LIBS) \
+	$(NULL)
 
 include $(topsrcdir)/config/rules.mk
 
 INCLUDES	+= -I$(srcdir)/../public
 
--- a/webapprt/win/Makefile.in
+++ b/webapprt/win/Makefile.in
@@ -29,17 +29,17 @@ LOCAL_INCLUDES += -I$(topsrcdir)/toolkit
 LOCAL_INCLUDES += -I$(topsrcdir)/xpcom/base
 LOCAL_INCLUDES += -I$(topsrcdir)/xpcom/build
 LOCAL_INCLUDES += -I$(DEPTH)/build
 
 DEFINES += -DXPCOM_GLUE
 STL_FLAGS=
 
 LIBS = \
-  $(XPCOM_STANDALONE_GLUE_LDOPTS) \
+  $(XPCOM_STANDALONE_STATICRUNTIME_GLUE_LDOPTS) \
   $(NULL)
 
 ifndef MOZ_WINCONSOLE
 ifdef MOZ_DEBUG
 MOZ_WINCONSOLE = 1
 else
 MOZ_WINCONSOLE = 0
 endif
--- a/xpcom/glue/Makefile.in
+++ b/xpcom/glue/Makefile.in
@@ -10,16 +10,22 @@ VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 include $(srcdir)/objs.mk
 
 EXTRA_DEPS += $(srcdir)/objs.mk
 
 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.
+ifeq ($(OS_ARCH),WINNT)
+DIRS += staticruntime
+endif
+
 MODULE		= xpcom
 LIBRARY_NAME	= xpcomglue_s
 DIST_INSTALL	= 1
 
 LOCAL_INCLUDES	= \
 		-I$(srcdir)/../build \
 		$(NULL)
 
@@ -104,26 +110,18 @@ EXPORTS_mozilla = \
 EXPORTS_mozilla/threads = \
   nsThreadIDs.h \
   $(NULL)
 
 SDK_LIBRARY     =                        \
 		$(LIB_PREFIX)xpcomglue_s.$(LIB_SUFFIX) \
 		$(NULL)
 
-
-# we don't want the shared lib, but we want to force the creation of a static lib.
 FORCE_STATIC_LIB = 1
 
-
-# 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 = 1
-
 include $(topsrcdir)/config/rules.mk
 
 ifdef _MSC_VER
 # Don't include directives about which CRT to use
 OS_COMPILE_CXXFLAGS += -Zl
 OS_COMPILE_CFLAGS += -Zl
 DEFINES += -D_USE_ANSI_CPP
 endif
--- a/xpcom/glue/nomozalloc/Makefile.in
+++ b/xpcom/glue/nomozalloc/Makefile.in
@@ -12,17 +12,16 @@ include $(DEPTH)/config/autoconf.mk
 include $(srcdir)/../objs.mk
 
 EXTRA_DEPS += $(srcdir)/../objs.mk
 
 MODULE		= xpcom
 LIBRARY_NAME	= xpcomglue_s_nomozalloc
 DIST_INSTALL	= 1
 
-
 LOCAL_INCLUDES	= \
 		-I$(srcdir)/../../build \
 		$(NULL)
 
 CPPSRCS		= \
 		$(XPCOM_GLUE_SRC_LCPPSRCS) \
 		$(XPCOM_GLUENS_SRC_LCPPSRCS) \
 		nsStringAPI.cpp \
@@ -33,17 +32,16 @@ SDK_LIBRARY     =                       
 		$(LIB_PREFIX)xpcomglue_s_nomozalloc.$(LIB_SUFFIX) \
 		$(NULL)
 
 GARBAGE += $(CPPSRCS) DeadlockDetector.h SSE.h arm.h
 
 # we don't want the shared lib, but we want to force the creation of a static lib.
 FORCE_STATIC_LIB = 1
 
-
 # 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 = 1
 
 # Don't use STL wrappers here (i.e. wrapped <new>); they require mozalloc
 STL_FLAGS       =
 
--- a/xpcom/glue/standalone/Makefile.in
+++ b/xpcom/glue/standalone/Makefile.in
@@ -8,23 +8,29 @@ topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 include $(srcdir)/../objs.mk
 
 EXTRA_DEPS += $(srcdir)/../objs.mk
 
+# On win we build two glue libs - glue linked to crt dlls here and in staticruntime we build
+# a statically linked glue lib.
+ifeq ($(OS_ARCH),WINNT)
+DIRS += staticruntime
+endif
+
 MODULE		= xpcom
 LIBRARY_NAME	= xpcomglue
 DIST_INSTALL	= 1
 
 LOCAL_INCLUDES	= \
-		-I$(srcdir)/../../build \
-		$(NULL)
+	-I$(srcdir)/../../build \
+	$(NULL)
 
 ifeq (Darwin,$(OS_ARCH))
 ifeq (uikit,$(MOZ_WIDGET_TOOLKIT))
 LINKSRC = nsGlueLinkingDlopen.cpp
 else
 LINKSRC = nsGlueLinkingOSX.cpp
 endif
 endif
@@ -40,50 +46,43 @@ LINKSRC = nsGlueLinkingOS2.cpp
 endif
 
 ifndef LINKSRC
 LINKSRC = nsGlueLinkingNull.cpp
 $(warning TinderboxPrint:<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=298044">Error: XPCOM Glue</a>)
 endif
 
 CPPSRCS		= \
-		$(XPCOM_GLUE_SRC_LCPPSRCS)   \
-		nsStringAPI.cpp              \
-		nsXPCOMGlue.cpp              \
-		$(LINKSRC)                   \
-		$(NULL)
+	$(XPCOM_GLUE_SRC_LCPPSRCS)   \
+	nsStringAPI.cpp              \
+	nsXPCOMGlue.cpp              \
+	$(LINKSRC)                   \
+	$(NULL)
 
 SDK_HEADERS     = \
-		nsXPCOMGlue.h \
-		$(NULL)
+	nsXPCOMGlue.h \
+	$(NULL)
 
 SDK_LIBRARY     	= \
-		$(LIB_PREFIX)xpcomglue.$(LIB_SUFFIX) \
-		$(NULL)
-
-# we don't want the shared lib, but we want to force the creation of a static lib.
-FORCE_STATIC_LIB = 1
+	$(LIB_PREFIX)xpcomglue.$(LIB_SUFFIX) \
+	$(NULL)
 
-
-# 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 = 1
+FORCE_STATIC_LIB = 1
 
 # Don't use STL wrappers here (i.e. wrapped <new>); they require mozalloc
 STL_FLAGS	=
 
 GARBAGE         += $(XPCOM_GLUE_SRC_LCPPSRCS) $(wildcard *.$(OBJ_SUFFIX))
 
 SRCS_IN_OBJDIR	= 1
 
 include $(topsrcdir)/config/rules.mk
 
 ifdef _MSC_VER
-# Don't include directives about which CRT to use
+# Don't include directives in obj files about which CRT to use
 OS_COMPILE_CXXFLAGS += -Zl
 OS_COMPILE_CFLAGS += -Zl
 DEFINES += -D_USE_ANSI_CPP
 endif
 
 export:: $(XPCOM_GLUE_SRC_CPPSRCS) $(topsrcdir)/xpcom/glue/nsStringAPI.cpp
 	$(INSTALL) $^ .
 
new file mode 100644
--- /dev/null
+++ b/xpcom/glue/standalone/staticruntime/Makefile.in
@@ -0,0 +1,89 @@
+# 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/.
+
+DEPTH		= ../../../..
+topsrcdir	= @top_srcdir@
+srcdir		= @srcdir@
+VPATH		= @srcdir@
+
+include $(DEPTH)/config/autoconf.mk
+include $(srcdir)/../../objs.mk
+
+EXTRA_DEPS += $(srcdir)/../../objs.mk
+
+MODULE		= xpcom
+LIBRARY_NAME	= xpcomglue_staticruntime
+DIST_INSTALL	= 1
+
+LOCAL_INCLUDES	= \
+	-I$(srcdir)/../../../build \
+	$(NULL)
+
+ifeq (Darwin,$(OS_ARCH))
+ifeq (uikit,$(MOZ_WIDGET_TOOLKIT))
+LINKSRC = nsGlueLinkingDlopen.cpp
+else
+LINKSRC = nsGlueLinkingOSX.cpp
+endif
+endif
+
+ifeq ($(OS_ARCH),WINNT)
+LINKSRC = nsGlueLinkingWin.cpp
+endif
+ifneq (,$(filter AIX DragonFly FreeBSD GNU GNU_% Linux NetBSD OpenBSD SunOS,$(OS_ARCH)))
+LINKSRC = nsGlueLinkingDlopen.cpp
+endif
+ifeq (OS2,$(OS_ARCH))
+LINKSRC = nsGlueLinkingOS2.cpp
+endif
+
+ifndef LINKSRC
+LINKSRC = nsGlueLinkingNull.cpp
+$(warning TinderboxPrint:<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=298044">Error: XPCOM Glue</a>)
+endif
+
+CPPSRCS		= \
+	$(XPCOM_GLUE_SRC_LCPPSRCS)   \
+	nsXPCOMGlue.cpp              \
+	nsStringAPI.cpp              \
+	$(LINKSRC)                   \
+	$(NULL)
+
+SDK_LIBRARY     	= \
+	$(LIB_PREFIX)xpcomglue_staticruntime.$(LIB_SUFFIX) \
+	$(NULL)
+
+# create a static lib
+FORCE_STATIC_LIB = 1
+
+# Statically link to the CRT on Windows
+USE_STATIC_LIBS = 1
+
+# Don't use STL wrappers here (i.e. wrapped <new>); they require mozalloc
+STL_FLAGS	=
+
+GARBAGE         += $(XPCOM_GLUE_SRC_LCPPSRCS) $(wildcard *.$(OBJ_SUFFIX))
+
+SRCS_IN_OBJDIR	= 1
+
+include $(topsrcdir)/config/rules.mk
+
+ifdef _MSC_VER
+# Don't include directives in obj files about which CRT to use
+OS_COMPILE_CXXFLAGS += -Zl
+OS_COMPILE_CFLAGS += -Zl
+DEFINES += -D_USE_ANSI_CPP
+endif
+
+export:: $(XPCOM_GLUE_SRC_CPPSRCS) $(topsrcdir)/xpcom/glue/nsStringAPI.cpp ../nsXPCOMGlue.cpp ../nsGlueLinking.h ../$(LINKSRC)
+	$(INSTALL) $^ .
+
+GARBAGE += nsStringAPI.cpp nsXPCOMGlue.cpp nsGlueLinking.h $(LINKSRC)
+
+DEFINES		+= -DXPCOM_GLUE
+
+ifdef TARGET_XPCOM_ABI
+DEFINES += -DTARGET_XPCOM_ABI=\"$(TARGET_XPCOM_ABI)\"
+endif
+
new file mode 100644
--- /dev/null
+++ b/xpcom/glue/staticruntime/Makefile.in
@@ -0,0 +1,60 @@
+# 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/.
+
+DEPTH		= ../../..
+topsrcdir	= @top_srcdir@
+srcdir		= @srcdir@
+VPATH		= @srcdir@
+
+include $(DEPTH)/config/autoconf.mk
+include $(srcdir)/../objs.mk
+
+EXTRA_DEPS += $(srcdir)/../objs.mk
+
+MODULE		= xpcom
+LIBRARY_NAME	= xpcomglue_staticruntime_s
+DIST_INSTALL	= 1
+
+LOCAL_INCLUDES	= \
+	-I$(srcdir)/../../build \
+	$(NULL)
+
+CPPSRCS		= \
+	$(XPCOM_GLUE_SRC_LCPPSRCS) \
+	$(XPCOM_GLUENS_SRC_LCPPSRCS) \
+	nsStringAPI.cpp \
+	GenericModule.cpp \
+	$(NULL)
+
+SDK_LIBRARY     	= \
+	$(LIB_PREFIX)xpcomglue_staticruntime_s.$(LIB_SUFFIX) \
+	$(NULL)
+
+GARBAGE         += $(XPCOM_GLUE_SRC_LCPPSRCS) $(wildcard *.$(OBJ_SUFFIX))
+
+FORCE_STATIC_LIB = 1
+
+# Statically link to the CRT on Windows
+USE_STATIC_LIBS = 1
+
+# Don't use STL wrappers here (i.e. wrapped <new>); they require mozalloc
+STL_FLAGS	=
+
+include $(topsrcdir)/config/rules.mk
+
+ifdef _MSC_VER
+# Don't include directives about which CRT to use
+OS_COMPILE_CXXFLAGS += -Zl
+OS_COMPILE_CFLAGS += -Zl
+DEFINES += -D_USE_ANSI_CPP
+endif
+
+export:: $(XPCOM_GLUE_SRC_CPPSRCS) $(XPCOM_GLUENS_SRC_CPPSRCS) $(topsrcdir)/xpcom/glue/nsStringAPI.cpp $(topsrcdir)/xpcom/glue/GenericModule.cpp $(topsrcdir)/xpcom/glue/DeadlockDetector.h $(topsrcdir)/xpcom/glue/SSE.h $(topsrcdir)/xpcom/glue/arm.h
+	$(INSTALL) $^ .
+
+ifdef TARGET_XPCOM_ABI
+DEFINES += -DTARGET_XPCOM_ABI=\"$(TARGET_XPCOM_ABI)\"
+endif
+
--- a/xulrunner/stub/Makefile.in
+++ b/xulrunner/stub/Makefile.in
@@ -28,17 +28,17 @@ LOCAL_INCLUDES = \
   -I$(topsrcdir)/xpcom/build \
   -I$(topsrcdir)/xpcom/base \
   $(NULL)
 
 DEFINES  += -DXPCOM_GLUE
 STL_FLAGS=
 
 LIBS = \
-  $(XPCOM_STANDALONE_GLUE_LDOPTS) \
+  $(XPCOM_STANDALONE_STATICRUNTIME_GLUE_LDOPTS) \
   $(NULL)
 
 # Need to link with CoreFoundation on Mac
 ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 LIBS            += \
 		$(TK_LIBS) \
 		$(NULL)
 endif