From 81843f855445593bddf6b8f4232343bffd2e79c7 Mon Sep 17 00:00:00 2001 From: Robert Chiras Date: Thu, 19 May 2016 15:03:13 +0300 Subject: [PATCH] build: fix cross-compile issue for Android Some tools from icu are building host binaries, which are failing because the current logic is using the target_arch. So, I added _host exports to local build tools in order to use them, when building host binaries. Also, in the commin.gypi file, we need to take care of the current toolset used when generating makefiles. This needs to be done, so that we will use the host_arch when generating makefiles for host and target_arch when generating makefiles for target. Also, removed the unnecessary define '_GLIBCXX_USE_C99_MATH'. Signed-off-by: Robert Chiras --- android-configure | 4 + common.gypi | 143 ++++++++++++++++++++++----------- tools/create_android_makefiles | 4 + 3 files changed, 105 insertions(+), 46 deletions(-) diff --git a/android-configure b/android-configure index 1dc238ebd0c522..87ac21c15e5dfd 100755 --- a/android-configure +++ b/android-configure @@ -50,6 +50,10 @@ export AR=$TOOLCHAIN/bin/$SUFFIX-ar export CC=$TOOLCHAIN/bin/$SUFFIX-gcc export CXX=$TOOLCHAIN/bin/$SUFFIX-g++ export LINK=$TOOLCHAIN/bin/$SUFFIX-g++ +export AR_host=ar +export CC_host=gcc +export CXX_host=g++ +export LINK_host=g++ GYP_DEFINES="target_arch=$ARCH" GYP_DEFINES+=" v8_target_arch=$ARCH" diff --git a/common.gypi b/common.gypi index 8da603d00f618e..05277ec1868e8b 100644 --- a/common.gypi +++ b/common.gypi @@ -242,60 +242,111 @@ ['_type=="static_library"', { 'standalone_static_library': 1, # disable thin archive which needs binutils >= 2.19 }], - ], - 'conditions': [ - [ 'target_arch=="ia32"', { - 'cflags': [ '-m32' ], - 'ldflags': [ '-m32' ], - }], - [ 'target_arch=="x32"', { - 'cflags': [ '-mx32' ], - 'ldflags': [ '-mx32' ], - }], - [ 'target_arch=="x64"', { - 'cflags': [ '-m64' ], - 'ldflags': [ '-m64' ], - }], - [ 'target_arch=="ppc" and OS!="aix"', { - 'cflags': [ '-m32' ], - 'ldflags': [ '-m32' ], - }], - [ 'target_arch=="ppc64" and OS!="aix"', { - 'cflags': [ '-m64', '-mminimal-toc' ], - 'ldflags': [ '-m64' ], - }], - [ 'target_arch=="s390"', { - 'cflags': [ '-m31' ], - 'ldflags': [ '-m31' ], - }], - [ 'target_arch=="s390x"', { - 'cflags': [ '-m64' ], - 'ldflags': [ '-m64' ], - }], - [ 'OS=="solaris"', { - 'cflags': [ '-pthreads' ], - 'ldflags': [ '-pthreads' ], - 'cflags!': [ '-pthread' ], - 'ldflags!': [ '-pthread' ], + ['_toolset=="host"', { + 'conditions': [ + ['host_arch=="ia32"', { + 'cflags': [ '-m32' ], + 'ldflags': [ '-m32' ], + }], + ['host_arch=="x32"', { + 'cflags': [ '-mx32' ], + 'ldflags': [ '-mx32' ], + }], + [ 'host_arch=="x64"', { + 'cflags': [ '-m64' ], + 'ldflags': [ '-m64' ], + }], + [ 'host_arch=="ppc" and OS!="aix"', { + 'cflags': [ '-m32' ], + 'ldflags': [ '-m32' ], + }], + [ 'host_arch=="ppc64" and OS!="aix"', { + 'cflags': [ '-m64', '-mminimal-toc' ], + 'ldflags': [ '-m64' ], + }], + [ 'host_arch=="s390"', { + 'cflags': [ '-m31' ], + 'ldflags': [ '-m31' ], + }], + [ 'host_arch=="s390x"', { + 'cflags': [ '-m64' ], + 'ldflags': [ '-m64' ], + }], + [ 'OS=="solaris"', { + 'cflags': [ '-pthreads' ], + 'ldflags': [ '-pthreads' ], + 'cflags!': [ '-pthread' ], + 'ldflags!': [ '-pthread' ], + }], + [ 'OS=="aix"', { + 'conditions': [ + [ 'host_arch=="ppc"', { + 'ldflags': [ '-Wl,-bmaxdata:0x60000000/dsa' ], + }], + [ 'host_arch=="ppc64"', { + 'cflags': [ '-maix64' ], + 'ldflags': [ '-maix64' ], + }], + ], + 'ldflags!': [ '-rdynamic' ], + }], + ], }], - [ 'OS=="aix"', { + ['_toolset=="target"', { 'conditions': [ - [ 'target_arch=="ppc"', { - 'ldflags': [ '-Wl,-bmaxdata:0x60000000/dsa' ], + ['target_arch=="ia32"', { + 'cflags': [ '-m32' ], + 'ldflags': [ '-m32' ], + }], + ['target_arch=="x32"', { + 'cflags': [ '-mx32' ], + 'ldflags': [ '-mx32' ], + }], + [ 'target_arch=="x64"', { + 'cflags': [ '-m64' ], + 'ldflags': [ '-m64' ], }], - [ 'target_arch=="ppc64"', { - 'cflags': [ '-maix64' ], - 'ldflags': [ '-maix64' ], + [ 'target_arch=="ppc" and OS!="aix"', { + 'cflags': [ '-m32' ], + 'ldflags': [ '-m32' ], + }], + [ 'target_arch=="ppc64" and OS!="aix"', { + 'cflags': [ '-m64', '-mminimal-toc' ], + 'ldflags': [ '-m64' ], + }], + [ 'target_arch=="s390"', { + 'cflags': [ '-m31' ], + 'ldflags': [ '-m31' ], + }], + [ 'target_arch=="s390x"', { + 'cflags': [ '-m64' ], + 'ldflags': [ '-m64' ], + }], + [ 'OS=="solaris"', { + 'cflags': [ '-pthreads' ], + 'ldflags': [ '-pthreads' ], + 'cflags!': [ '-pthread' ], + 'ldflags!': [ '-pthread' ], + }], + [ 'OS=="aix"', { + 'conditions': [ + [ 'target_arch=="ppc"', { + 'ldflags': [ '-Wl,-bmaxdata:0x60000000/dsa' ], + }], + [ 'target_arch=="ppc64"', { + 'cflags': [ '-maix64' ], + 'ldflags': [ '-maix64' ], + }], + ], + 'ldflags!': [ '-rdynamic' ], }], ], - 'ldflags!': [ '-rdynamic' ], + }], + ['OS=="android" and _toolset=="target"', { + 'libraries': [ '-llog' ], }], ], }], - [ 'OS=="android"', { - 'defines': ['_GLIBCXX_USE_C99_MATH'], - 'libraries': [ '-llog' ], - }], ['OS=="mac"', { 'defines': ['_DARWIN_USE_64_BIT_INODE=1'], 'xcode_settings': { diff --git a/tools/create_android_makefiles b/tools/create_android_makefiles index abf2ecf083c307..a4f2a82fcf6b5c 100755 --- a/tools/create_android_makefiles +++ b/tools/create_android_makefiles @@ -21,6 +21,10 @@ fi cd $(dirname $0)/.. +# Export CC_host to gcc, so that the configure script will detect the correct +# host arch +export CC_host=gcc + ./configure \ --without-snapshot \ --openssl-no-asm \