Bug 850576 - Statically link stlport on b2g and android, and always use a custom built stlport for that. r=ted
authorMike Hommey <mh+mozilla@glandium.org>
Mon, 15 Jul 2013 18:48:39 +0900
changeset 138460 926141b660e5db51975f2f46e2dfc27e9b6eb228
parent 138459 75ec39054b8a69b05128d2261a3b5a255eb485d4
child 138461 375bbf91af55f72175fdedc1a85e4420ea3ec4ed
push id30988
push usermh@glandium.org
push dateMon, 15 Jul 2013 09:51:22 +0000
treeherdermozilla-inbound@5c3ae19d8f6b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted
bugs850576
milestone25.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 850576 - Statically link stlport on b2g and android, and always use a custom built stlport for that. r=ted
build/autoconf/android.m4
build/moz.build
build/stlport/Makefile.in
build/stlport/README.mozilla
build/stlport/android-mozilla-config.patch
build/stlport/moz.build
build/stlport/stl/config/_android.h.in
build/stlport/stlport/stl/config/_android.h
config/rules.mk
configure.in
js/src/build/autoconf/android.m4
js/src/config/rules.mk
--- a/build/autoconf/android.m4
+++ b/build/autoconf/android.m4
@@ -239,37 +239,25 @@ if test "$OS_TARGET" = "Android" -a -z "
             elif test -e "$android_ndk/sources/cxx-stl/gnu-libstdc++/libs/$ANDROID_CPU_ARCH/libstdc++.a"; then
                 # android-ndk-r5c, android-ndk-r6, android-ndk-r6b
                 STLPORT_CPPFLAGS="-I$android_ndk/sources/cxx-stl/gnu-libstdc++/include -I$android_ndk/sources/cxx-stl/gnu-libstdc++/libs/$ANDROID_CPU_ARCH/include"
                 STLPORT_LDFLAGS="-L$android_ndk/sources/cxx-stl/gnu-libstdc++/libs/$ANDROID_CPU_ARCH/"
                 STLPORT_LIBS="-lstdc++"
             else
                 AC_MSG_ERROR([Couldn't find path to gnu-libstdc++ in the android ndk])
             fi
-        elif test -e "$android_ndk/sources/cxx-stl/stlport/src/iostream.cpp" ; then
-            if test -e "$android_ndk/sources/cxx-stl/stlport/libs/$ANDROID_CPU_ARCH/libstlport_static.a"; then
-                STLPORT_LDFLAGS="-L$_objdir/build/stlport -L$android_ndk/sources/cxx-stl/stlport/libs/$ANDROID_CPU_ARCH/"
-            elif test -e "$android_ndk/tmp/ndk-digit/build/install/sources/cxx-stl/stlport/libs/$ANDROID_CPU_ARCH/libstlport_static.a"; then
-                STLPORT_LDFLAGS="-L$_objdir/build/stlport -L$android_ndk/tmp/ndk-digit/build/install/sources/cxx-stl/stlport/libs/$ANDROID_CPU_ARCH/"
-            else
-                AC_MSG_ERROR([Couldn't find path to stlport in the android ndk])
-            fi
-            STLPORT_SOURCES="$android_ndk/sources/cxx-stl/stlport"
-            STLPORT_CPPFLAGS="-I$_objdir/build/stlport -I$android_ndk/sources/cxx-stl/stlport/stlport"
-            STLPORT_LIBS="-lstlport_static -static-libstdc++"
-        elif test "$target" != "arm-android-eabi"; then
-            dnl fail if we're not building with NDKr4
-            AC_MSG_ERROR([Couldn't find path to stlport in the android ndk])
+        else
+            STLPORT_CPPFLAGS="-I$_topsrcdir/build/stlport/stlport -I$android_ndk/sources/cxx-stl/system/include"
+            STLPORT_LIBS="$_objdir/build/stlport/libstlport_static.a -static-libstdc++"
         fi
     fi
     CXXFLAGS="$CXXFLAGS $STLPORT_CPPFLAGS"
-    LDFLAGS="$LDFLAGS $STLPORT_LDFLAGS"
-    LIBS="$LIBS $STLPORT_LIBS"
 fi
-AC_SUBST([STLPORT_SOURCES])
+AC_SUBST([MOZ_ANDROID_LIBSTDCXX])
+AC_SUBST([STLPORT_LIBS])
 
 ])
 
 AC_DEFUN([MOZ_ANDROID_SDK],
 [
 
 MOZ_ARG_WITH_STRING(android-sdk,
 [  --with-android-sdk=DIR
--- a/build/moz.build
+++ b/build/moz.build
@@ -4,17 +4,17 @@
 # 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 CONFIG['OS_ARCH'] not in ('WINNT', 'OS2'):
     DIRS += ['unix']
 elif CONFIG['OS_ARCH'] == 'WINNT':
     DIRS += ['win32']
 
-if CONFIG['STLPORT_SOURCES']:
+if CONFIG['OS_TARGET'] == 'Android' and not CONFIG['MOZ_ANDROID_LIBSTDCXX']:
     DIRS += ['stlport']
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
     TEST_DIRS += [
         'mobile/sutagent/android',
         'mobile/sutagent/android/watcher',
         'mobile/sutagent/android/ffxcp',
         'mobile/sutagent/android/fencp',
--- a/build/stlport/Makefile.in
+++ b/build/stlport/Makefile.in
@@ -12,17 +12,17 @@ include $(DEPTH)/config/autoconf.mk
 MODULES = stlport
 FORCE_STATIC_LIB = 1
 STL_FLAGS =
 
 # Force to build a static library, instead of a fake library, without
 # installing it in dist/lib.
 LIBRARY = $(LIB_PREFIX)$(LIBRARY_NAME).$(LIB_SUFFIX)
 
-VPATH += $(STLPORT_SOURCES)/src
+VPATH += $(srcdir)/src
 
-CSRCS = $(notdir $(wildcard $(STLPORT_SOURCES)/src/*.c))
+CSRCS = $(notdir $(wildcard $(srcdir)/src/*.c))
 
 include $(topsrcdir)/config/rules.mk
 
 DEFINES += -D_GNU_SOURCE
 CXXFLAGS += -fuse-cxa-atexit
-INCLUDES += -I$(STLPORT_SOURCES)/stlport
+INCLUDES += -I$(srcdir)/stlport
--- a/build/stlport/README.mozilla
+++ b/build/stlport/README.mozilla
@@ -1,3 +1,7 @@
 This copy of STLport was taken from the Android NDK r8e.
 Android specific changes are listed in README.android.
 The libs/ directory containing prebuilt static libraries was removed.
+
+The following patches are applied on top:
+- android-mozilla-config.patch: Adjusts Android-specific configuration
+  to the mozilla codebase use of the STL.
new file mode 100644
--- /dev/null
+++ b/build/stlport/android-mozilla-config.patch
@@ -0,0 +1,82 @@
+diff --git a/stlport/stl/config/_android.h b/stlport/stl/config/_android.h
+--- a/stlport/stl/config/_android.h
++++ b/stlport/stl/config/_android.h
+@@ -10,18 +10,18 @@
+ #define _PTHREADS
+ 
+ // Don't have native <cplusplus> headers
+ #define _STLP_HAS_NO_NEW_C_HEADERS 1
+ 
+ // Use unix for streams
+ #define _STLP_USE_UNIX_IO 1
+ 
+-// We do have rtti support now through GAbi++
+-#undef _STLP_NO_RTTI
++// We don't want rtti support
++#define _STLP_NO_RTTI 1
+ 
+ // C library is in the global namespace.
+ #define _STLP_VENDOR_GLOBAL_CSTD 1
+ 
+ // Don't have underlying local support.
+ #undef _STLP_REAL_LOCALE_IMPLEMENTED
+ 
+ // No pthread_spinlock_t in Android
+@@ -32,48 +32,42 @@
+ 
+ // Little endian platform.
+ #define _STLP_LITTLE_ENDIAN 1
+ 
+ // No <exception> headers
+ #undef _STLP_NO_EXCEPTION_HEADER
+ 
+ // No throwing exceptions
+-#undef _STLP_NO_EXCEPTIONS
+-
++#define _STLP_NO_EXCEPTIONS 1
++#define _STLP_NO_EXCEPTION_HEADER 1
+ 
+ // No need to define our own namespace
+ #define _STLP_NO_OWN_NAMESPACE 1
+ 
+ // Use __new_alloc instead of __node_alloc, so we don't need static functions.
+ #define _STLP_USE_SIMPLE_NODE_ALLOC 1
+ 
+ // Don't use extern versions of range errors, so we don't need to
+ // compile as a library.
+ #define _STLP_USE_NO_EXTERN_RANGE_ERRORS 1
+ 
+ // The system math library doesn't have long double variants, e.g
+ // sinl, cosl, etc
+ #define _STLP_NO_VENDOR_MATH_L 1
+ 
+-// Define how to include our native headers.
+-#define _STLP_NATIVE_HEADER(header) <usr/include/header>
+-#define _STLP_NATIVE_C_HEADER(header) <../include/header>
+-#define _STLP_NATIVE_CPP_C_HEADER(header) <../../gabi++/include/header>
+-#define _STLP_NATIVE_CPP_RUNTIME_HEADER(header) <../../gabi++/include/header>
+-#define _STLP_NATIVE_OLD_STREAMS_HEADER(header) <usr/include/header>
+-
+ // Include most of the gcc settings.
+ #include <stl/config/_gcc.h>
+ 
+ // Do not use glibc, Android is missing some things.
+ #undef _STLP_USE_GLIBC
+ 
+ // No exceptions.
+-#undef _STLP_NO_UNCAUGHT_EXCEPT_SUPPORT
+-#undef _STLP_NO_UNEXPECTED_EXCEPT_SUPPORT
++#define _STLP_NO_UNCAUGHT_EXCEPT_SUPPORT 1
++#define _STLP_NO_UNEXPECTED_EXCEPT_SUPPORT 1
+ 
+-#ifndef _ANDROID_NDK_BLAZE_
+-// Android does have include_next but it doesn't work well in our build system.
+-#undef _STLP_HAS_INCLUDE_NEXT
+-#endif
++#define _STLP_HAS_INCLUDE_NEXT 1
++
++// Use operator new instead of stlport own node allocator
++#undef _STLP_USE_NEWALLOC
++#define _STLP_USE_NEWALLOC 1
+ 
+ #endif /* __stl_config__android_h */
--- a/build/stlport/moz.build
+++ b/build/stlport/moz.build
@@ -1,14 +1,12 @@
 # -*- 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/.
 
-CONFIGURE_SUBST_FILES += ['stl/config/_android.h']
-
 CPP_SOURCES += [
-    '$(notdir $(wildcard $(STLPORT_SOURCES)/src/*.cpp))',
+    '$(notdir $(wildcard $(srcdir)/src/*.cpp))',
 ]
 
 LIBRARY_NAME = 'stlport_static'
 
deleted file mode 100644
--- a/build/stlport/stl/config/_android.h.in
+++ /dev/null
@@ -1,31 +0,0 @@
-/* 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_stl_config__android_h
-#define mozilla_stl_config__android_h
-
-#include "@STLPORT_SOURCES@/stlport/stl/config/_android.h"
-
-// No rtti support
-#undef _STLP_NO_RTTI
-#define _STLP_NO_RTTI 1
-
-// No throwing exceptions
-#undef _STLP_NO_EXCEPTIONS
-#define _STLP_NO_EXCEPTIONS 1
-#undef _STLP_NO_EXCEPTION_HEADER
-#define _STLP_NO_EXCEPTION_HEADER 1
-#undef _STLP_NO_UNCAUGHT_EXCEPT_SUPPORT
-#define _STLP_NO_UNCAUGHT_EXCEPT_SUPPORT 1
-
-#undef _STLP_NATIVE_CPP_C_HEADER
-#define _STLP_NATIVE_CPP_C_HEADER(header) <../../system/include/header>
-#undef _STLP_NATIVE_CPP_RUNTIME_HEADER
-#define _STLP_NATIVE_CPP_RUNTIME_HEADER(header) <../../system/include/header>
-
-// Use operator new instead of stlport own node allocator
-#undef _STLP_USE_NEWALLOC
-#define _STLP_USE_NEWALLOC 1
-
-#endif /* mozilla_stl_config__android_h */
--- a/build/stlport/stlport/stl/config/_android.h
+++ b/build/stlport/stlport/stl/config/_android.h
@@ -10,18 +10,18 @@
 #define _PTHREADS
 
 // Don't have native <cplusplus> headers
 #define _STLP_HAS_NO_NEW_C_HEADERS 1
 
 // Use unix for streams
 #define _STLP_USE_UNIX_IO 1
 
-// We do have rtti support now through GAbi++
-#undef _STLP_NO_RTTI
+// We don't want rtti support
+#define _STLP_NO_RTTI 1
 
 // C library is in the global namespace.
 #define _STLP_VENDOR_GLOBAL_CSTD 1
 
 // Don't have underlying local support.
 #undef _STLP_REAL_LOCALE_IMPLEMENTED
 
 // No pthread_spinlock_t in Android
@@ -32,48 +32,42 @@
 
 // Little endian platform.
 #define _STLP_LITTLE_ENDIAN 1
 
 // No <exception> headers
 #undef _STLP_NO_EXCEPTION_HEADER
 
 // No throwing exceptions
-#undef _STLP_NO_EXCEPTIONS
-
+#define _STLP_NO_EXCEPTIONS 1
+#define _STLP_NO_EXCEPTION_HEADER 1
 
 // No need to define our own namespace
 #define _STLP_NO_OWN_NAMESPACE 1
 
 // Use __new_alloc instead of __node_alloc, so we don't need static functions.
 #define _STLP_USE_SIMPLE_NODE_ALLOC 1
 
 // Don't use extern versions of range errors, so we don't need to
 // compile as a library.
 #define _STLP_USE_NO_EXTERN_RANGE_ERRORS 1
 
 // The system math library doesn't have long double variants, e.g
 // sinl, cosl, etc
 #define _STLP_NO_VENDOR_MATH_L 1
 
-// Define how to include our native headers.
-#define _STLP_NATIVE_HEADER(header) <usr/include/header>
-#define _STLP_NATIVE_C_HEADER(header) <../include/header>
-#define _STLP_NATIVE_CPP_C_HEADER(header) <../../gabi++/include/header>
-#define _STLP_NATIVE_CPP_RUNTIME_HEADER(header) <../../gabi++/include/header>
-#define _STLP_NATIVE_OLD_STREAMS_HEADER(header) <usr/include/header>
-
 // Include most of the gcc settings.
 #include <stl/config/_gcc.h>
 
 // Do not use glibc, Android is missing some things.
 #undef _STLP_USE_GLIBC
 
 // No exceptions.
-#undef _STLP_NO_UNCAUGHT_EXCEPT_SUPPORT
-#undef _STLP_NO_UNEXPECTED_EXCEPT_SUPPORT
+#define _STLP_NO_UNCAUGHT_EXCEPT_SUPPORT 1
+#define _STLP_NO_UNEXPECTED_EXCEPT_SUPPORT 1
 
-#ifndef _ANDROID_NDK_BLAZE_
-// Android does have include_next but it doesn't work well in our build system.
-#undef _STLP_HAS_INCLUDE_NEXT
-#endif
+#define _STLP_HAS_INCLUDE_NEXT 1
+
+// Use operator new instead of stlport own node allocator
+#undef _STLP_USE_NEWALLOC
+#define _STLP_USE_NEWALLOC 1
 
 #endif /* __stl_config__android_h */
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -883,17 +883,17 @@ ifdef MSMANIFEST_TOOL
 	fi
 endif	# MSVC with manifest tool
 ifdef MOZ_PROFILE_GENERATE
 # touch it a few seconds into the future to work around FAT's
 # 2-second granularity
 	touch -t `date +%Y%m%d%H%M.%S -d "now+5seconds"` pgo.relink
 endif
 else # !WINNT || GNU_CC
-	$(EXPAND_CCC) -o $@ $(CXXFLAGS) $(PROGOBJS) $(RESFILE) $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(WRAP_LDFLAGS) $(LIBS_DIR) $(LIBS) $(MOZ_GLUE_PROGRAM_LDFLAGS) $(OS_LIBS) $(EXTRA_LIBS) $(BIN_FLAGS) $(EXE_DEF_FILE)
+	$(EXPAND_CCC) -o $@ $(CXXFLAGS) $(PROGOBJS) $(RESFILE) $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(WRAP_LDFLAGS) $(LIBS_DIR) $(LIBS) $(MOZ_GLUE_PROGRAM_LDFLAGS) $(OS_LIBS) $(EXTRA_LIBS) $(BIN_FLAGS) $(EXE_DEF_FILE) $(STLPORT_LIBS)
 	@$(call CHECK_STDCXX,$@)
 endif # WINNT && !GNU_CC
 
 ifdef ENABLE_STRIP
 	$(STRIP) $@
 endif
 ifdef MOZ_POST_PROGRAM_COMMAND
 	$(MOZ_POST_PROGRAM_COMMAND) $@
@@ -937,17 +937,17 @@ ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
 	$(EXPAND_LD) -nologo -out:$@ -pdb:$(LINK_PDBFILE) $< $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(MOZ_GLUE_PROGRAM_LDFLAGS) $(LIBS) $(EXTRA_LIBS) $(OS_LIBS)
 ifdef MSMANIFEST_TOOL
 	@if test -f $@.manifest; then \
 		mt.exe -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;1; \
 		rm -f $@.manifest; \
 	fi
 endif	# MSVC with manifest tool
 else
-	$(EXPAND_CCC) $(CXXFLAGS) -o $@ $< $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(WRAP_LDFLAGS) $(LIBS_DIR) $(LIBS) $(MOZ_GLUE_PROGRAM_LDFLAGS) $(OS_LIBS) $(EXTRA_LIBS) $(BIN_FLAGS)
+	$(EXPAND_CCC) $(CXXFLAGS) -o $@ $< $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(WRAP_LDFLAGS) $(LIBS_DIR) $(LIBS) $(MOZ_GLUE_PROGRAM_LDFLAGS) $(OS_LIBS) $(EXTRA_LIBS) $(BIN_FLAGS) $(STLPORT_LIBS)
 	@$(call CHECK_STDCXX,$@)
 endif # WINNT && !GNU_CC
 
 ifdef ENABLE_STRIP
 	$(STRIP) $@
 endif
 ifdef MOZ_POST_PROGRAM_COMMAND
 	$(MOZ_POST_PROGRAM_COMMAND) $@
@@ -1033,20 +1033,20 @@ endif
 	$(info $(notdir $@))
 ifndef INCREMENTAL_LINKER
 	$(RM) $@
 endif
 ifdef DTRACE_LIB_DEPENDENT
 ifndef XP_MACOSX
 	dtrace -G -C -s $(MOZILLA_DTRACE_SRC) -o  $(DTRACE_PROBE_OBJ) $(shell $(EXPAND_LIBS) $(MOZILLA_PROBE_LIBS))
 endif
-	$(EXPAND_MKSHLIB) $(SHLIB_LDSTARTFILE) $(OBJS) $(LOBJS) $(SUB_SHLOBJS) $(DTRACE_PROBE_OBJ) $(MOZILLA_PROBE_LIBS) $(RESFILE) $(LDFLAGS) $(WRAP_LDFLAGS) $(SHARED_LIBRARY_LIBS) $(EXTRA_DSO_LDOPTS) $(MOZ_GLUE_LDFLAGS) $(OS_LIBS) $(EXTRA_LIBS) $(DEF_FILE) $(SHLIB_LDENDFILE)
+	$(EXPAND_MKSHLIB) $(SHLIB_LDSTARTFILE) $(OBJS) $(LOBJS) $(SUB_SHLOBJS) $(DTRACE_PROBE_OBJ) $(MOZILLA_PROBE_LIBS) $(RESFILE) $(LDFLAGS) $(WRAP_LDFLAGS) $(SHARED_LIBRARY_LIBS) $(EXTRA_DSO_LDOPTS) $(MOZ_GLUE_LDFLAGS) $(OS_LIBS) $(EXTRA_LIBS) $(DEF_FILE) $(SHLIB_LDENDFILE) $(if $(LIB_IS_C_ONLY),,$(STLPORT_LIBS))
 	@$(RM) $(DTRACE_PROBE_OBJ)
 else # ! DTRACE_LIB_DEPENDENT
-	$(EXPAND_MKSHLIB) $(SHLIB_LDSTARTFILE) $(OBJS) $(LOBJS) $(SUB_SHLOBJS) $(RESFILE) $(LDFLAGS) $(WRAP_LDFLAGS) $(SHARED_LIBRARY_LIBS) $(EXTRA_DSO_LDOPTS) $(MOZ_GLUE_LDFLAGS) $(OS_LIBS) $(EXTRA_LIBS) $(DEF_FILE) $(SHLIB_LDENDFILE)
+	$(EXPAND_MKSHLIB) $(SHLIB_LDSTARTFILE) $(OBJS) $(LOBJS) $(SUB_SHLOBJS) $(RESFILE) $(LDFLAGS) $(WRAP_LDFLAGS) $(SHARED_LIBRARY_LIBS) $(EXTRA_DSO_LDOPTS) $(MOZ_GLUE_LDFLAGS) $(OS_LIBS) $(EXTRA_LIBS) $(DEF_FILE) $(SHLIB_LDENDFILE) $(if $(LIB_IS_C_ONLY),,$(STLPORT_LIBS))
 endif # DTRACE_LIB_DEPENDENT
 	@$(call CHECK_STDCXX,$@)
 
 ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
 ifdef MSMANIFEST_TOOL
 ifdef EMBED_MANIFEST_AT
 	@if test -f $@.manifest; then \
 		mt.exe -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;$(EMBED_MANIFEST_AT); \
--- a/configure.in
+++ b/configure.in
@@ -185,18 +185,21 @@ if test -n "$gonkdir" ; then
     CXX="$gonk_toolchain_prefix"g++
     CPP="$gonk_toolchain_prefix"cpp
     LD="$gonk_toolchain_prefix"ld
     AR="$gonk_toolchain_prefix"ar
     RANLIB="$gonk_toolchain_prefix"ranlib
     STRIP="$gonk_toolchain_prefix"strip
     OBJCOPY="$gonk_toolchain_prefix"objcopy
 
-    STLPORT_CPPFLAGS="-I$gonkdir/ndk/sources/cxx-stl/stlport/stlport/ -I$gonkdir/external/stlport/stlport/"
-    STLPORT_LIBS="-lstlport"
+    if ! test -e "$gonkdir/ndk/sources/cxx-stl/stlport/src/iostream.cpp"; then
+        AC_MSG_ERROR([Couldn't find path to stlport sources in the gonk tree])
+    fi
+    STLPORT_CPPFLAGS="-I$_topsrcdir/build/stlport/stlport -I$gonkdir/ndk/sources/cxx-stl/system/include"
+    STLPORT_LIBS="$_objdir/build/stlport/libstlport_static.a -static-libstdc++"
 
     case "$target_cpu" in
     arm)
         ARCH_DIR=arch-arm
         ;;
     i?86)
         ARCH_DIR=arch-x86
         ;;
@@ -217,17 +220,17 @@ if test -n "$gonkdir" ; then
     *)
         AC_MSG_ERROR([Unsupported platform version: $ANDROID_VERSION])
         ;;
     esac
     CPPFLAGS="-DANDROID -isystem $gonkdir/bionic/libc/$ARCH_DIR/include -isystem $gonkdir/bionic/libc/include/ -isystem $gonkdir/bionic/libc/kernel/common -isystem $gonkdir/bionic/libc/kernel/$ARCH_DIR -isystem $gonkdir/bionic/libm/include -I$gonkdir/system -I$gonkdir/system/core/include -isystem $gonkdir/bionic -I$gonkdir/hardware/libhardware/include -I$gonkdir/external/valgrind/fxos-include $GONK_INCLUDES $CPPFLAGS"
     CFLAGS="-mandroid -fno-short-enums -fno-exceptions $CFLAGS"
     CXXFLAGS="-mandroid -fno-short-enums -fno-exceptions -Wno-psabi $CXXFLAGS $STLPORT_CPPFLAGS"
     dnl Add -llog by default, since we use it all over the place.
-    LIBS="$LIBS -llog $STLPORT_LIBS"
+    LIBS="$LIBS -llog"
 
     LDFLAGS="-mandroid -L$gonkdir/out/target/product/$GONK_PRODUCT/obj/lib -Wl,-rpath-link=$gonkdir/out/target/product/$GONK_PRODUCT/obj/lib --sysroot=$gonkdir/out/target/product/$GONK_PRODUCT/obj/ $LDFLAGS"
 
     dnl prevent cross compile section from using these flags as host flags
     if test -z "$HOST_CPPFLAGS" ; then
         HOST_CPPFLAGS=" "
     fi
     if test -z "$HOST_CFLAGS" ; then
@@ -9136,16 +9139,18 @@ HAVE_SYS_MOUNT_H
 
 # FUTURE? Consider moving all these to moz.build files.
 AC_CONFIG_HEADER(
 netwerk/necko-config.h
 xpcom/xpcom-config.h
 xpcom/xpcom-private.h
 )
 
+AC_SUBST(STLPORT_LIBS)
+
 AC_OUTPUT([mozilla-config.h])
 
 # Hack around an Apple bug that affects the egrep that comes with OS X 10.7.
 # "env ARCHPREFERENCE=i386,x86_64 arch egrep" first tries to use the 32-bit
 # Intel part of the egrep fat binary, even on 64-bit systems, and falls back on
 # the 64-bit part if it's not a fat binary, as can happen with MacPorts. We
 # (apparently) only need this hack when egrep's "pattern" is particularly long
 # (as in the following code) and the first egrep on our $PATH is Apple's.  See
--- a/js/src/build/autoconf/android.m4
+++ b/js/src/build/autoconf/android.m4
@@ -239,37 +239,25 @@ if test "$OS_TARGET" = "Android" -a -z "
             elif test -e "$android_ndk/sources/cxx-stl/gnu-libstdc++/libs/$ANDROID_CPU_ARCH/libstdc++.a"; then
                 # android-ndk-r5c, android-ndk-r6, android-ndk-r6b
                 STLPORT_CPPFLAGS="-I$android_ndk/sources/cxx-stl/gnu-libstdc++/include -I$android_ndk/sources/cxx-stl/gnu-libstdc++/libs/$ANDROID_CPU_ARCH/include"
                 STLPORT_LDFLAGS="-L$android_ndk/sources/cxx-stl/gnu-libstdc++/libs/$ANDROID_CPU_ARCH/"
                 STLPORT_LIBS="-lstdc++"
             else
                 AC_MSG_ERROR([Couldn't find path to gnu-libstdc++ in the android ndk])
             fi
-        elif test -e "$android_ndk/sources/cxx-stl/stlport/src/iostream.cpp" ; then
-            if test -e "$android_ndk/sources/cxx-stl/stlport/libs/$ANDROID_CPU_ARCH/libstlport_static.a"; then
-                STLPORT_LDFLAGS="-L$_objdir/build/stlport -L$android_ndk/sources/cxx-stl/stlport/libs/$ANDROID_CPU_ARCH/"
-            elif test -e "$android_ndk/tmp/ndk-digit/build/install/sources/cxx-stl/stlport/libs/$ANDROID_CPU_ARCH/libstlport_static.a"; then
-                STLPORT_LDFLAGS="-L$_objdir/build/stlport -L$android_ndk/tmp/ndk-digit/build/install/sources/cxx-stl/stlport/libs/$ANDROID_CPU_ARCH/"
-            else
-                AC_MSG_ERROR([Couldn't find path to stlport in the android ndk])
-            fi
-            STLPORT_SOURCES="$android_ndk/sources/cxx-stl/stlport"
-            STLPORT_CPPFLAGS="-I$_objdir/build/stlport -I$android_ndk/sources/cxx-stl/stlport/stlport"
-            STLPORT_LIBS="-lstlport_static -static-libstdc++"
-        elif test "$target" != "arm-android-eabi"; then
-            dnl fail if we're not building with NDKr4
-            AC_MSG_ERROR([Couldn't find path to stlport in the android ndk])
+        else
+            STLPORT_CPPFLAGS="-I$_topsrcdir/build/stlport/stlport -I$android_ndk/sources/cxx-stl/system/include"
+            STLPORT_LIBS="$_objdir/build/stlport/libstlport_static.a -static-libstdc++"
         fi
     fi
     CXXFLAGS="$CXXFLAGS $STLPORT_CPPFLAGS"
-    LDFLAGS="$LDFLAGS $STLPORT_LDFLAGS"
-    LIBS="$LIBS $STLPORT_LIBS"
 fi
-AC_SUBST([STLPORT_SOURCES])
+AC_SUBST([MOZ_ANDROID_LIBSTDCXX])
+AC_SUBST([STLPORT_LIBS])
 
 ])
 
 AC_DEFUN([MOZ_ANDROID_SDK],
 [
 
 MOZ_ARG_WITH_STRING(android-sdk,
 [  --with-android-sdk=DIR
--- a/js/src/config/rules.mk
+++ b/js/src/config/rules.mk
@@ -883,17 +883,17 @@ ifdef MSMANIFEST_TOOL
 	fi
 endif	# MSVC with manifest tool
 ifdef MOZ_PROFILE_GENERATE
 # touch it a few seconds into the future to work around FAT's
 # 2-second granularity
 	touch -t `date +%Y%m%d%H%M.%S -d "now+5seconds"` pgo.relink
 endif
 else # !WINNT || GNU_CC
-	$(EXPAND_CCC) -o $@ $(CXXFLAGS) $(PROGOBJS) $(RESFILE) $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(WRAP_LDFLAGS) $(LIBS_DIR) $(LIBS) $(MOZ_GLUE_PROGRAM_LDFLAGS) $(OS_LIBS) $(EXTRA_LIBS) $(BIN_FLAGS) $(EXE_DEF_FILE)
+	$(EXPAND_CCC) -o $@ $(CXXFLAGS) $(PROGOBJS) $(RESFILE) $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(WRAP_LDFLAGS) $(LIBS_DIR) $(LIBS) $(MOZ_GLUE_PROGRAM_LDFLAGS) $(OS_LIBS) $(EXTRA_LIBS) $(BIN_FLAGS) $(EXE_DEF_FILE) $(STLPORT_LIBS)
 	@$(call CHECK_STDCXX,$@)
 endif # WINNT && !GNU_CC
 
 ifdef ENABLE_STRIP
 	$(STRIP) $@
 endif
 ifdef MOZ_POST_PROGRAM_COMMAND
 	$(MOZ_POST_PROGRAM_COMMAND) $@
@@ -937,17 +937,17 @@ ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
 	$(EXPAND_LD) -nologo -out:$@ -pdb:$(LINK_PDBFILE) $< $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(MOZ_GLUE_PROGRAM_LDFLAGS) $(LIBS) $(EXTRA_LIBS) $(OS_LIBS)
 ifdef MSMANIFEST_TOOL
 	@if test -f $@.manifest; then \
 		mt.exe -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;1; \
 		rm -f $@.manifest; \
 	fi
 endif	# MSVC with manifest tool
 else
-	$(EXPAND_CCC) $(CXXFLAGS) -o $@ $< $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(WRAP_LDFLAGS) $(LIBS_DIR) $(LIBS) $(MOZ_GLUE_PROGRAM_LDFLAGS) $(OS_LIBS) $(EXTRA_LIBS) $(BIN_FLAGS)
+	$(EXPAND_CCC) $(CXXFLAGS) -o $@ $< $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(WRAP_LDFLAGS) $(LIBS_DIR) $(LIBS) $(MOZ_GLUE_PROGRAM_LDFLAGS) $(OS_LIBS) $(EXTRA_LIBS) $(BIN_FLAGS) $(STLPORT_LIBS)
 	@$(call CHECK_STDCXX,$@)
 endif # WINNT && !GNU_CC
 
 ifdef ENABLE_STRIP
 	$(STRIP) $@
 endif
 ifdef MOZ_POST_PROGRAM_COMMAND
 	$(MOZ_POST_PROGRAM_COMMAND) $@
@@ -1033,20 +1033,20 @@ endif
 	$(info $(notdir $@))
 ifndef INCREMENTAL_LINKER
 	$(RM) $@
 endif
 ifdef DTRACE_LIB_DEPENDENT
 ifndef XP_MACOSX
 	dtrace -G -C -s $(MOZILLA_DTRACE_SRC) -o  $(DTRACE_PROBE_OBJ) $(shell $(EXPAND_LIBS) $(MOZILLA_PROBE_LIBS))
 endif
-	$(EXPAND_MKSHLIB) $(SHLIB_LDSTARTFILE) $(OBJS) $(LOBJS) $(SUB_SHLOBJS) $(DTRACE_PROBE_OBJ) $(MOZILLA_PROBE_LIBS) $(RESFILE) $(LDFLAGS) $(WRAP_LDFLAGS) $(SHARED_LIBRARY_LIBS) $(EXTRA_DSO_LDOPTS) $(MOZ_GLUE_LDFLAGS) $(OS_LIBS) $(EXTRA_LIBS) $(DEF_FILE) $(SHLIB_LDENDFILE)
+	$(EXPAND_MKSHLIB) $(SHLIB_LDSTARTFILE) $(OBJS) $(LOBJS) $(SUB_SHLOBJS) $(DTRACE_PROBE_OBJ) $(MOZILLA_PROBE_LIBS) $(RESFILE) $(LDFLAGS) $(WRAP_LDFLAGS) $(SHARED_LIBRARY_LIBS) $(EXTRA_DSO_LDOPTS) $(MOZ_GLUE_LDFLAGS) $(OS_LIBS) $(EXTRA_LIBS) $(DEF_FILE) $(SHLIB_LDENDFILE) $(if $(LIB_IS_C_ONLY),,$(STLPORT_LIBS))
 	@$(RM) $(DTRACE_PROBE_OBJ)
 else # ! DTRACE_LIB_DEPENDENT
-	$(EXPAND_MKSHLIB) $(SHLIB_LDSTARTFILE) $(OBJS) $(LOBJS) $(SUB_SHLOBJS) $(RESFILE) $(LDFLAGS) $(WRAP_LDFLAGS) $(SHARED_LIBRARY_LIBS) $(EXTRA_DSO_LDOPTS) $(MOZ_GLUE_LDFLAGS) $(OS_LIBS) $(EXTRA_LIBS) $(DEF_FILE) $(SHLIB_LDENDFILE)
+	$(EXPAND_MKSHLIB) $(SHLIB_LDSTARTFILE) $(OBJS) $(LOBJS) $(SUB_SHLOBJS) $(RESFILE) $(LDFLAGS) $(WRAP_LDFLAGS) $(SHARED_LIBRARY_LIBS) $(EXTRA_DSO_LDOPTS) $(MOZ_GLUE_LDFLAGS) $(OS_LIBS) $(EXTRA_LIBS) $(DEF_FILE) $(SHLIB_LDENDFILE) $(if $(LIB_IS_C_ONLY),,$(STLPORT_LIBS))
 endif # DTRACE_LIB_DEPENDENT
 	@$(call CHECK_STDCXX,$@)
 
 ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
 ifdef MSMANIFEST_TOOL
 ifdef EMBED_MANIFEST_AT
 	@if test -f $@.manifest; then \
 		mt.exe -NOLOGO -MANIFEST $@.manifest -OUTPUTRESOURCE:$@\;$(EMBED_MANIFEST_AT); \