Bug 643690 part 1 - Avoid requiring libstdc++ symbol versions > GLIBCXX_3.4.8 (gcc > 4.1). r=ted,r=tglek
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 15 Apr 2011 11:03:17 +0200
changeset 68153 3a38a70b0e1258a7a389dd813c67d4de6d4b5ea8
parent 68152 29ea31633ac69c8d7219bb7a741bb8ae182da4d6
child 68154 2aa8ce6b37e0f5e3c922143b28dbfb3c83c5a932
push id19526
push usermh@glandium.org
push dateFri, 15 Apr 2011 10:46:22 +0000
treeherdermozilla-central@2aa8ce6b37e0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted, tglek
bugs643690
milestone6.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 643690 part 1 - Avoid requiring libstdc++ symbol versions > GLIBCXX_3.4.8 (gcc > 4.1). r=ted,r=tglek
build/stdc++compat.cpp
build/unix/elfhack/Makefile.in
config/autoconf.mk.in
configure.in
modules/plugin/test/testplugin/Makefile.in
toolkit/crashreporter/client/Makefile.in
toolkit/crashreporter/test/Makefile.in
toolkit/library/Makefile.in
xpcom/tests/Makefile.in
new file mode 100644
--- /dev/null
+++ b/build/stdc++compat.cpp
@@ -0,0 +1,114 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is a hack to avoid dependencies on recent libstdc++.
+ *
+ * The Initial Developer of the Original Code is
+ * Mozilla Foundation.
+ * Portions created by the Initial Developer are Copyright (C) 2011
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Mike Hommey <mh@glandium.org>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include <ostream>
+#include <istream>
+#ifdef DEBUG
+#include <string>
+#endif
+
+namespace std {
+#if (__GNUC__ == 4) && (__GNUC_MINOR__ >= 2)
+    /* Instantiate these templates to avoid GLIBCXX_3.4.9 symbol versions */
+    template ostream& ostream::_M_insert(double);
+    template ostream& ostream::_M_insert(long);
+    template ostream& ostream::_M_insert(unsigned long);
+    template ostream& __ostream_insert(ostream&, const char*, streamsize);
+    template istream& istream::_M_extract(double&);
+#endif
+#ifdef DEBUG
+#if (__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)
+    /* Instantiate these templates to avoid GLIBCXX_3.4.14 symbol versions
+     * in debug builds */
+    template char *basic_string<char, char_traits<char>, allocator<char> >::_S_construct_aux_2(size_type, char, allocator<char> const&);
+    template wchar_t *basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >::_S_construct_aux_2(size_type, wchar_t, allocator<wchar_t> const&);
+#endif
+#endif
+}
+
+namespace std __attribute__((visibility("default"))) {
+
+#if (__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)
+    /* Hack to avoid GLIBCXX_3.4.14 symbol versions */
+    struct _List_node_base
+    {
+        void hook(_List_node_base * const __position) throw ();
+
+        void unhook() throw ();
+
+        void transfer(_List_node_base * const __first,
+                      _List_node_base * const __last) throw();
+
+        void _M_hook(_List_node_base * const __position) throw ();
+
+        void _M_unhook() throw ();
+
+        void _M_transfer(_List_node_base * const __first,
+                         _List_node_base * const __last) throw();
+    };
+
+    /* The functions actually have the same implementation */
+    void
+    _List_node_base::_M_hook(_List_node_base * const __position) throw ()
+    {
+        hook(__position);
+    }
+
+    void
+    _List_node_base::_M_unhook() throw ()
+    {
+        unhook();
+    }
+
+    void
+    _List_node_base::_M_transfer(_List_node_base * const __first,
+                                 _List_node_base * const __last) throw ()
+    {
+        transfer(__first, __last);
+    }
+#endif
+
+#if (__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)
+    /* Hack to avoid GLIBCXX_3.4.11 symbol versions
+       An inline definition of ctype<char>::_M_widen_init() used to be in
+       locale_facets.h before GCC 4.4, but moved out of headers in more
+       recent versions.
+       It is actually safe to make it do nothing. */
+    void ctype<char>::_M_widen_init() const {}
+#endif
+
+}
--- a/build/unix/elfhack/Makefile.in
+++ b/build/unix/elfhack/Makefile.in
@@ -43,19 +43,22 @@ VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 INTERNAL_TOOLS = 1
 
 HOST_PROGRAM = elfhack
 NO_DIST_INSTALL = 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)))
--- a/config/autoconf.mk.in
+++ b/config/autoconf.mk.in
@@ -112,16 +112,17 @@ MOZ_CALLGRIND   = @MOZ_CALLGRIND@
 MOZ_VTUNE       = @MOZ_VTUNE@
 MOZ_TRACE_JSCALLS = @MOZ_TRACE_JSCALLS@
 MOZ_TRACEVIS    = @MOZ_TRACEVIS@
 DEHYDRA_PATH    = @DEHYDRA_PATH@
 
 NS_TRACE_MALLOC = @NS_TRACE_MALLOC@
 USE_ELF_DYNSTR_GC = @USE_ELF_DYNSTR_GC@
 USE_ELF_HACK = @USE_ELF_HACK@
+STDCXX_COMPAT = @STDCXX_COMPAT@
 INCREMENTAL_LINKER = @INCREMENTAL_LINKER@
 MACOSX_DEPLOYMENT_TARGET = @MACOSX_DEPLOYMENT_TARGET@
 MOZ_MAIL_NEWS	= @MOZ_MAIL_NEWS@
 BUILD_STATIC_LIBS = @BUILD_STATIC_LIBS@
 MOZ_ENABLE_LIBXUL = @MOZ_ENABLE_LIBXUL@
 ENABLE_TESTS	= @ENABLE_TESTS@
 IBMBIDI = @IBMBIDI@
 MOZ_UNIVERSALCHARDET = @MOZ_UNIVERSALCHARDET@
--- a/configure.in
+++ b/configure.in
@@ -7712,16 +7712,38 @@ if test "$USE_ELF_HACK" = 1; then
         ;;
     *)
         USE_ELF_HACK=
         ;;
     esac
 fi
 
 dnl ========================================================
+dnl = libstdc++ compatibility hacks
+dnl ========================================================
+
+STDCXX_COMPAT=stdc++compat.cpp
+MOZ_ARG_DISABLE_BOOL(stdcxx-compat,
+[  --disable-stdcxx-compat Disable libstdc++ compatibility],
+    STDCXX_COMPAT=)
+
+# Disable on platforms where it doesn't make sense
+if test -n "$STDCXX_COMPAT"; then
+    case "${OS_TARGET}" in
+    Linux)
+        ;;
+    *)
+        STDCXX_COMPAT=
+        ;;
+    esac
+fi
+
+AC_SUBST(STDCXX_COMPAT)
+
+dnl ========================================================
 dnl = 
 dnl = Profiling and Instrumenting
 dnl = 
 dnl ========================================================
 MOZ_ARG_HEADER(Profiling and Instrumenting)
 
 dnl ========================================================
 dnl = Enable timeline service, which provides lightweight
--- a/modules/plugin/test/testplugin/Makefile.in
+++ b/modules/plugin/test/testplugin/Makefile.in
@@ -51,19 +51,22 @@ STL_FLAGS =
 
 # must link statically with the CRT; nptest isn't Gecko code
 USE_STATIC_LIBS = 1
 
 # Need to custom install plugins
 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/toolkit/crashreporter/client/Makefile.in
+++ b/toolkit/crashreporter/client/Makefile.in
@@ -53,17 +53,22 @@ STL_FLAGS =
 
 ifneq ($(OS_TARGET),Android)
 PROGRAM = crashreporter$(BIN_SUFFIX)
 DIST_PROGRAM = crashreporter$(BIN_SUFFIX)
 endif
 
 LOCAL_INCLUDES = -I$(srcdir)/../google-breakpad/src
 
-CPPSRCS = crashreporter.cpp
+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)
 LOCAL_INCLUDES += -I$(srcdir)
--- a/toolkit/crashreporter/test/Makefile.in
+++ b/toolkit/crashreporter/test/Makefile.in
@@ -47,25 +47,27 @@ MODULE = crashreporter_test
 XPCSHELL_TESTS = unit
 
 LIBRARY_NAME = testcrasher
 NO_DIST_INSTALL = 1
 
 VPATH += \
   $(srcdir)/../google-breakpad/src/processor/ \
   $(srcdir)/../google-breakpad/src/common/ \
+  $(topsrcdir)/build/ \
   $(NULL)
 
 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)
--- a/toolkit/library/Makefile.in
+++ b/toolkit/library/Makefile.in
@@ -58,16 +58,18 @@ ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
 # "libxul.dylib"
 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),WINCE)
 CPPSRCS += dlldeps-xul.cpp
 endif
--- a/xpcom/tests/Makefile.in
+++ b/xpcom/tests/Makefile.in
@@ -59,30 +59,32 @@ DIRS		= external component
 ifeq ($(OS_ARCH),WINNT)
 DIRS		+= windows
 endif
 
 ifdef DEHYDRA_PATH
 DIRS += static-checker
 endif
 
+VPATH += $(topsrcdir)/build
 
-CPPSRCS		= \
-		nsIFileEnumerator.cpp \
-		TestCallTemplates.cpp \
-		TestINIParser.cpp \
-		TestRacingServiceManager.cpp \
-		TestRegistrationOrder.cpp \
-		TestThreadPoolListener.cpp \
-		TestTimers.cpp \
-		TestBlockingProcess.cpp \
-		TestQuickReturn.cpp \
-		TestArguments.cpp \
-		TestUnicodeArguments.cpp \
-		$(NULL)
+CPPSRCS = \
+  nsIFileEnumerator.cpp \
+  TestCallTemplates.cpp \
+  TestINIParser.cpp \
+  TestRacingServiceManager.cpp \
+  TestRegistrationOrder.cpp \
+  TestThreadPoolListener.cpp \
+  TestTimers.cpp \
+  TestBlockingProcess.cpp \
+  TestQuickReturn.cpp \
+  TestArguments.cpp \
+  TestUnicodeArguments.cpp \
+  $(STDCPPFLAGS) \
+  $(NULL)
 
 ifdef WRAP_STL_INCLUDES
 CPPSRCS += TestSTLWrappers.cpp
 endif
 
 SIMPLE_PROGRAMS	:= $(CPPSRCS:.cpp=$(BIN_SUFFIX))
 
 CPP_UNIT_TESTS = \
@@ -219,8 +221,13 @@ check::
 		exit 1; \
 	fi
 	$(RM_DIST) $(DIST_PATH)components/compreg.dat; \
 	$(DOCOPY) \
 	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