Bug 748739 - Link stdc++compat as a static library, and always link it when STDCXX_COMPAT is enabled. r=ted
authorMike Hommey <mh+mozilla@glandium.org>
Mon, 30 Apr 2012 08:03:59 +0200
changeset 96760 93c2ecbcde044dc4a511538ef9eb92e05c64f738
parent 96759 5bc899138eb47ec8f0fc8badf3ffba76a8327d11
child 96761 9150ab0f7bea14edb7878ead90eae2606c85fafe
push idunknown
push userunknown
push dateunknown
reviewersted
bugs748739
milestone15.0a1
Bug 748739 - Link stdc++compat as a static library, and always link it when STDCXX_COMPAT is enabled. r=ted
allmakefiles.sh
build/stdc++compat.cpp
build/unix/Makefile.in
build/unix/elfhack/Makefile.in
build/unix/stdc++compat/Makefile.in
build/unix/stdc++compat/stdc++compat.cpp
config/Makefile.in
config/config.mk
config/rules.mk
configure.in
dom/plugins/test/testplugin/Makefile.in
js/src/config/config.mk
js/src/config/rules.mk
toolkit/crashreporter/client/Makefile.in
toolkit/crashreporter/google-breakpad/src/tools/linux/dump_syms/Makefile.in
toolkit/crashreporter/test/Makefile.in
toolkit/library/Makefile.in
xpcom/tests/Makefile.in
--- a/allmakefiles.sh
+++ b/allmakefiles.sh
@@ -84,16 +84,21 @@ if [ "$OS_ARCH" = "WINNT" ]; then
     build/win32/crashinjectdll/Makefile
   "
 fi
 
 if [ "$OS_ARCH" != "WINNT" -a "$OS_ARCH" != "OS2" ]; then
   add_makefiles "
     build/unix/Makefile
   "
+  if [ "$STDCXX_COMPAT" ]; then
+    add_makefiles "
+      build/unix/stdc++compat/Makefile
+    "
+  fi
   if [ "$USE_ELF_HACK" ]; then
     add_makefiles "
       build/unix/elfhack/Makefile
     "
   fi
 fi
 
 if [ "$COMPILER_DEPEND" = "" -a "$MOZ_NATIVE_MAKEDEPEND" = "" ]; then
--- a/build/unix/Makefile.in
+++ b/build/unix/Makefile.in
@@ -42,18 +42,22 @@ DEPTH		= ../..
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE       = build
 
+ifdef STDCXX_COMPAT
+DIRS += stdc++compat
+endif
+
 ifdef USE_ELF_HACK
-DIRS = elfhack
+DIRS += elfhack
 endif
 
 TEST_DIRS = test
 
 include $(topsrcdir)/config/rules.mk
 
 libs:: $(srcdir)/run-mozilla.sh
 	$(INSTALL) $< $(DIST)/bin
--- a/build/unix/elfhack/Makefile.in
+++ b/build/unix/elfhack/Makefile.in
@@ -49,17 +49,16 @@ HOST_PROGRAM = elfhack
 NO_DIST_INSTALL = 1
 NO_PROFILE_GUIDED_OPTIMIZE = 1
 
 VPATH += $(topsrcdir)/build
 
 HOST_CPPSRCS = \
   elf.cpp \
   elfhack.cpp \
-  $(STDCXX_COMPAT) \
   $(NULL)
 
 OS_CXXFLAGS := $(filter-out -fno-exceptions,$(OS_CXXFLAGS)) -fexceptions
 
 ifneq (,$(filter %86,$(TARGET_CPU)))
 CPU := x86
 else
 ifneq (,$(filter arm%,$(TARGET_CPU)))
new file mode 100644
--- /dev/null
+++ b/build/unix/stdc++compat/Makefile.in
@@ -0,0 +1,27 @@
+# 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
+
+MODULE		= build
+LIBRARY_NAME	= stdc++compat
+HOST_LIBRARY_NAME = host_stdc++compat
+FORCE_STATIC_LIB= 1
+STL_FLAGS =
+NO_EXPAND_LIBS = 1
+
+CPPSRCS = \
+  stdc++compat.cpp
+  $(NULL)
+
+HOST_CPPSRCS = $(CPPSRCS)
+
+include $(topsrcdir)/config/rules.mk
+
+CXXFLAGS += -DMOZ_LIBSTDCXX_VERSION=$(MOZ_LIBSTDCXX_TARGET_VERSION)
rename from build/stdc++compat.cpp
rename to build/unix/stdc++compat/stdc++compat.cpp
--- a/config/Makefile.in
+++ b/config/Makefile.in
@@ -44,16 +44,20 @@ srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 # For sanity's sake, we compile nsinstall without the wrapped system
 # headers, so that we can use it to set up the wrapped system headers.
 VISIBILITY_FLAGS =
 
+# STDCXX_COMPAT is not needed here, and will actually fail because
+# libstdc++-compat is not built yet.
+STDCXX_COMPAT =
+
 HOST_PROGRAM	= nsinstall$(HOST_BIN_SUFFIX)
 
 ifeq (WINNT,$(HOST_OS_ARCH))
 HOST_CSRCS	= nsinstall_win.c
 else
 HOST_CSRCS	= nsinstall.c pathsub.c
 endif
 
--- a/config/config.mk
+++ b/config/config.mk
@@ -784,16 +784,19 @@ ifdef SYMBOL_ORDER
 EXPAND_MKSHLIB_ARGS += --symbol-order $(SYMBOL_ORDER)
 endif
 EXPAND_MKSHLIB = $(EXPAND_LIBS_EXEC) $(EXPAND_MKSHLIB_ARGS) -- $(MKSHLIB)
 
 ifdef STDCXX_COMPAT
 ifneq ($(OS_ARCH),Darwin)
 CHECK_STDCXX = objdump -p $(1) | grep -e 'GLIBCXX_3\.4\.\(9\|[1-9][0-9]\)' > /dev/null && echo "TEST-UNEXPECTED-FAIL | | We don't want these libstdc++ symbols to be used:" && objdump -T $(1) | grep -e 'GLIBCXX_3\.4\.\(9\|[1-9][0-9]\)' && exit 1 || exit 0
 endif
+
+EXTRA_LIBS += $(call EXPAND_LIBNAME_PATH,stdc++compat,$(DEPTH)/build/unix/stdc++compat)
+HOST_EXTRA_LIBS += $(call EXPAND_LIBNAME_PATH,host_stdc++compat,$(DEPTH)/build/unix/stdc++compat)
 endif
 
 # autoconf.mk sets OBJ_SUFFIX to an error to avoid use before including
 # this file
 OBJ_SUFFIX := $(_OBJ_SUFFIX)
 
 # PGO builds with GCC build objects with instrumentation in a first pass,
 # then objects optimized, without instrumentation, in a second pass. If
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -821,19 +821,16 @@ ifdef GNU_CC
 $(PROGRAM) $(SHARED_LIBRARY) $(LIBRARY): FORCE
 endif
 endif
 
 endif # NO_PROFILE_GUIDED_OPTIMIZE
 
 ##############################################
 
-stdc++compat.$(OBJ_SUFFIX): CXXFLAGS+=-DMOZ_LIBSTDCXX_VERSION=$(MOZ_LIBSTDCXX_TARGET_VERSION)
-host_stdc++compat.$(OBJ_SUFFIX): CXXFLAGS+=-DMOZ_LIBSTDCXX_VERSION=$(MOZ_LIBSTDCXX_HOST_VERSION)
-
 checkout:
 	$(MAKE) -C $(topsrcdir) -f client.mk checkout
 
 clean clobber realclean clobber_all:: $(SUBMAKEFILES)
 	-$(RM) $(ALL_TRASH)
 	-$(RM) -r $(ALL_TRASH_DIRS)
 	$(foreach dir,$(PARALLEL_DIRS) $(DIRS) $(STATIC_DIRS) $(TOOL_DIRS),-$(call SUBMAKE,$@,$(dir)))
 
--- a/configure.in
+++ b/configure.in
@@ -7514,17 +7514,17 @@ fi
 
 dnl ========================================================
 dnl = libstdc++ compatibility hacks
 dnl ========================================================
 
 STDCXX_COMPAT=
 MOZ_ARG_ENABLE_BOOL(stdcxx-compat,
 [  --enable-stdcxx-compat  Enable compatibility with older libstdc++],
-    STDCXX_COMPAT=stdc++compat.cpp)
+    STDCXX_COMPAT=1)
 
 AC_SUBST(STDCXX_COMPAT)
 
 if test -n "$STDCXX_COMPAT"; then
    eval $(CXX="$CXX" MACOS_SDK_DIR="$MACOS_SDK_DIR" $PYTHON $_topsrcdir/build/autoconf/libstdcxx.py)
    AC_SUBST(MOZ_LIBSTDCXX_TARGET_VERSION)
    AC_SUBST(MOZ_LIBSTDCXX_HOST_VERSION)
 fi
--- a/dom/plugins/test/testplugin/Makefile.in
+++ b/dom/plugins/test/testplugin/Makefile.in
@@ -57,17 +57,16 @@ USE_STATIC_LIBS = 1
 NO_DIST_INSTALL	= 1
 NO_INSTALL = 1
 
 VPATH += $(topsrcdir)/build
 
 CPPSRCS   =  \
   nptest.cpp \
   nptest_utils.cpp \
-  $(STDCXX_COMPAT) \
   $(NULL)
 
 ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
 CMMSRCS = nptest_macosx.mm
 endif
 
 ifeq ($(MOZ_WIDGET_TOOLKIT),gtk2)
 CPPSRCS += nptest_gtk2.cpp
--- a/js/src/config/config.mk
+++ b/js/src/config/config.mk
@@ -784,16 +784,19 @@ ifdef SYMBOL_ORDER
 EXPAND_MKSHLIB_ARGS += --symbol-order $(SYMBOL_ORDER)
 endif
 EXPAND_MKSHLIB = $(EXPAND_LIBS_EXEC) $(EXPAND_MKSHLIB_ARGS) -- $(MKSHLIB)
 
 ifdef STDCXX_COMPAT
 ifneq ($(OS_ARCH),Darwin)
 CHECK_STDCXX = objdump -p $(1) | grep -e 'GLIBCXX_3\.4\.\(9\|[1-9][0-9]\)' > /dev/null && echo "TEST-UNEXPECTED-FAIL | | We don't want these libstdc++ symbols to be used:" && objdump -T $(1) | grep -e 'GLIBCXX_3\.4\.\(9\|[1-9][0-9]\)' && exit 1 || exit 0
 endif
+
+EXTRA_LIBS += $(call EXPAND_LIBNAME_PATH,stdc++compat,$(DEPTH)/build/unix/stdc++compat)
+HOST_EXTRA_LIBS += $(call EXPAND_LIBNAME_PATH,host_stdc++compat,$(DEPTH)/build/unix/stdc++compat)
 endif
 
 # autoconf.mk sets OBJ_SUFFIX to an error to avoid use before including
 # this file
 OBJ_SUFFIX := $(_OBJ_SUFFIX)
 
 # PGO builds with GCC build objects with instrumentation in a first pass,
 # then objects optimized, without instrumentation, in a second pass. If
--- a/js/src/config/rules.mk
+++ b/js/src/config/rules.mk
@@ -821,19 +821,16 @@ ifdef GNU_CC
 $(PROGRAM) $(SHARED_LIBRARY) $(LIBRARY): FORCE
 endif
 endif
 
 endif # NO_PROFILE_GUIDED_OPTIMIZE
 
 ##############################################
 
-stdc++compat.$(OBJ_SUFFIX): CXXFLAGS+=-DMOZ_LIBSTDCXX_VERSION=$(MOZ_LIBSTDCXX_TARGET_VERSION)
-host_stdc++compat.$(OBJ_SUFFIX): CXXFLAGS+=-DMOZ_LIBSTDCXX_VERSION=$(MOZ_LIBSTDCXX_HOST_VERSION)
-
 checkout:
 	$(MAKE) -C $(topsrcdir) -f client.mk checkout
 
 clean clobber realclean clobber_all:: $(SUBMAKEFILES)
 	-$(RM) $(ALL_TRASH)
 	-$(RM) -r $(ALL_TRASH_DIRS)
 	$(foreach dir,$(PARALLEL_DIRS) $(DIRS) $(STATIC_DIRS) $(TOOL_DIRS),-$(call SUBMAKE,$@,$(dir)))
 
--- a/toolkit/crashreporter/client/Makefile.in
+++ b/toolkit/crashreporter/client/Makefile.in
@@ -61,17 +61,16 @@ MOZ_GLUE_PROGRAM_LDFLAGS =
 endif
 
 LOCAL_INCLUDES = -I$(srcdir)/../google-breakpad/src
 
 VPATH += $(topsrcdir)/build/
 
 CPPSRCS = \
   crashreporter.cpp \
-  $(STDCXX_COMPAT) \
   $(NULL)
 
 ifeq ($(OS_ARCH),WINNT)
 CPPSRCS += crashreporter_win.cpp
 LIBS += \
   $(DEPTH)/toolkit/crashreporter/google-breakpad/src/client/windows/sender/$(LIB_PREFIX)crash_report_sender_s.$(LIB_SUFFIX) \
   $(DEPTH)/toolkit/crashreporter/google-breakpad/src/common/windows/$(LIB_PREFIX)breakpad_windows_common_s.$(LIB_SUFFIX) \
   $(NULL)
--- a/toolkit/crashreporter/google-breakpad/src/tools/linux/dump_syms/Makefile.in
+++ b/toolkit/crashreporter/google-breakpad/src/tools/linux/dump_syms/Makefile.in
@@ -56,13 +56,9 @@ HOST_LIBS += \
   $(DEPTH)/toolkit/crashreporter/google-breakpad/src/common/linux/$(LIB_PREFIX)host_breakpad_linux_common_s.$(LIB_SUFFIX) \
   $(DEPTH)/toolkit/crashreporter/google-breakpad/src/common/$(LIB_PREFIX)host_breakpad_common_s.$(LIB_SUFFIX) \
   $(DEPTH)/toolkit/crashreporter/google-breakpad/src/common/dwarf/$(LIB_PREFIX)host_breakpad_dwarf_s.$(LIB_SUFFIX) \
   $(NULL)
 
 # force C++ linking
 CPP_PROG_LINK = 1
 
-#XXX: bug 554854 causes us to be unable to run binaries on the build slaves
-# due to them having an older libstdc++
-HOST_LDFLAGS += -static
-
 include $(topsrcdir)/config/rules.mk
--- a/toolkit/crashreporter/test/Makefile.in
+++ b/toolkit/crashreporter/test/Makefile.in
@@ -59,17 +59,16 @@ VPATH += \
 
 CPPSRCS = \
   nsTestCrasher.cpp \
   dumputils.cpp \
   basic_code_modules.cc \
   logging.cc \
   minidump.cc \
   pathname_stripper.cc \
-  $(STDCXX_COMPAT) \
   $(NULL)
 
 LOCAL_INCLUDES += \
   -I$(XPIDL_GEN_DIR) \
   -I$(srcdir)/../google-breakpad/src/ \
   $(NULL)
 EXTRA_DSO_LIBS += xpcom
 EXTRA_DSO_LDOPTS += $(LIBS_DIR) $(MOZ_COMPONENT_LIBS) $(XPCOM_GLUE_LDOPTS)
--- a/toolkit/library/Makefile.in
+++ b/toolkit/library/Makefile.in
@@ -23,17 +23,16 @@ ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
 LIBRARY_NAME=XUL
 # Setting MAKE_FRAMEWORK makes DLL_PREFIX and DLL_SUFFIX be ignored when
 # setting SHARED_LIBRARY; we need to leave DLL_PREFIX and DLL_SUFFIX
 # as-is so that dependencies of the form -ltracemalloc still work.
 MAKE_FRAMEWORK=1
 endif
 
 VPATH += $(topsrcdir)/build/
-CPPSRCS += $(STDCXX_COMPAT)
 
 ifeq ($(OS_ARCH)_$(GNU_CC),WINNT_)
 CPPSRCS += dlldeps-xul.cpp
 endif
 
 ifeq ($(OS_ARCH),OS2)
 CPPSRCS += dlldeps-xul.cpp
 endif
--- a/xpcom/tests/Makefile.in
+++ b/xpcom/tests/Makefile.in
@@ -200,13 +200,8 @@ RM_DIST = rm -f
 regOrderDir="$(call getnativepath,$(abs_srcdir)/regorder)";
 DOCOPY=
 
 check::
 	XPCOM_DEBUG_BREAK=stack-and-abort $(RUN_TEST_PROGRAM) \
 	  $(DIST)/bin/TestRegistrationOrder$(BIN_SUFFIX) $(regOrderDir)
 
 GARBAGE += TestScriptable.h
-
-ifdef STDCXX_COMPAT
-TestCheckedInt: $(STDCXX_COMPAT:.cpp=.$(OBJ_SUFFIX))
-TestCheckedInt: LIBS += $(STDCXX_COMPAT:.cpp=.$(OBJ_SUFFIX))
-endif