android/Bootstrap/Makefile.shared | 2 - bridges/Library_cpp_uno.mk | 1 config_host.mk.in | 1 configure.ac | 43 ++++++++++------------------- distro-configs/Jenkins/android_common.conf | 2 - external/nss/ExternalProject_nss.mk | 2 - 6 files changed, 18 insertions(+), 33 deletions(-)
New commits: commit 7bdc09ffa44e85544d38131702c4264f006c039d Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Wed Jan 25 08:27:04 2023 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu Feb 16 20:31:54 2023 +0000 android: Require NDK 23 and use default linker lld Using lld instead of hard-coding ld.gold speeds up linking liblo-native-code.so from about 40 seconds to about 10 seconds for my x86 debug Android build with NDK 23.2.8568313. lld was added in NDK 21, made default in NDK 22 [1]. lld doesn't know the `--no-keep-files-mapped` option, so drop that as well. ld.gold had previously been hard-coded in commit c6dadf5035c8e1c31dbd3fccec167bd4a906bf54 Date: Fri Nov 1 17:57:17 2019 +0100 android: Fix linking of liblo-native-code.so on aarch64. , but lld wasn't available yet back then. To make sure that lld is used by default, NDK >= 22 has to be used. In addition, due to a clang bug in NDK 22.1.7171670 [2] ("Misspelled -fnostack-clash-protection"), building for aarch64 Android with that NDK version would fail as follows: clang++: error: unknown argument '-fno-stack-clash-protection'; did you mean '-fnostack-clash-protection'? clang++ version: $ /home/michael.weghorn/Android/Sdk/ndk/22.1.7171670//toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ --version Android (7155654, based on r399163b1) clang version 11.0.5 (https://android.googlesource.com/toolchain/llvm-project 87f1315dfbea7c137aa2e6d362dbb457e388158d) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /home/michael.weghorn/Android/Sdk/ndk/22.1.7171670//toolchains/llvm/prebuilt/linux-x86_64/bin Rather than work around that bug on LO side, require NDK 23.x right away, since that provides a clang where this is fixed. Both, non-debug as well as `--enable-dbgutil` builds with NDK version 23.2.8568313 were successfully tested for all 4 supported architectures and these devices: * aarch64: Fairphone 3 Plus, LineageOS 19 (Android 12), API 31 * arm32: Samsung Galaxy S4 I9505, LineageOS 17.1 (Android 10), API 29 * x86: * AVD: Nexus 4, API 16 * AVD: Pixel 2, API 30 * x86_64: AVD: Pixel 2, API 33 [1] https://developer.android.com/ndk/downloads/revision_history [2] https://bugs.llvm.org/show_bug.cgi?id=47139 Change-Id: I9ea714255faf29d50bb5f8e206f13495637da867 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146119 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/android/Bootstrap/Makefile.shared b/android/Bootstrap/Makefile.shared index f9825b583c05..de7351f5e3f8 100644 --- a/android/Bootstrap/Makefile.shared +++ b/android/Bootstrap/Makefile.shared @@ -60,7 +60,7 @@ WHOLELIBS = \ $(OBJLOCAL)/liblo-native-code.so : native-code.cxx $(ALL_STATIC_LIBS) @echo "Linking $@" mkdir -p $(OBJLOCAL) - $(CXX) -fuse-ld=gold -Wl,--build-id=sha1 -Wl,--gc-sections -Wl,--version-script=../Bootstrap/version.map -Wl,--no-keep-files-mapped -Wl,--no-undefined -DANDROID -DDISABLE_DYNLOADING -shared -Wl,-soname,liblo-native-code.so -o $(OBJLOCAL)/liblo-native-code.so -I$(BUILDDIR)/config_host -I$(SRCDIR)/include native-code.cxx -L$(INSTDIR)/$(LIBO_LIB_FOLDER) $(WHOLELIBS) $(LIBS) -lc++_static -lc++abi $(if $(filter-out arm64-v8a x86_64,$(ANDROID_APP_ABI)),-landroid_support) $(if $(filter armeabi-v7a,$(ANDROID_APP_ABI)),-lunwind) $(addprefix -l,$(NSSLIBS)) -lGLESv2 -landroid -ljnigraphics -llog -lz + $(CXX) -Wl,--build-id=sha1 -Wl,--gc-sections -Wl,--version-script=../Bootstrap/version.map -Wl,--no-undefined -DANDROID -DDISABLE_DYNLOADING -shared -Wl,-soname,liblo-native-code.so -o $(OBJLOCAL)/liblo-native-code.so -I$(BUILDDIR)/config_host -I$(SRCDIR)/include native-code.cxx -L$(INSTDIR)/$(LIBO_LIB_FOLDER) $(WHOLELIBS) $(LIBS) -lc++_static -lc++abi $(if $(filter-out arm64-v8a x86_64,$(ANDROID_APP_ABI)),-landroid_support) $(if $(filter armeabi-v7a,$(ANDROID_APP_ABI)),-lunwind) $(addprefix -l,$(NSSLIBS)) -lGLESv2 -landroid -ljnigraphics -llog -lz $(SODEST)/liblo-native-code.so : $(OBJLOCAL)/liblo-native-code.so mkdir -p $(SODEST) diff --git a/configure.ac b/configure.ac index 8c52306b04ba..07d25c85b781 100644 --- a/configure.ac +++ b/configure.ac @@ -701,16 +701,16 @@ if test -n "$with_android_ndk"; then fi case $ANDROID_NDK_VERSION in r9*|r10*) - AC_MSG_ERROR([Building for Android requires NDK version >= 21.*]) + AC_MSG_ERROR([Building for Android requires NDK version >= 23.*]) ;; - 11.1.*|12.1.*|13.1.*|14.1.*|16.*|17.*|18.*|19.*|20.*) - AC_MSG_ERROR([Building for Android requires NDK version >= 21.*]) + 11.1.*|12.1.*|13.1.*|14.1.*|16.*|17.*|18.*|19.*|20.*|21.*|22.*) + AC_MSG_ERROR([Building for Android requires NDK version >= 23.*]) ;; - 21.*|22.*|23.*) + 23.*) ;; *) - AC_MSG_WARN([Untested Android NDK version $ANDROID_NDK_VERSION, only versions 21.* to 23.* have been used successfully. Proceed at your own risk.]) - add_warning "Untested Android NDK version $ANDROID_NDK_VERSION, only versions 21.* to 23.* have been used successfully. Proceed at your own risk." + AC_MSG_WARN([Untested Android NDK version $ANDROID_NDK_VERSION, only versions 23.* have been used successfully. Proceed at your own risk.]) + add_warning "Untested Android NDK version $ANDROID_NDK_VERSION, only versions 23.* have been used successfully. Proceed at your own risk." ;; esac commit c11701c2126da47af7e7044d83443d3d6a9f58cc Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Wed Jan 25 08:26:51 2023 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu Feb 16 20:31:39 2023 +0000 android: Switch from GNU binutils to support NDK 23.x, require 21.x Relevant announcement from revision history for NDK 23 [1]: > * GNU binutils, excluding the GNU Assembler (GAS), has been removed. GAS > will be removed in the next release. If you are building with > -fno-integrated-as, file bugs if anything is preventing you from > removing that flag. Therefore, switch from uses of GNU binutils to the corresponding LLVM tools instead. NDK 20.x doesn't provide `llvm-ranlib` yet, so bump the minimum version to 21.x. Also drop the previous uses of `ANDROID_BINUTILS_PREBUILT_ROOT`, which appear to no longer be relevant by now. commit 4082a18406c18af7b4fcef7bd501c3679c3be56b Date: Wed Nov 22 23:08:06 2017 +0100 android: use unified headers and llvm-c++ STL (x86) with NDK 16 gnustl (and others) are to be removed in future versions of the ndk also bump gradle and build-tools to current versions along with it arm unfortunately crashes with llvm-c++, so keep with gnustl for now/fix that later that introduced one of those uses mentions issues on ARM, but building and running the app at least on my 32-bit ARM device (Samsung Galaxy S4 I9505, LineageOS 17.1/Android 10) didn't show any issues in a quick test with this change in place. Update the Jenkins config to switch from the now no longer supported NDK 20.1.5948944 to 23.2.8568313 for which building and running the app has been tested on devices for all of the four supported architectures with upcoming change Change-Id I9ea714255faf29d50bb5f8e206f13495637da867 "android: Require NDK 23 and use default linker lld" in place on top, s. that one's commit message for more details. Note however that the NDK version will be further updated to use NDK 25 in upcoming change Change-Id Ib8e65f433ee89ff1bc12432722570bf8f9f7ed85 ("android: Support NDK 24.x and 25.x, use NDK 25 for Jenkins"). [1] https://developer.android.com/ndk/downloads/revision_history [2] https://lists.freedesktop.org/archives/libreoffice/2023-January/089878.html Change-Id: I7645f8025d42f0fa384b5bceb31bb4b1c0a44cb5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146118 Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> Tested-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/bridges/Library_cpp_uno.mk b/bridges/Library_cpp_uno.mk index 56d86c5aaec2..7b10348e83b7 100644 --- a/bridges/Library_cpp_uno.mk +++ b/bridges/Library_cpp_uno.mk @@ -217,7 +217,6 @@ endif # it off. ifeq ($(COM),GCC) $(eval $(call gb_Library_add_cxxflags,gcc3_uno,\ - $(if $(filter armeabi-v7a,$(ANDROID_APP_ABI)),-I$(ANDROID_BINUTILS_PREBUILT_ROOT)/lib/gcc/arm-linux-androideabi/4.9.x/include) \ -fno-omit-frame-pointer \ -fno-strict-aliasing \ -fno-lto \ diff --git a/config_host.mk.in b/config_host.mk.in index 519b472cb2ec..b954ed8b688e 100644 --- a/config_host.mk.in +++ b/config_host.mk.in @@ -19,7 +19,6 @@ export ANDROID_NDK_DIR=@ANDROID_NDK_DIR@ export ANDROID_APP_ABI=@ANDROID_APP_ABI@ export ANDROID_SDK_DIR=@ANDROID_SDK_DIR@ export ANDROID_PACKAGE_NAME=@ANDROID_PACKAGE_NAME@ -export ANDROID_BINUTILS_PREBUILT_ROOT=@ANDROID_BINUTILS_PREBUILT_ROOT@ export ANDROID_GCC_TOOLCHAIN_VERSION=@ANDROID_GCC_TOOLCHAIN_VERSION@ export ANT=@ANT@ export ANT_HOME=@ANT_HOME@ diff --git a/configure.ac b/configure.ac index ad1caa71cd80..8c52306b04ba 100644 --- a/configure.ac +++ b/configure.ac @@ -701,16 +701,16 @@ if test -n "$with_android_ndk"; then fi case $ANDROID_NDK_VERSION in r9*|r10*) - AC_MSG_ERROR([Building for Android is only supported with NDK versions above 16.x*]) + AC_MSG_ERROR([Building for Android requires NDK version >= 21.*]) ;; - 11.1.*|12.1.*|13.1.*|14.1.*) - AC_MSG_ERROR([Building for Android is only supported with NDK versions above 16.x.*]) + 11.1.*|12.1.*|13.1.*|14.1.*|16.*|17.*|18.*|19.*|20.*) + AC_MSG_ERROR([Building for Android requires NDK version >= 21.*]) ;; - 16.*|17.*|18.*|19.*|20.*|21.*|22.*) + 21.*|22.*|23.*) ;; *) - AC_MSG_WARN([Untested Android NDK version $ANDROID_NDK_VERSION, only versions 16.* to 22.* have been used successfully. Proceed at your own risk.]) - add_warning "Untested Android NDK version $ANDROID_NDK_VERSION, only versions 16.* to 22.* have been used successfully. Proceed at your own risk." + AC_MSG_WARN([Untested Android NDK version $ANDROID_NDK_VERSION, only versions 21.* to 23.* have been used successfully. Proceed at your own risk.]) + add_warning "Untested Android NDK version $ANDROID_NDK_VERSION, only versions 21.* to 23.* have been used successfully. Proceed at your own risk." ;; esac @@ -719,36 +719,26 @@ if test -n "$with_android_ndk"; then ANDROID_API_LEVEL="$with_android_api_level" fi - android_cpu=$host_cpu if test $host_cpu = arm; then - android_platform_prefix=arm-linux-androideabi - android_gnu_prefix=$android_platform_prefix LLVM_TRIPLE=armv7a-linux-androideabi ANDROID_APP_ABI=armeabi-v7a ANDROIDCFLAGS="-mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -Wl,--fix-cortex-a8" elif test $host_cpu = aarch64; then - android_platform_prefix=aarch64-linux-android - android_gnu_prefix=$android_platform_prefix - LLVM_TRIPLE=$android_platform_prefix + LLVM_TRIPLE=aarch64-linux-android # minimum android version that supports aarch64 if test "$ANDROID_API_LEVEL" -lt "21" ; then ANDROID_API_LEVEL=21 fi ANDROID_APP_ABI=arm64-v8a elif test $host_cpu = x86_64; then - android_platform_prefix=x86_64-linux-android - android_gnu_prefix=$android_platform_prefix - LLVM_TRIPLE=$android_platform_prefix + LLVM_TRIPLE=x86_64-linux-android # minimum android version that supports x86_64 ANDROID_API_LEVEL=21 ANDROID_APP_ABI=x86_64 else # host_cpu is something like "i386" or "i686" I guess, NDK uses # "x86" in some contexts - android_cpu=x86 - android_platform_prefix=$android_cpu - android_gnu_prefix=i686-linux-android - LLVM_TRIPLE=$android_gnu_prefix + LLVM_TRIPLE=i686-linux-android ANDROID_APP_ABI=x86 fi @@ -782,15 +772,12 @@ if test -n "$with_android_ndk"; then esac android_TOOLCHAIN=$ANDROID_NDK_DIR/toolchains/llvm/prebuilt/$android_HOST_TAG ANDROID_COMPILER_BIN=$android_TOOLCHAIN/bin - dnl TODO: NSS build uses it... - ANDROID_BINUTILS_PREBUILT_ROOT=$ANDROID_NDK_DIR/toolchains/$android_platform_prefix-$ANDROID_GCC_TOOLCHAIN_VERSION/prebuilt/$android_HOST_TAG - AC_SUBST(ANDROID_BINUTILS_PREBUILT_ROOT) - - test -z "$AR" && AR=$ANDROID_COMPILER_BIN/$android_gnu_prefix-ar - test -z "$NM" && NM=$ANDROID_COMPILER_BIN/$android_gnu_prefix-nm - test -z "$OBJDUMP" && OBJDUMP=$ANDROID_COMPILER_BIN/$android_gnu_prefix-objdump - test -z "$RANLIB" && RANLIB=$ANDROID_COMPILER_BIN/$android_gnu_prefix-ranlib - test -z "$STRIP" && STRIP=$ANDROID_COMPILER_BIN/$android_gnu_prefix-strip + + test -z "$AR" && AR=$ANDROID_COMPILER_BIN/llvm-ar + test -z "$NM" && NM=$ANDROID_COMPILER_BIN/llvm-nm + test -z "$OBJDUMP" && OBJDUMP=$ANDROID_COMPILER_BIN/llvm-objdump + test -z "$RANLIB" && RANLIB=$ANDROID_COMPILER_BIN/llvm-ranlib + test -z "$STRIP" && STRIP=$ANDROID_COMPILER_BIN/llvm-strip ANDROIDCFLAGS="$ANDROIDCFLAGS -target ${LLVM_TRIPLE}${ANDROID_API_LEVEL}" ANDROIDCFLAGS="$ANDROIDCFLAGS -no-canonical-prefixes -ffunction-sections -fdata-sections -Qunused-arguments" diff --git a/distro-configs/Jenkins/android_common.conf b/distro-configs/Jenkins/android_common.conf index 9c9edec504da..c5489f36c3e4 100644 --- a/distro-configs/Jenkins/android_common.conf +++ b/distro-configs/Jenkins/android_common.conf @@ -1,5 +1,5 @@ --with-android-sdk=$HOME/Android/Sdk ---with-android-ndk=$HOME/Android/Sdk/ndk/20.1.5948944 +--with-android-ndk=$HOME/Android/Sdk/ndk/23.2.8568313 --with-jdk-home=/etc/alternatives/java_sdk_11 --enable-android-editing CC_FOR_BUILD=/opt/rh/devtoolset-7/root/usr/bin/gcc diff --git a/external/nss/ExternalProject_nss.mk b/external/nss/ExternalProject_nss.mk index ee3c7839fcb6..165591536de1 100644 --- a/external/nss/ExternalProject_nss.mk +++ b/external/nss/ExternalProject_nss.mk @@ -76,7 +76,7 @@ $(call gb_ExternalProject_get_state_target,nss,build): \ COMMA=$(COMMA) \ CC="$(CC)$(if $(filter iOS,$(OS)), -DNSS_STATIC_SOFTOKEN=1 -DNSS_STATIC_FREEBL=1 -DNSS_STATIC_PKCS11=1)$(if $(filter ANDROID,$(OS)), -D_PR_NO_LARGE_FILES=1 -DSQLITE_DISABLE_LFS=1)" CCC="$(CXX)" \ $(if $(CROSS_COMPILING),NSINSTALL="$(if $(filter MACOSX,$(OS_FOR_BUILD)),xcrun python3,$(call gb_ExternalExecutable_get_command,python)) $(SRCDIR)/external/nss/nsinstall.py") \ - $(if $(filter ANDROID,$(OS)),OS_TARGET=Android OS_TARGET_RELEASE=16 ARCHFLAG="" DEFAULT_COMPILER=clang ANDROID_NDK=$(ANDROID_NDK_DIR) ANDROID_TOOLCHAIN_VERSION=$(ANDROID_GCC_TOOLCHAIN_VERSION) ANDROID_PREFIX=$(HOST_PLATFORM) ANDROID_SYSROOT=$(ANDROID_NDK_DIR)/sysroot ANDROID_TOOLCHAIN=$(ANDROID_BINUTILS_PREBUILT_ROOT)) \ + $(if $(filter ANDROID,$(OS)),OS_TARGET=Android OS_TARGET_RELEASE=16 ARCHFLAG="" DEFAULT_COMPILER=clang ANDROID_NDK=$(ANDROID_NDK_DIR) ANDROID_TOOLCHAIN_VERSION=$(ANDROID_GCC_TOOLCHAIN_VERSION) ANDROID_PREFIX=$(HOST_PLATFORM) ANDROID_SYSROOT=$(ANDROID_NDK_DIR)/sysroot) \ NSS_DISABLE_GTESTS=1 \ nss_build_all \ && rm -f $(call gb_UnpackedTarball_get_dir,nss)/dist/out/lib/*.a \