Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Android arm64 compilations #17099

Merged
merged 1 commit into from Jul 8, 2017
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Some generated files are not rendered by default. Learn more.

@@ -80,7 +80,7 @@ fn android_main() {
}

// compiling libandroid_native_app_glue.a
if Command::new(toolchain_path.join("bin").join("arm-linux-androideabi-ar"))
if Command::new(toolchain_path.join("bin").join(format!("{}-ar", toolchain)))
.arg("rcs")
.arg(directory.join("libandroid_native_app_glue.a"))
.arg(directory.join("android_native_app_glue.o"))
@@ -11,4 +11,4 @@ set -o pipefail
source fake-ld.sh

export _GCC_PARAMS="${@}"
call_gcc "arch-arm" "arm-linux-androideabi-4.9" "android-18" "armeabi"
call_gcc "arch-arm" "arm-linux-androideabi" "android-18" "armeabi"
@@ -11,4 +11,4 @@ set -o pipefail
source fake-ld.sh

export _GCC_PARAMS="${@}"
call_gcc "arch-arm64" "aarch64-linux-android-4.9" "android-21" "arm64-v8a"
call_gcc "arch-arm64" "aarch64-linux-android" "android-21" "arm64-v8a"
@@ -11,4 +11,4 @@ set -o pipefail
source fake-ld.sh

export _GCC_PARAMS="${@}"
call_gcc "arch-arm" "arm-linux-androideabi-4.9" "android-18" "armeabi-v7a"
call_gcc "arch-arm" "arm-linux-androideabi" "android-18" "armeabi-v7a"
@@ -18,8 +18,8 @@ call_gcc()
export ANDROID_SYSROOT="${ANDROID_NDK}/platforms/${_ANDROID_PLATFORM}/${_ANDROID_ARCH}"
ANDROID_TOOLCHAIN=""
for host in "linux-x86_64" "linux-x86" "darwin-x86_64" "darwin-x86"; do
if [[ -d "${ANDROID_NDK}/toolchains/${_ANDROID_EABI}/prebuilt/${host}/bin" ]]; then
ANDROID_TOOLCHAIN="${ANDROID_NDK}/toolchains/${_ANDROID_EABI}/prebuilt/${host}/bin"
if [[ -d "${ANDROID_NDK}/toolchains/${_ANDROID_EABI}-4.9/prebuilt/${host}/bin" ]]; then
ANDROID_TOOLCHAIN="${ANDROID_NDK}/toolchains/${_ANDROID_EABI}-4.9/prebuilt/${host}/bin"
break
fi
done
@@ -32,7 +32,7 @@ call_gcc()
echo "sysroot: ${ANDROID_SYSROOT}"
echo "targetdir: ${ANDROID_CXX_LIBS}"

"${ANDROID_TOOLCHAIN}/arm-linux-androideabi-gcc" \
"${ANDROID_TOOLCHAIN}/${_ANDROID_EABI}-gcc" \
--sysroot="${ANDROID_SYSROOT}" -L "${ANDROID_CXX_LIBS}" ${_GCC_PARAMS} -lc++ \
-o "${TARGET_DIR}/libservo.so" -shared && touch "${TARGET_DIR}/servo"
}
@@ -246,6 +246,10 @@ def build(self, target=None, release=False, dev=False, jobs=None,
env["RUSTFLAGS"] = "-C debug_assertions"

if android:
android_platform = self.config["android"]["platform"]
android_toolchain = self.config["android"]["toolchain_name"]
android_arch = "arch-" + self.config["android"]["arch"]

# Build OpenSSL for android
env["OPENSSL_VERSION"] = "1.0.2k"
make_cmd = ["make"]
@@ -258,6 +262,7 @@ def build(self, target=None, release=False, dev=False, jobs=None,
shutil.copy(path.join(self.android_support_dir(), "openssl.makefile"), openssl_dir)
shutil.copy(path.join(self.android_support_dir(), "openssl.sh"), openssl_dir)
env["ANDROID_NDK_ROOT"] = env["ANDROID_NDK"]
env["RUST_TARGET"] = target
with cd(openssl_dir):
status = call(
make_cmd + ["-f", "openssl.makefile"],
@@ -283,10 +288,6 @@ def build(self, target=None, release=False, dev=False, jobs=None,
host_suffix = "x86_64"
host = os_type + "-" + host_suffix

android_platform = self.config["android"]["platform"]
android_toolchain = self.config["android"]["toolchain_name"]
android_arch = "arch-" + self.config["android"]["arch"]

env['PATH'] = path.join(
env['ANDROID_NDK'], "toolchains", android_toolchain, "prebuilt", host, "bin"
) + ':' + env['PATH']
@@ -22,12 +22,48 @@ _ANDROID_NDK="android-ndk-r9"
# list in $ANDROID_NDK_ROOT/toolchains. This value is always used.
# _ANDROID_EABI="x86-4.6"
# _ANDROID_EABI="arm-linux-androideabi-4.6"
_ANDROID_EABI="arm-linux-androideabi-4.9"

# Set _ANDROID_ARCH to the architecture you are building for.
# This value is always used.
# _ANDROID_ARCH=arch-x86
_ANDROID_ARCH=arch-arm


case $RUST_TARGET in
armv7*)
_ANDROID_TARGET="arm-linux-androideabi"
_ANDROID_ARCH=arch-arm
_OPENSSL_MACHINE="armv7"
_OPENSSL_ARCH="arm"
_OPENSSL_CONFIG="android-armv7"
;;
arm*)
_ANDROID_TARGET=$RUST_TARGET
_ANDROID_ARCH=arch-arm
_OPENSSL_MACHINE="arm"
_OPENSSL_ARCH="arm"
_OPENSSL_CONFIG="android-armv7"
;;
aarch64*)
_ANDROID_TARGET=$RUST_TARGET
_ANDROID_ARCH=arch-arm64
_OPENSSL_MACHINE="armv7"
_OPENSSL_ARCH="arm64"
_OPENSSL_CONFIG="linux-generic64 -DB_ENDIAN"
;;
x86*)
_ANDROID_TARGET=$RUST_TARGET
_ANDROID_ARCH=arch-x86
_OPENSSL_MACHINE="x86"
_OPENSSL_ARCH="arm"
_OPENSSL_CONFIG="android-x86"
;;
*)
echo "Error: Invalid TARGET platform: $RUST_TARGET"
;;
esac

_ANDROID_EABI="$_ANDROID_TARGET-4.9"


# Set _ANDROID_API to the API you want to use. You should set it
# to one of: android-14, android-9, android-8, android-14, android-5
@@ -93,17 +129,7 @@ if [ -z "$ANDROID_TOOLCHAIN" ] || [ ! -d "$ANDROID_TOOLCHAIN" ]; then
# exit 1
fi

case $_ANDROID_ARCH in
arch-arm)
ANDROID_TOOLS="arm-linux-androideabi-gcc arm-linux-androideabi-ranlib arm-linux-androideabi-ld"
;;
arch-x86)
ANDROID_TOOLS="i686-linux-android-gcc i686-linux-android-ranlib i686-linux-android-ld"
;;
*)
echo "ERROR ERROR ERROR"
;;
esac
ANDROID_TOOLS="$_ANDROID_TARGET-gcc $_ANDROID_TARGET-ranlib $_ANDROID_TARGET-ld"

for tool in $ANDROID_TOOLS
do
@@ -141,24 +167,17 @@ fi
#####################################################################

# Most of these should be OK (MACHINE, SYSTEM, ARCH). RELEASE is ignored.
export MACHINE=armv7
export MACHINE=$_OPENSSL_MACHINE
export RELEASE=2.6.37
export SYSTEM=android
export ARCH=arm
export CROSS_COMPILE="arm-linux-androideabi-"

if [ "$_ANDROID_ARCH" == "arch-x86" ]; then
export MACHINE=i686
export RELEASE=2.6.37
export SYSTEM=android
export ARCH=x86
export CROSS_COMPILE="i686-linux-android-"
fi
export ARCH=$_OPENSSL_ARCH
export CROSS_COMPILE="$_ANDROID_TARGET-"

# For the Android toolchain
# https://android.googlesource.com/platform/ndk/+/ics-mr0/docs/STANDALONE-TOOLCHAIN.html
export ANDROID_SYSROOT="$ANDROID_NDK_ROOT/platforms/$_ANDROID_API/$_ANDROID_ARCH"
export SYSROOT="$ANDROID_SYSROOT"
export CROSS_SYSROOT="$ANDROID_SYSROOT"
export NDK_SYSROOT="$ANDROID_SYSROOT"
export ANDROID_NDK_SYSROOT="$ANDROID_SYSROOT"
export ANDROID_API="$_ANDROID_API"
@@ -168,6 +187,9 @@ export ANDROID_API="$_ANDROID_API"
export ANDROID_DEV="$ANDROID_NDK_ROOT/platforms/$_ANDROID_API/$_ANDROID_ARCH/usr"
export HOSTCC=gcc

# See https://github.com/cocochpie/android-openssl/blob/master/build-all-arch.sh
xCFLAGS="-DSHARED_EXTENSION=.so -fPIC -DOPENSSL_PIC -DDSO_DLFCN -DHAVE_DLFCN_H -mandroid -I$ANDROID_DEV/include -B$ANDROID_DEV/lib -O3 -fomit-frame-pointer -Wall"

VERBOSE=1
if [ ! -z "$VERBOSE" ] && [ "$VERBOSE" != "0" ]; then
echo "ANDROID_NDK_ROOT: $ANDROID_NDK_ROOT"
@@ -186,6 +208,6 @@ perl -pi -e 's/install: all install_docs install_sw/install: install_docs instal

# The code being built isn't maintained by us, so we redirect stderr to stdout
# so that the warnings don't clutter up buildbot
./config shared -no-ssl2 -no-ssl3 -no-comp -no-hw -no-engine --openssldir=/usr/local/ssl/$ANDROID_API 2>&1
./Configure shared -no-ssl2 -no-ssl3 -no-comp -no-hw -no-engine --openssldir=/usr/local/ssl/$ANDROID_API $_OPENSSL_CONFIG $xCFLAGS 2>&1
make depend 2>&1
make all 2>&1
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.