Bug 681202 - Add Android x86 target. r=glandium
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Thu, 29 Sep 2011 13:39:03 +0900
changeset 77797 c5d8bfe7a0140754df699a25f804b7635d683aec
parent 77796 9ac44888529927b81a97e9d0c03d69b2fceba6d5
child 77798 9672c3995eea2e7552d23359a5a7378e202d2f9e
push id21239
push usermwu@mozilla.com
push dateThu, 29 Sep 2011 08:20:44 +0000
treeherdermozilla-central@e7854b4d29ba [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs681202
milestone10.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 681202 - Add Android x86 target. r=glandium
config/system-headers
configure.in
ipc/chromium/src/base/process_util_linux.cc
js/src/config/system-headers
js/src/configure.in
memory/jemalloc/jemalloc.h
other-licenses/android/APKOpen.cpp
other-licenses/android/APKOpen.h
other-licenses/android/Makefile.in
other-licenses/android/dlfcn.h
other-licenses/android/nsGeckoUtils.cpp
toolkit/mozapps/installer/packager.mk
toolkit/xre/nsSigHandlers.cpp
--- a/config/system-headers
+++ b/config/system-headers
@@ -18,16 +18,17 @@ afxwin.h
 algorithm
 Aliases.h
 all.h
 alloca.h
 alloc.h
 alsa/asoundlib.h
 alsa/pcm.h
 alsa/mixer.h
+android/log.h
 ansi_parms.h
 a.out.h
 app/Cursor.h
 Appearance.h
 AppFileInfo.h
 AppKit.h
 AppleEvents.h
 Application.h
@@ -328,16 +329,17 @@ IOKit/pwr_mgt/IOPMLib.h
 iomanip
 iostream
 iostream.h
 iterator
 jar.h
 JavaControl.h
 JavaEmbedding/JavaControl.h
 JavaVM/jni.h
+jemalloc.h
 JManager.h
 JNIEnvTests.h
 jni.h
 #if MOZ_NATIVE_JPEG==1
 jpeglib.h
 #endif
 JVMManagerTests.h
 Kerberos/Kerberos.h
--- a/configure.in
+++ b/configure.in
@@ -273,16 +273,19 @@ MOZ_ARG_ENABLE_BOOL(android-libstdcxx,
                           use GNU libstdc++ instead of STLPort for NDK >= 5],
     MOZ_ANDROID_LIBSTDCXX=1,
     MOZ_ANDROID_LIBSTDCXX= )
 
 case "$target" in
 arm-linux*-android*|*-linuxandroid*)
     android_tool_prefix="arm-linux-androideabi"
     ;;
+i?86-*android*)
+    android_tool_prefix="i686-android-linux"
+    ;;
 arm-android-eabi)
     android_tool_prefix="arm-eabi"
     ;;
 *)
     android_tool_prefix="$target_os"
     ;;
 esac
 
@@ -364,30 +367,39 @@ case "$target" in
     CC="$android_toolchain"/bin/"$android_tool_prefix"-gcc
     CXX="$android_toolchain"/bin/"$android_tool_prefix"-g++
     CPP="$android_toolchain"/bin/"$android_tool_prefix"-cpp
     LD="$android_toolchain"/bin/"$android_tool_prefix"-ld
     AR="$android_toolchain"/bin/"$android_tool_prefix"-ar
     RANLIB="$android_toolchain"/bin/"$android_tool_prefix"-ranlib
     STRIP="$android_toolchain"/bin/"$android_tool_prefix"-strip
 
+    case "${target_cpu}" in
+    arm*)
+      ANDROID_CPU_ARCH=armeabi-v7a
+      ;;
+    i?86)
+      ANDROID_CPU_ARCH=x86
+      ;;
+    esac
+
     if test -n "$MOZ_ANDROID_LIBSTDCXX" ; then
-       if test ! -e "$android_ndk/sources/cxx-stl/gnu-libstdc++/libs/armeabi-v7a/libstdc++.a" ; then
+       if test ! -e "$android_ndk/sources/cxx-stl/gnu-libstdc++/libs/$ANDROID_CPU_ARCH/libstdc++.a" ; then
           AC_MSG_ERROR([Cannot find path to libstdc++ (NDK version >= 5?)])
        fi
-       STLPORT_CPPFLAGS="-I$android_ndk/sources/cxx-stl/gnu-libstdc++/include -I$android_ndk/sources/cxx-stl/gnu-libstdc++/libs/armeabi-v7a/include -D_GLIBCXX_PERMIT_BACKWARD_HASH"
-       STLPORT_LDFLAGS="-L$android_ndk/sources/cxx-stl/gnu-libstdc++/libs/armeabi-v7a"
+       STLPORT_CPPFLAGS="-I$android_ndk/sources/cxx-stl/gnu-libstdc++/include -I$android_ndk/sources/cxx-stl/gnu-libstdc++/libs/$ANDROID_CPU_ARCH/include -D_GLIBCXX_PERMIT_BACKWARD_HASH"
+       STLPORT_LDFLAGS="-L$android_ndk/sources/cxx-stl/gnu-libstdc++/libs/$ANDROID_CPU_ARCH"
        STLPORT_LIBS="-lstdc++"
-    elif test -e "$android_ndk/sources/cxx-stl/stlport/libs/armeabi-v7a/libstlport_static.a" ; then
+    elif test -e "$android_ndk/sources/cxx-stl/stlport/libs/$ANDROID_CPU_ARCH/libstlport_static.a" ; then
        STLPORT_CPPFLAGS="-I$android_ndk/sources/cxx-stl/stlport/stlport"
-       STLPORT_LDFLAGS="-L$android_ndk/sources/cxx-stl/stlport/libs/armeabi-v7a/"
+       STLPORT_LDFLAGS="-L$android_ndk/sources/cxx-stl/stlport/libs/$ANDROID_CPU_ARCH/"
        STLPORT_LIBS="-lstlport_static"
-    elif  test -e "$android_ndk/tmp/ndk-digit/build/install/sources/cxx-stl/stlport/libs/armeabi-v7a/libstlport_static.a" ; then
+    elif  test -e "$android_ndk/tmp/ndk-digit/build/install/sources/cxx-stl/stlport/libs/$ANDROID_CPU_ARCH/libstlport_static.a" ; then
        STLPORT_CPPFLAGS="-I$android_ndk/sources/cxx-stl/stlport/stlport"
-       STLPORT_LDFLAGS="-L$android_ndk/tmp/ndk-digit/build/install/sources/cxx-stl/stlport/libs/armeabi-v7a"
+       STLPORT_LDFLAGS="-L$android_ndk/tmp/ndk-digit/build/install/sources/cxx-stl/stlport/libs/$ANDROID_CPU_ARCH"
        STLPORT_LIBS="-lstlport_static"
     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])
     fi
 
     CPPFLAGS="-I$android_platform/usr/include $STLPORT_CPPFLAGS $CPPFLAGS"
     CFLAGS="-mandroid -I$android_platform/usr/include -fno-short-enums -fno-exceptions $CFLAGS"
@@ -4382,18 +4394,21 @@ case "$target_os" in
         if test -n "$NS_ENABLE_TSF"; then
             AC_DEFINE(NS_ENABLE_TSF)
         fi
         ;;
 esac
 
 case "${target}" in
     *-android*|*-linuxandroid*)
+        if test "$CPU_ARCH" = "arm" ; then
+          USE_ARM_KUSER=1
+        fi
+
         NSS_DISABLE_DBM=1
-        USE_ARM_KUSER=1
         MOZ_INSTALLER=
         NECKO_WIFI=
         MOZ_THEME_FASTSTRIPE=1
         MOZ_TREE_FREETYPE=1
         MOZ_MEMORY=1
         ;;
 esac
 
--- a/ipc/chromium/src/base/process_util_linux.cc
+++ b/ipc/chromium/src/base/process_util_linux.cc
@@ -15,20 +15,17 @@
 #include "base/debug_util.h"
 #include "base/eintr_wrapper.h"
 #include "base/file_util.h"
 #include "base/logging.h"
 #include "base/string_tokenizer.h"
 #include "base/string_util.h"
 
 #ifdef MOZ_MEMORY_ANDROID
-extern "C" {
-extern void _malloc_prefork(void);
-extern void _malloc_postfork(void);
-}
+#include "jemalloc.h"
 #endif
 
 namespace {
 
 enum ParsingState {
   KEY_NAME,
   KEY_VALUE
 };
--- a/js/src/config/system-headers
+++ b/js/src/config/system-headers
@@ -18,16 +18,17 @@ afxwin.h
 algorithm
 Aliases.h
 all.h
 alloca.h
 alloc.h
 alsa/asoundlib.h
 alsa/pcm.h
 alsa/mixer.h
+android/log.h
 ansi_parms.h
 a.out.h
 app/Cursor.h
 Appearance.h
 AppFileInfo.h
 AppKit.h
 AppleEvents.h
 Application.h
@@ -328,16 +329,17 @@ IOKit/pwr_mgt/IOPMLib.h
 iomanip
 iostream
 iostream.h
 iterator
 jar.h
 JavaControl.h
 JavaEmbedding/JavaControl.h
 JavaVM/jni.h
+jemalloc.h
 JManager.h
 JNIEnvTests.h
 jni.h
 #if MOZ_NATIVE_JPEG==1
 jpeglib.h
 #endif
 JVMManagerTests.h
 Kerberos/Kerberos.h
--- a/js/src/configure.in
+++ b/js/src/configure.in
@@ -268,16 +268,19 @@ MOZ_ARG_ENABLE_BOOL(android-libstdcxx,
 
 case "$target" in
 arm-linux*-android*|*-linuxandroid*)
     android_tool_prefix="arm-linux-androideabi"
     ;;
 arm-android-eabi)
     android_tool_prefix="arm-eabi"
     ;;
+i?86-*android*)
+    android_tool_prefix="i686-android-linux"
+    ;;
 *)
     android_tool_prefix="$target_os"
     ;;
 esac
 
 case "$target" in
 *-android*|*-linuxandroid*)
     if test -z "$android_ndk" ; then
@@ -356,30 +359,39 @@ case "$target" in
     CC="$android_toolchain"/bin/"$android_tool_prefix"-gcc
     CXX="$android_toolchain"/bin/"$android_tool_prefix"-g++
     CPP="$android_toolchain"/bin/"$android_tool_prefix"-cpp
     LD="$android_toolchain"/bin/"$android_tool_prefix"-ld
     AR="$android_toolchain"/bin/"$android_tool_prefix"-ar
     RANLIB="$android_toolchain"/bin/"$android_tool_prefix"-ranlib
     STRIP="$android_toolchain"/bin/"$android_tool_prefix"-strip
 
+    case "${target_cpu}" in
+    arm*)
+      ANDROID_CPU_ARCH=armeabi-v7a
+      ;;
+    i?86)
+      ANDROID_CPU_ARCH=x86
+      ;;
+    esac
+
     if test -n "$MOZ_ANDROID_LIBSTDCXX" ; then
-       if test ! -e "$android_ndk/sources/cxx-stl/gnu-libstdc++/libs/armeabi-v7a/libstdc++.a" ; then
+       if test ! -e "$android_ndk/sources/cxx-stl/gnu-libstdc++/libs/$ANDROID_CPU_ARCH/libstdc++.a" ; then
           AC_MSG_ERROR([Cannot find path to libstdc++ (NDK version >= 5?)])
        fi
-       STLPORT_CPPFLAGS="-I$android_ndk/sources/cxx-stl/gnu-libstdc++/include -I$android_ndk/sources/cxx-stl/gnu-libstdc++/libs/armeabi-v7a/include -D_GLIBCXX_PERMIT_BACKWARD_HASH"
-       STLPORT_LDFLAGS="-L$android_ndk/sources/cxx-stl/gnu-libstdc++/libs/armeabi-v7a"
+       STLPORT_CPPFLAGS="-I$android_ndk/sources/cxx-stl/gnu-libstdc++/include -I$android_ndk/sources/cxx-stl/gnu-libstdc++/libs/$ANDROID_CPU_ARCH/include -D_GLIBCXX_PERMIT_BACKWARD_HASH"
+       STLPORT_LDFLAGS="-L$android_ndk/sources/cxx-stl/gnu-libstdc++/libs/$ANDROID_CPU_ARCH"
        STLPORT_LIBS="-lstdc++"
-    elif test -e "$android_ndk/sources/cxx-stl/stlport/libs/armeabi-v7a/libstlport_static.a" ; then
+    elif test -e "$android_ndk/sources/cxx-stl/stlport/libs/$ANDROID_CPU_ARCH/libstlport_static.a" ; then
        STLPORT_CPPFLAGS="-I$android_ndk/sources/cxx-stl/stlport/stlport"
-       STLPORT_LDFLAGS="-L$android_ndk/sources/cxx-stl/stlport/libs/armeabi-v7a/"
+       STLPORT_LDFLAGS="-L$android_ndk/sources/cxx-stl/stlport/libs/$ANDROID_CPU_ARCH/"
        STLPORT_LIBS="-lstlport_static"
-    elif  test -e "$android_ndk/tmp/ndk-digit/build/install/sources/cxx-stl/stlport/libs/armeabi-v7a/libstlport_static.a" ; then
+    elif  test -e "$android_ndk/tmp/ndk-digit/build/install/sources/cxx-stl/stlport/libs/$ANDROID_CPU_ARCH/libstlport_static.a" ; then
        STLPORT_CPPFLAGS="-I$android_ndk/sources/cxx-stl/stlport/stlport"
-       STLPORT_LDFLAGS="-L$android_ndk/tmp/ndk-digit/build/install/sources/cxx-stl/stlport/libs/armeabi-v7a"
+       STLPORT_LDFLAGS="-L$android_ndk/tmp/ndk-digit/build/install/sources/cxx-stl/stlport/libs/$ANDROID_CPU_ARCH"
        STLPORT_LIBS="-lstlport_static"
     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])
     fi
 
     CPPFLAGS="-I$android_platform/usr/include $STLPORT_CPPFLAGS $CPPFLAGS"
     CFLAGS="-mandroid -I$android_platform/usr/include -fno-short-enums -fno-exceptions $CFLAGS"
@@ -3871,17 +3883,17 @@ dnl ====================================
 
 MOZ_ARG_HEADER(Application)
 
 ENABLE_TESTS=1
 
 USE_ARM_KUSER=
 
 case "${target}" in
-    *-android*|*-linuxandroid*)
+    arm*-android*|arm*-linuxandroid*)
         USE_ARM_KUSER=1
         ;;
 esac
 
 dnl ========================================================
 dnl Use ARM userspace kernel helpers; tell NSPR to enable
 dnl their usage and use them in spidermonkey.
 dnl ========================================================
--- a/memory/jemalloc/jemalloc.h
+++ b/memory/jemalloc/jemalloc.h
@@ -48,16 +48,20 @@ void	*calloc(size_t num, size_t size);
 void	*realloc(void *ptr, size_t size);
 void	free(void *ptr);
 int	posix_memalign(void **memptr, size_t alignment, size_t size);
 #endif /* MOZ_MEMORY_DARWIN, MOZ_MEMORY_LINUX */
 
 /* Android doesn't have posix_memalign */
 #ifdef MOZ_MEMORY_ANDROID
 int	posix_memalign(void **memptr, size_t alignment, size_t size);
+/* Android < 2.3 doesn't have pthread_atfork, so we need to call these
+ * when forking the child process. See bug 680190 */
+void    _malloc_prefork(void);
+void    _malloc_postfork(void);
 #endif
 
 #if defined(MOZ_MEMORY_DARWIN) || defined(MOZ_MEMORY_WINDOWS)
 void	*je_malloc(size_t size);
 void	*je_valloc(size_t size);
 void	*je_calloc(size_t num, size_t size);
 void	*je_realloc(void *ptr, size_t size);
 void	je_free(void *ptr);
--- a/other-licenses/android/APKOpen.cpp
+++ b/other-licenses/android/APKOpen.cpp
@@ -62,18 +62,16 @@
 #include <sys/time.h>
 #include <sys/resource.h>
 
 /* compression methods */
 #define STORE    0
 #define DEFLATE  8
 #define LZMA    14
 
-#define NS_EXPORT __attribute__ ((visibility("default")))
-
 struct local_file_header {
   uint32_t signature;
   uint16_t min_version;
   uint16_t general_flag;
   uint16_t compression;
   uint16_t lastmod_time;
   uint16_t lastmod_date;
   uint32_t crc32;
--- a/other-licenses/android/APKOpen.h
+++ b/other-licenses/android/APKOpen.h
@@ -32,16 +32,20 @@
  * 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 ***** */
 
 #ifndef APKOpen_h
 #define APKOpen_h
 
+#ifndef NS_EXPORT
+#define NS_EXPORT __attribute__ ((visibility("default")))
+#endif
+
 struct mapping_info {
   char * name;
   char * file_id;
   uintptr_t base;
   size_t len;
   size_t offset;
 };
 
@@ -52,11 +56,11 @@ const struct mapping_info * getLibraryMa
 
 struct lib_cache_info {
   char name[MAX_LIB_CACHE_NAME_LEN];
   int fd;
   uint32_t lib_size;
   void* buffer;
 };
 
-const struct lib_cache_info * getLibraryCache();
+NS_EXPORT const struct lib_cache_info * getLibraryCache();
 
 #endif /* APKOpen_h */
--- a/other-licenses/android/Makefile.in
+++ b/other-licenses/android/Makefile.in
@@ -43,23 +43,30 @@ VPATH		= @srcdir@
 include $(DEPTH)/config/autoconf.mk
 
 MODULE           = android
 LIBRARY_NAME     = android
 FORCE_STATIC_LIB = 1
 
 DEFINES += \
   -DLINKER_DEBUG=0 \
-  -DANDROID_ARM_LINKER \
   -DMOZ_LINKER \
   -DLINKER_TEXT_BASE=0xB0001000 \
   -DLINKER_AREA_SIZE=0x01000000 \
   -DANDROID_PACKAGE_NAME='"$(ANDROID_PACKAGE_NAME)"' \
   $(NULL)
 
+ifeq ($(CPU_ARCH),arm)
+DEFINES += -DANDROID_ARM_LINKER
+else
+ifeq ($(CPU_ARCH),x86)
+DEFINES += -DANDROID_X86_LINKER
+endif
+endif
+
 CPPSRCS = \
   nsGeckoUtils.cpp \
   APKOpen.cpp \
   $(NULL)
 
 CSRCS = \
   ba.c \
   debugger.c \
--- a/other-licenses/android/dlfcn.h
+++ b/other-licenses/android/dlfcn.h
@@ -48,22 +48,16 @@ extern void* moz_mapped_dlopen(const cha
                                int fd, void *mem, unsigned int len, unsigned int offset);
 extern void*        __wrap_dlopen(const char*  filename, int flag);
 extern int          __wrap_dlclose(void*  handle);
 extern const char*  __wrap_dlerror(void);
 extern void*        __wrap_dlsym(void*  handle, const char*  symbol);
 extern int          __wrap_dladdr(void* addr, Dl_info *info);
 #pragma GCC visibility pop
 
-extern void*        dlopen(const char*  filename, int flag);
-extern int          dlclose(void*  handle);
-extern const char*  dlerror(void);
-extern void*        dlsym(void*  handle, const char*  symbol);
-extern int          dladdr(void* addr, Dl_info *info);
-
 enum {
   RTLD_NOW  = 0,
   RTLD_LAZY = 1,
 
   RTLD_LOCAL  = 0,
   RTLD_GLOBAL = 2,
 };
 
--- a/other-licenses/android/nsGeckoUtils.cpp
+++ b/other-licenses/android/nsGeckoUtils.cpp
@@ -33,20 +33,17 @@
  * 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 <jni.h>
 #include <stdlib.h>
 
-extern "C" {
-  void JNICALL Java_org_mozilla_gecko_GeckoAppShell_putenv(JNIEnv *jenv, jclass, jstring map);
-}
-
+extern "C"
 __attribute__ ((visibility("default")))
 void JNICALL
 Java_org_mozilla_gecko_GeckoAppShell_putenv(JNIEnv *jenv, jclass, jstring map)
 {
     const char* str;
     // XXX: java doesn't give us true UTF8, we should figure out something 
     // better to do here
     str = jenv->GetStringUTFChars(map, NULL);
--- a/toolkit/mozapps/installer/packager.mk
+++ b/toolkit/mozapps/installer/packager.mk
@@ -300,21 +300,25 @@ NON_DIST_FILES = \
   $(NULL)
 
 UPLOAD_EXTRA_FILES += gecko-unsigned-unaligned.apk
 
 include $(topsrcdir)/ipc/app/defs.mk
 
 DIST_FILES += $(MOZ_CHILD_PROCESS_NAME)
 
+ifeq ($(CPU_ARCH),x86)
+ABI_DIR = x86
+else
 ifdef MOZ_THUMB2
 ABI_DIR = armeabi-v7a
 else
 ABI_DIR = armeabi
 endif
+endif
 
 PKG_SUFFIX      = .apk
 INNER_MAKE_PACKAGE	= \
   make -C ../embedding/android gecko.ap_ && \
   cp ../embedding/android/gecko.ap_ $(_ABS_DIST) && \
   ( cd $(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH) && \
     rm -rf lib && \
     mkdir -p lib/$(ABI_DIR) && \
--- a/toolkit/xre/nsSigHandlers.cpp
+++ b/toolkit/xre/nsSigHandlers.cpp
@@ -55,17 +55,17 @@
 #include "nsDebug.h"
 #include "nsXULAppAPI.h"
 
 #if defined(LINUX)
 #include <sys/time.h>
 #include <sys/resource.h>
 #include <unistd.h>
 #include <stdlib.h> // atoi
-#ifndef __arm__ // no arm impl
+#ifndef ANDROID // no Android impl
 #  include <ucontext.h>
 #endif
 #endif
 
 #if defined(SOLARIS)
 #include <sys/resource.h>
 #include <ucontext.h>
 #endif
@@ -185,17 +185,17 @@ static void fpehandler(int signum, sigin
   status->__invalid = status->__denorm = status->__zdiv = status->__ovrfl = status->__undfl =
     status->__precis = status->__stkflt = status->__errsumm = 0;
 
   __uint32_t *mxcsr = &uc->uc_mcontext->__fs.__fpu_mxcsr;
   *mxcsr |= SSE_EXCEPTION_MASK; /* disable all SSE exceptions */
   *mxcsr &= ~SSE_STATUS_FLAGS; /* clear all pending SSE exceptions */
 #endif
 #endif
-#if defined(LINUX) && !defined(__arm__)
+#if defined(LINUX) && !defined(ANDROID)
   ucontext_t *uc = (ucontext_t *)context;
 
 #if defined(__i386__)
   /*
    * It seems that we have no access to mxcsr on Linux. libc
    * seems to be translating cw/sw to mxcsr.
    */
   unsigned long int *cw = &uc->uc_mcontext.fpregs->cw;