android: Drop linker flag for libandroid_support

According to [1], libandroid_support is no longer needed
for API level >= 21. Quoting from the issue:

> Dropping KitKat will have greater benefits than the other API levels
> we've dropped support for over the years (and while not the only reason,
> one motivation for the prior support removals was getting us
> closer to being able to drop 19/20):
>
> 1. libandroid_support will no longer be needed.
>   i. libandroid_support
>      adds to the APK size for all apps. Even if your minSdkVersion is
>      21+, libc++ is built for the lowest API level supported by the NDK,
>      so it includes some pieces of libandroid_support.
> [...]

The LO Android build no longer supports API versions < 21
since:

    commit c2fc2c8c7c63ca4e43bca6e8c9b82c50418422d2
    Author: Michael Weghorn <m.weghorn@posteo.de>
    Date:   Tue Dec 5 09:57:22 2023 +0100

        android: Bump minSdkVersion to 21 (Android 5.0)

The linker flag was otherwise now causing linker errors in an NDK 28
build in a WIP branch including a fix for tdf#162769, using

    --with-distro=LibreOfficeAndroidX86`
    --with-android-sdk=/home/michi/Android/Sdk
    --with-android-ndk=/home/michi/Android/Sdk/ndk/28.0.13004108/

Error:

    Linking /home/michi/development/git/libreoffice-WORKTREE-android/android/obj/local/x86/liblo-native-code.so
    ld.lld: error: unable to find library -landroid_support
    clang++: error: linker command failed with exit code 1 (use -v to see invocation)

The linker flag had already been dropped earlier in

    commit a7f6338875931d8afff55cb39ead8f6600af04cb
    Author: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
    Date:   Wed Aug 7 12:06:25 2019 +0200

        android: support NDK 19 and above (20 as of this commit)

but was restored in

    commit f68a36b62ed327eb67efdfea0ac46645b4d90877
    Date:   Fri Oct 25 07:42:30 2019 +0200

        android: Fix problems with unwinding in the Online-based Android app.

        This partially reverts a7f6338875931d8afff55cb39ead8f6600af04cb.  The
        problem is that with that approach, the problems with unwinding as
        described in 312eeeee42cb4a1e356943e17305555e41afc4ef were plaguing the
        Online-based Android app, leading to mysterious crashes with stack
        traces like:

         #00 pc 0005f2b6  /apex/com.android.runtime/lib/bionic/libc.so (abort+166) (BuildId: 68c87e04526a60689ecb5deb329804a0)
         #01 pc 05caaae7  /data/app/libreoffice.debug-fBEOIUwPHY3_k3eQid159Q==/lib/arm/liblo-native-code.so (BuildId: 1c3d0e6336ddfc3578e1c186944160252a750b8b)
         ...
         #06 pc 07452e43  /data/app/libreoffice.debug-fBEOIUwPHY3_k3eQid159Q==/lib/arm/liblo-native-code.so (BuildId: 1c3d0e6336ddfc3578e1c186944160252a750b8b)
         #07 pc 0005a37c  /apex/com.android.runtime/lib/bionic/libc.so (__restore_rt) (BuildId: 68c87e04526a60689ecb5deb329804a0)
         #08 pc 0005f2b2  /apex/com.android.runtime/lib/bionic/libc.so (abort+162) (BuildId: 68c87e04526a60689ecb5deb329804a0)
         #09 pc 07565d3b  /data/app/libreoffice.debug-fBEOIUwPHY3_k3eQid159Q==/lib/arm/liblo-native-code.so (BuildId: 1c3d0e6336ddfc3578e1c186944160252a750b8b)
         ...
         #11 pc 07565641  /data/app/libreoffice.debug-fBEOIUwPHY3_k3eQid159Q==/lib/arm/liblo-native-code.so (BuildId: 1c3d0e6336ddfc3578e1c186944160252a750b8b)
         #12 pc 0001e394  /apex/com.android.runtime/lib/bionic/libm.so (__gnu_Unwind_RaiseException+108) (BuildId: 0ee3a75927e0da4fa0fe29469ccf8b39)
         #13 pc 0001eee8  /apex/com.android.runtime/lib/bionic/libm.so (_Unwind_RaiseException+20) (BuildId: 0ee3a75927e0da4fa0fe29469ccf8b39)

Hopefully whatever was the problem back then is not
retriggered by dropping `-landroid_support` again
these days.

[1] https://github.com/android/ndk/issues/1751

Change-Id: Icd45abee58e13a2fc77d78d12e823a8045272b4f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181898
Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
This commit is contained in:
Michael Weghorn 2025-02-19 13:44:55 +01:00
parent 347a437dc6
commit 38d3c9abe6

View File

@ -60,7 +60,7 @@ WHOLELIBS = \
$(OBJLOCAL)/liblo-native-code.so : native-code.cxx $(ALL_STATIC_LIBS) $(OBJLOCAL)/liblo-native-code.so : native-code.cxx $(ALL_STATIC_LIBS)
@echo "Linking $@" @echo "Linking $@"
mkdir -p $(OBJLOCAL) mkdir -p $(OBJLOCAL)
$(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 $(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 armeabi-v7a,$(ANDROID_APP_ABI)),-lunwind) $(addprefix -l,$(NSSLIBS)) -lGLESv2 -landroid -ljnigraphics -llog -lz
$(SODEST)/liblo-native-code.so : $(OBJLOCAL)/liblo-native-code.so $(SODEST)/liblo-native-code.so : $(OBJLOCAL)/liblo-native-code.so
mkdir -p $(SODEST) mkdir -p $(SODEST)