Bug 807423 - Support use of GNU libstdc++ on Android. r=ted
authorSurith Thekkiam <folecr@gmail.com>
Tue, 06 Nov 2012 09:41:16 -0800
changeset 113451 7f785ec19024ddb5cbb760da3b5c602ab657ef76
parent 113450 5bdf8bbcd02f481ea04fef10e255142b0c202ec1
child 113452 c794e4ef27fc9ed4ba45aa9cc3a0d13afa582895
push id18158
push userryanvm@gmail.com
push dateFri, 16 Nov 2012 01:34:59 +0000
treeherdermozilla-inbound@90c362bfd156 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted
bugs807423
milestone19.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 807423 - Support use of GNU libstdc++ on Android. r=ted * For android-ndk versions r7, r7b, r8, r8b * std::ifstream broken in earlier versions of ndk * ... used in jscntxt.cpp by ComputeIsJITBroken() * Default gnu_compiler_version is 4.4.3 * If android_toolchain is not set, attempt to infer it from gnu_compiler_version. * Copy changes from js/src/build/autoconf/android.m4 to build/autoconf/android.m4
build/autoconf/android.m4
js/src/build/autoconf/android.m4
--- a/build/autoconf/android.m4
+++ b/build/autoconf/android.m4
@@ -10,16 +10,30 @@ MOZ_ARG_WITH_STRING(android-ndk,
                           location where the Android NDK can be found],
     android_ndk=$withval)
 
 MOZ_ARG_WITH_STRING(android-toolchain,
 [  --with-android-toolchain=DIR
                           location of the android toolchain],
     android_toolchain=$withval)
 
+dnl default gnu compiler version is 4.4.3
+android_gnu_compiler_version=4.4.3
+
+MOZ_ARG_WITH_STRING(android-gnu-compiler-version,
+[  --with-android-gnu-compiler-version=VER
+                          gnu compiler version to use, default 4.4.3],
+    android_gnu_compiler_version=$withval)
+
+MOZ_ARG_ENABLE_BOOL(android-libstdcxx,
+[  --enable-android-libstdcxx
+                          use GNU libstdc++ instead of STLPort],
+    MOZ_ANDROID_LIBSTDCXX=1,
+    MOZ_ANDROID_LIBSTDCXX= )
+
 dnl default android_version is different per target cpu
 case "$target_cpu" in
 arm)
     android_version=5
     ;;
 i?86|mipsel)
     android_version=9
     ;;
@@ -58,23 +72,23 @@ case "$target" in
 
     if test -z "$android_toolchain" ; then
         AC_MSG_CHECKING([for android toolchain directory])
 
         kernel_name=`uname -s | tr "[[:upper:]]" "[[:lower:]]"`
 
         case "$target_cpu" in
         arm)
-            target_name=arm-linux-androideabi-4.4.3
+            target_name=arm-linux-androideabi-$android_gnu_compiler_version
             ;;
         i?86)
-            target_name=x86-4.4.3
+            target_name=x86-$android_gnu_compiler_version
             ;;
         mipsel)
-            target_name=mipsel-linux-android-4.4.3
+            target_name=mipsel-linux-android-$android_gnu_compiler_version
             ;;
         esac
         android_toolchain="$android_ndk"/toolchains/$target_name/prebuilt/$kernel_name-x86
 
         if test -d "$android_toolchain" ; then
             AC_MSG_RESULT([$android_toolchain])
         else
             AC_MSG_ERROR([not found. You have to specify --with-android-toolchain=/path/to/ndk/toolchain.])
@@ -176,17 +190,36 @@ if test "$OS_TARGET" = "Android" -a -z "
     mips-*) # When target_cpu is mipsel, CPU_ARCH is mips
         ANDROID_CPU_ARCH=mips
         ;;
     esac
 
     AC_SUBST(ANDROID_CPU_ARCH)
 
     if test -z "$STLPORT_CPPFLAGS$STLPORT_LDFLAGS$STLPORT_LIBS"; then
-        if test -e "$android_ndk/sources/cxx-stl/stlport/src/iostream.cpp" ; then
+        if test -n "$MOZ_ANDROID_LIBSTDCXX" ; then
+            if test -e "$android_ndk/sources/cxx-stl/gnu-libstdc++/$android_gnu_compiler_version/libs/$ANDROID_CPU_ARCH/libgnustl_static.a"; then
+                # android-ndk-r8b
+                STLPORT_LDFLAGS="-L$android_ndk/sources/cxx-stl/gnu-libstdc++/$android_gnu_compiler_version/libs/$ANDROID_CPU_ARCH/"
+                STLPORT_CPPFLAGS="-I$android_ndk/sources/cxx-stl/gnu-libstdc++/$android_gnu_compiler_version/include -I$android_ndk/sources/cxx-stl/gnu-libstdc++/$android_gnu_compiler_version/libs/$ANDROID_CPU_ARCH/include"
+                STLPORT_LIBS="-lgnustl_static"
+            elif test -e "$android_ndk/sources/cxx-stl/gnu-libstdc++/libs/$ANDROID_CPU_ARCH/libgnustl_static.a"; then
+                # android-ndk-r7, android-ndk-r7b, android-ndk-r8
+                STLPORT_LDFLAGS="-L$android_ndk/sources/cxx-stl/gnu-libstdc++/libs/$ANDROID_CPU_ARCH/"
+                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_LIBS="-lgnustl_static"
+            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"
--- a/js/src/build/autoconf/android.m4
+++ b/js/src/build/autoconf/android.m4
@@ -10,16 +10,30 @@ MOZ_ARG_WITH_STRING(android-ndk,
                           location where the Android NDK can be found],
     android_ndk=$withval)
 
 MOZ_ARG_WITH_STRING(android-toolchain,
 [  --with-android-toolchain=DIR
                           location of the android toolchain],
     android_toolchain=$withval)
 
+dnl default gnu compiler version is 4.4.3
+android_gnu_compiler_version=4.4.3
+
+MOZ_ARG_WITH_STRING(android-gnu-compiler-version,
+[  --with-android-gnu-compiler-version=VER
+                          gnu compiler version to use, default 4.4.3],
+    android_gnu_compiler_version=$withval)
+
+MOZ_ARG_ENABLE_BOOL(android-libstdcxx,
+[  --enable-android-libstdcxx
+                          use GNU libstdc++ instead of STLPort],
+    MOZ_ANDROID_LIBSTDCXX=1,
+    MOZ_ANDROID_LIBSTDCXX= )
+
 dnl default android_version is different per target cpu
 case "$target_cpu" in
 arm)
     android_version=5
     ;;
 i?86|mipsel)
     android_version=9
     ;;
@@ -58,23 +72,23 @@ case "$target" in
 
     if test -z "$android_toolchain" ; then
         AC_MSG_CHECKING([for android toolchain directory])
 
         kernel_name=`uname -s | tr "[[:upper:]]" "[[:lower:]]"`
 
         case "$target_cpu" in
         arm)
-            target_name=arm-linux-androideabi-4.4.3
+            target_name=arm-linux-androideabi-$android_gnu_compiler_version
             ;;
         i?86)
-            target_name=x86-4.4.3
+            target_name=x86-$android_gnu_compiler_version
             ;;
         mipsel)
-            target_name=mipsel-linux-android-4.4.3
+            target_name=mipsel-linux-android-$android_gnu_compiler_version
             ;;
         esac
         android_toolchain="$android_ndk"/toolchains/$target_name/prebuilt/$kernel_name-x86
 
         if test -d "$android_toolchain" ; then
             AC_MSG_RESULT([$android_toolchain])
         else
             AC_MSG_ERROR([not found. You have to specify --with-android-toolchain=/path/to/ndk/toolchain.])
@@ -176,17 +190,36 @@ if test "$OS_TARGET" = "Android" -a -z "
     mips-*) # When target_cpu is mipsel, CPU_ARCH is mips
         ANDROID_CPU_ARCH=mips
         ;;
     esac
 
     AC_SUBST(ANDROID_CPU_ARCH)
 
     if test -z "$STLPORT_CPPFLAGS$STLPORT_LDFLAGS$STLPORT_LIBS"; then
-        if test -e "$android_ndk/sources/cxx-stl/stlport/src/iostream.cpp" ; then
+        if test -n "$MOZ_ANDROID_LIBSTDCXX" ; then
+            if test -e "$android_ndk/sources/cxx-stl/gnu-libstdc++/$android_gnu_compiler_version/libs/$ANDROID_CPU_ARCH/libgnustl_static.a"; then
+                # android-ndk-r8b
+                STLPORT_LDFLAGS="-L$android_ndk/sources/cxx-stl/gnu-libstdc++/$android_gnu_compiler_version/libs/$ANDROID_CPU_ARCH/"
+                STLPORT_CPPFLAGS="-I$android_ndk/sources/cxx-stl/gnu-libstdc++/$android_gnu_compiler_version/include -I$android_ndk/sources/cxx-stl/gnu-libstdc++/$android_gnu_compiler_version/libs/$ANDROID_CPU_ARCH/include"
+                STLPORT_LIBS="-lgnustl_static"
+            elif test -e "$android_ndk/sources/cxx-stl/gnu-libstdc++/libs/$ANDROID_CPU_ARCH/libgnustl_static.a"; then
+                # android-ndk-r7, android-ndk-r7b, android-ndk-r8
+                STLPORT_LDFLAGS="-L$android_ndk/sources/cxx-stl/gnu-libstdc++/libs/$ANDROID_CPU_ARCH/"
+                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_LIBS="-lgnustl_static"
+            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"