From 5c004922b2fc167c826350085f7d996d93b4398e Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Sat, 30 Aug 2014 00:33:42 +0300 Subject: Start of support for Android on AArch64 The build does not get far before it runs into trouble in the GNU libstdc++ headers, though: android-ndk-r10/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86/include/bits/opt_random.h:33:23: fatal error: x86intrin.h: No such file or directory Change-Id: I9d459c64980091ba8bf5b3d631d47342625f6be9 --- bridges/Library_cpp_uno.mk | 2 +- configure.ac | 45 +++++++++++++++++++-------- distro-configs/LibreOfficeAndroidAarch64.conf | 19 +++++++++++ sal/android/lo-bootstrap.c | 14 +++++---- solenv/gbuild/platform/ANDROID_AARCH64_GCC.mk | 19 +++++++++++ 5 files changed, 79 insertions(+), 20 deletions(-) create mode 100644 distro-configs/LibreOfficeAndroidAarch64.conf create mode 100644 solenv/gbuild/platform/ANDROID_AARCH64_GCC.mk diff --git a/bridges/Library_cpp_uno.mk b/bridges/Library_cpp_uno.mk index 96bd293e1e1c..33a5c00e0c1f 100644 --- a/bridges/Library_cpp_uno.mk +++ b/bridges/Library_cpp_uno.mk @@ -35,7 +35,7 @@ $(call gb_LinkTarget_get_target,$(call gb_Library_get_linktarget,gcc3_uno)) : \ EXTRAOBJECTLISTS += $(call gb_CustomTarget_get_workdir,bridges/source/cpp_uno/gcc3_linux_arm)/armhelper.objectlist endif -else ifeq ($(OS)-$(CPUNAME),LINUX-AARCH64) +else ifneq (,$(filter ANDROID-AARCH64 LINUX-AARCH64,$(OS)-$(CPUNAME))) bridges_SELECTED_BRIDGE := gcc3_linux_aarch64 bridge_exception_objects := abi callvirtualfunction cpp2uno uno2cpp diff --git a/configure.ac b/configure.ac index c4fefead2e8d..c0b565824b82 100644 --- a/configure.ac +++ b/configure.ac @@ -317,6 +317,9 @@ if test -n "$with_android_ndk"; then if test $host_cpu = arm; then android_cpu=arm android_platform_prefix=$android_cpu-linux-androideabi + elif test $host_cpu = aarch64; then + android_cpu=aarch64 + android_platform_prefix=$android_cpu-linux-android elif test $host_cpu = mips; then android_cpu=mips android_platform_prefix=$android_cpu-linux-androideabi @@ -328,7 +331,7 @@ if test -n "$with_android_ndk"; then fi case "$with_android_ndk_toolchain_version" in - 4.6|4.7|4.8) + 4.6|4.7|4.8|4.9) ANDROID_BINUTILS_DIR=$ANDROID_NDK_HOME/toolchains/$android_platform_prefix-$with_android_ndk_toolchain_version ANDROID_COMPILER_DIR=$ANDROID_BINUTILS_DIR ;; @@ -383,8 +386,13 @@ if test -n "$with_android_ndk"; then ;; esac + ANDROID_API_LEVEL=15 if test $host_cpu = arm; then android_gnu_prefix=arm-linux-androideabi + elif test $host_cpu = aarch64; then + android_gnu_prefix=aarch64-linux-android + ANDROID_NDK_TOOLCHAIN_VERSION_SUBDIR="${with_android_ndk_toolchain_version}/" + ANDROID_API_LEVEL=L elif test $host_cpu = mips; then android_gnu_prefix=mipsel-linux-android elif test $ANDROID_NDK_VERSION = r8; then @@ -394,13 +402,7 @@ if test -n "$with_android_ndk"; then android_gnu_prefix=i686-linux-android fi - test -z "$SYSBASE" && export SYSBASE=$ANDROID_NDK_HOME/platforms/android-15/arch-$android_cpu - test -z "$AR" && AR=$ANDROID_BINUTILS_BIN/$android_gnu_prefix-ar - test -z "$NM" && NM=$ANDROID_BINUTILS_BIN/$android_gnu_prefix-nm - test -z "$OBJDUMP" && OBJDUMP=$ANDROID_BINUTILS_BIN/$android_gnu_prefix-objdump - test -z "$RANLIB" && RANLIB=$ANDROID_BINUTILS_BIN/$android_gnu_prefix-ranlib - test -z "$STRIP" && STRIP=$ANDROID_BINUTILS_BIN/$android_gnu_prefix-strip - + ANDROID_ARCH=$android_cpu if test $host_cpu = arm; then ANDROID_APP_ABI=armeabi-v7a if test -n "$ANDROID_USING_CLANG"; then @@ -412,6 +414,10 @@ if test -n "$with_android_ndk"; then fi ANDROIDCFLAGS="$ANDROIDCFLAGS -mthumb" ANDROIDCFLAGS="$ANDROIDCFLAGS -march=armv7-a -mfloat-abi=softfp -mfpu=neon" + ANDROIDCFLAGS="$ANDROIDCFLAGS -Wl,--fix-cortex-a8" + elif test $host_cpu = aarch64; then + ANDROID_APP_ABI=arm64-v8a + ANDROID_ARCH=arm64 elif test $host_cpu = mips; then ANDROID_APP_ABI=mips ANDROIDCFLAGS="" @@ -421,8 +427,7 @@ if test -n "$with_android_ndk"; then fi ANDROIDCFLAGS="$ANDROIDCFLAGS -ffunction-sections -fdata-sections" ANDROIDCFLAGS="$ANDROIDCFLAGS -L$ANDROID_NDK_HOME/sources/cxx-stl/gnu-libstdc++/${ANDROID_NDK_TOOLCHAIN_VERSION_SUBDIR}libs/$ANDROID_APP_ABI" - ANDROIDCFLAGS="$ANDROIDCFLAGS --sysroot $ANDROID_NDK_HOME/platforms/android-15/arch-$android_cpu" - ANDROIDCFLAGS="$ANDROIDCFLAGS -Wl,--fix-cortex-a8" + ANDROIDCFLAGS="$ANDROIDCFLAGS --sysroot $ANDROID_NDK_HOME/platforms/android-${ANDROID_API_LEVEL}/arch-${ANDROID_ARCH}" if test -n "$ANDROID_USING_CLANG"; then ANDROIDCFLAGS="$ANDROIDCFLAGS -Qunused-arguments" @@ -430,11 +435,17 @@ if test -n "$with_android_ndk"; then ANDROIDCFLAGS="$ANDROIDCFLAGS -Wno-psabi" fi + test -z "$SYSBASE" && export SYSBASE=$ANDROID_NDK_HOME/platforms/android-${ANDROID_API_LEVEL}/arch-${ANDROID_ARCH} + test -z "$AR" && AR=$ANDROID_BINUTILS_BIN/$android_gnu_prefix-ar + test -z "$NM" && NM=$ANDROID_BINUTILS_BIN/$android_gnu_prefix-nm + test -z "$OBJDUMP" && OBJDUMP=$ANDROID_BINUTILS_BIN/$android_gnu_prefix-objdump + test -z "$RANLIB" && RANLIB=$ANDROID_BINUTILS_BIN/$android_gnu_prefix-ranlib + test -z "$STRIP" && STRIP=$ANDROID_BINUTILS_BIN/$android_gnu_prefix-strip + # When using the 4.6 or newer toolchain, use the gold linker case "$with_android_ndk_toolchain_version" in 4.[[6789]]*|[[56789]].*|clang*) - # The NDK doesn't have ld.gold for MIPS for some reason - if test "$host_cpu" != mips -a "$ENABLE_LTO" != TRUE; then + if test "$host_cpu" = arm -a "$ENABLE_LTO" != TRUE; then ANDROIDCFLAGS="$ANDROIDCFLAGS -fuse-ld=gold" fi ;; @@ -451,6 +462,8 @@ if test -n "$with_android_ndk"; then ANDROID_NDK_GDBSERVER=$ANDROID_NDK_HOME/toolchains/arm-linux-androideabi-4.4.3/prebuilt/gdbserver elif test -f $ANDROID_NDK_HOME/prebuilt/android-$android_cpu/gdbserver/gdbserver; then ANDROID_NDK_GDBSERVER=$ANDROID_NDK_HOME/prebuilt/android-$android_cpu/gdbserver/gdbserver + elif test $android_cpu = aarch64; then + ANDROID_NDK_GDBSERVER=$ANDROID_NDK_HOME/prebuilt/android-arm64/gdbserver/gdbserver else AC_MSG_ERROR([Can't find gdbserver for your Android target]) fi @@ -751,7 +764,7 @@ linux-android*) fi # Verify that the NDK and SDK options are proper - if test ! -f "$ANDROID_NDK_HOME/platforms/android-15/arch-arm/usr/lib/libc.a"; then + if test ! -f "$ANDROID_NDK_HOME/platforms/android-${ANDROID_API_LEVEL}/arch-${ANDROID_ARCH}/usr/lib/libc.a"; then AC_MSG_ERROR([the --with-android-ndk option does not point to an Android NDK]) fi @@ -4433,6 +4446,12 @@ linux-android*) PLATFORMID=android_arm_eabi OUTPATH=unxandr ;; + aarch64) + CPUNAME=AARCH64 + RTL_ARCH=AARCH64 + PLATFORMID=android_aarch64 + OUTPATH=unxandaarch64 + ;; mips|mipsel) CPUNAME=GODSON # Weird, but maybe that's the LO convention? RTL_ARCH=MIPS_EL diff --git a/distro-configs/LibreOfficeAndroidAarch64.conf b/distro-configs/LibreOfficeAndroidAarch64.conf new file mode 100644 index 000000000000..7fa29bea3eca --- /dev/null +++ b/distro-configs/LibreOfficeAndroidAarch64.conf @@ -0,0 +1,19 @@ +--host=aarch64-linux-android +--disable-cairo-canvas +--disable-cups +--disable-gconf +--disable-gnome-vfs +--disable-gstreamer-0-10 +--disable-gstreamer +--disable-liblangtag +--disable-lockdown +--disable-odk +--disable-opengl +--disable-postgresql-sdbc +--disable-python +--disable-randr +--disable-randr-link +--disable-systray +--without-junit +--without-ppds +--without-helppack-integration diff --git a/sal/android/lo-bootstrap.c b/sal/android/lo-bootstrap.c index d1a7521fb0d0..f7a381ec3801 100644 --- a/sal/android/lo-bootstrap.c +++ b/sal/android/lo-bootstrap.c @@ -395,14 +395,16 @@ Java_org_libreoffice_android_Bootstrap_putenv(JNIEnv* env, jstring string) { const char *s; + char *s_copy; (void) clazz; s = (*env)->GetStringUTFChars(env, string, NULL); + s_copy = strdup(s); - LOGI("putenv(%s)", s); + LOGI("putenv(%s)", s_copy); - putenv(s); + putenv(s_copy); #if 0 { @@ -777,7 +779,7 @@ extract_files(const char *root, strcat(newfilename, dent->d_name); if (stat(newfilename, &st) == 0 && - (gzipped || st.st_size == size)) { + (gzipped || st.st_size == (long long) size)) { free(filename); free(newfilename); continue; @@ -793,13 +795,13 @@ extract_files(const char *root, if (!gzipped) { if (fwrite(apkentry, size, 1, f) != 1) { - LOGE("extract_files: Could not write %d bytes to %s: %s", size, newfilename, strerror(errno)); + LOGE("extract_files: Could not write %lld bytes to %s: %s", (long long) size, newfilename, strerror(errno)); } else { - LOGI("extract_files: Copied %s to %s: %d bytes", filename, newfilename, size); + LOGI("extract_files: Copied %s to %s: %lld bytes", filename, newfilename, (long long) size); } } else { size = extract_gzipped(filename, apkentry, size, f); - LOGI("extract_files: Decompressed %s to %s: %d bytes", filename, newfilename, size); + LOGI("extract_files: Decompressed %s to %s: %lld bytes", filename, newfilename, (long long) size); } fclose(f); diff --git a/solenv/gbuild/platform/ANDROID_AARCH64_GCC.mk b/solenv/gbuild/platform/ANDROID_AARCH64_GCC.mk new file mode 100644 index 000000000000..e8d2c25778c1 --- /dev/null +++ b/solenv/gbuild/platform/ANDROID_AARCH64_GCC.mk @@ -0,0 +1,19 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# 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/. +# + +# please make generic modifications to unxgcc.mk or android.mk +gb_CPUDEFS += -DARM32 +gb_COMPILERDEFAULTOPTFLAGS := -Os +gb_CXXFLAGS += -fno-omit-frame-pointer +gb_CFLAGS += -fno-omit-frame-pointer + +include $(GBUILDDIR)/platform/unxgcc.mk +include $(GBUILDDIR)/platform/android.mk + +# vim: set noet sw=4: -- cgit