android/Bootstrap/Makefile.shared   |    2 +-
 external/nss/ExternalProject_nss.mk |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 83450c00200d56079b8fe87d3eb6fd1b4c598dcc
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Wed Feb 19 14:00:33 2025 +0100
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Thu Feb 20 16:28:40 2025 +0100

    tdf#162769 android nss/nspr: Drop '-D_PR_NO_LARGE_FILES=1'
    
    The `-D_PR_NO_LARGE_FILES=1` configure option causes a
    
        --with-android-ndk=$HOME/Android/Sdk/ndk/26.1.10909125/
        --with-android-sdk=$HOME/Android/Sdk
        --with-distro=LibreOfficeAndroidX86_64
    
    Android build (with NDK 26) to fail like this:
    
        [...]
        checking whether /usr/bin/ccache 
/home/michi/Android/Sdk/ndk/26.1.10909125//toolchains/llvm/prebuilt/linux-x86_64/bin/clang
 -target x86_64-linux-android21 -no-canonical-prefixes -ffunction-sections 
-fdata-sections -Qunused-arguments -glldb -Xclang -debug-info-kind=constructor 
-D_PR_NO_LARGE_FILES=1 -DSQLITE_DISABLE_LFS=1 accepts -pthread... yes
        configure: creating ./config.status
        config.status: creating Makefile
        config.status: creating config/Makefile
        config.status: creating config/autoconf.mk
        config.status: creating config/nsprincl.mk
        config.status: creating config/nsprincl.sh
        config.status: creating config/nspr-config
        config.status: creating config/nspr.pc
        config.status: creating lib/Makefile
        config.status: creating lib/ds/Makefile
        config.status: creating lib/libc/Makefile
        config.status: creating lib/libc/include/Makefile
        config.status: creating lib/libc/src/Makefile
        config.status: creating lib/tests/Makefile
        config.status: creating pkg/Makefile
        config.status: creating pr/Makefile
        config.status: creating pr/include/Makefile
        config.status: creating pr/include/md/Makefile
        config.status: creating pr/include/obsolete/Makefile
        config.status: creating pr/include/private/Makefile
        config.status: creating pr/src/Makefile
        config.status: creating pr/src/io/Makefile
        config.status: creating pr/src/linking/Makefile
        config.status: creating pr/src/malloc/Makefile
        config.status: creating pr/src/md/Makefile
        config.status: creating pr/src/md/unix/Makefile
        config.status: creating pr/src/memory/Makefile
        config.status: creating pr/src/misc/Makefile
        config.status: creating pr/src/threads/Makefile
        config.status: creating pr/tests/Makefile
        config.status: creating pr/tests/dll/Makefile
        config.status: creating pr/src/pthreads/Makefile
        config.status: executing default commands
        ../../../../../pr/src/md/unix/unix.c:2742:27: error: incompatible 
function pointer types assigning to '_MD_Fstat64' (aka 'int (*)(int, struct 
stat64 *)') from 'int (int, struct stat * _Nonnull)' 
[-Wincompatible-function-pointer-types]
            _md_iovector._fstat64 = fstat;
                                  ^ ~~~~~
        ../../../../../pr/src/md/unix/unix.c:2743:26: error: incompatible 
function pointer types assigning to '_MD_Stat64' (aka 'int (*)(const char *, 
struct stat64 *)') from 'int (const char * _Nonnull, struct stat * _Nonnull)' 
[-Wincompatible-function-pointer-types]
            _md_iovector._stat64 = stat;
                                 ^ ~~~~
        ../../../../../pr/src/md/unix/unix.c:3288:61: warning: passing 'int *' 
to parameter of type 'socklen_t *' (aka 'unsigned int *') converts between 
pointers to integer types with different sign [-Wpointer-sign]
            if (getsockopt(osfd, SOL_SOCKET, SO_ERROR, (char*)&err, &optlen) == 
-1) {
                                                                    ^~~~~~~
        
/home/michi/Android/Sdk/ndk/26.1.10909125//toolchains/llvm/prebuilt/linux-x86_64/bin/../sysroot/usr/include/sys/socket.h:304:92:
 note: passing argument to parameter '__value_length' here
        __socketcall int getsockopt(int __fd, int __level, int __option, void* 
__value, socklen_t* __value_length);
                                                                                
                   ^
        1 warning and 2 errors generated.
    
    A similar build issue for Android API levels < 21
    was fixed in NSPR commit [1] ("Bug 1784193 - Cast values when
    setting _md_iovector._{f,}stat64 on Android API < 21.")
    
    Patching nss/nspr to apply a similar change for the
    
        #elif defined(_PR_NO_LARGE_FILES)
    
    code there would fix this issue, too (see initial description
    in tdf#162769).
    
    However, it seems that the `-D_PR_NO_LARGE_FILES=1` configure
    flag for NSS/NSPR, originally added in
    
        commit 4082a18406c18af7b4fcef7bd501c3679c3be56b
        Date:   Wed Nov 22 23:08:06 2017 +0100
    
            android: use unified headers and llvm-c++ STL (x86) with NDK 16
    
    is no longer necessary these days, so drop it.
    
    (Potentially, more of the disabling of large file support
    introduced in the above-mentioned commit is no longer
    needed now or at least when bumping the minSdkVersion further.
    Section [2] on the "32-bit ABI bugs" page has some more details
    on large file support in different Android/NDK
    versions and mentions "by API 24 you have everything including
    <stdio.h>" - while our current `minSdkVersion` is 21.)
    
    Building and running Android Viewer and opening files (including a
    password-protected one, which is where NSS might be involved) worked
    fine in a quick test with these build/device configurations:
    
    * Android x86_64 AVD with API 35 (Android 15.0),
      NDK 26.1.10909125,
     `--with-distro=LibreOfficeAndroidX86_64`
    
    * Samsung Galaxy S4 GT-I9505 (32 bit ARM) LineageOS 17.1
      (based on Android 10), NDK 25.2.9519653,
      `--with-distro=LibreOfficeAndroid`
    
    Tests with a build with this change in place using the latest NDK 
28.0.13004108
    also worked fine on the above 2 devices (x86_64, 32-bit ARM)
    and a Fairphone 3+ (aarch64, LineageOS 21, based on Android 14)
    and an x86 AVD (API 24, i.e. Android 7.0).
    
    [1] https://phabricator.services.mozilla.com/D154336
    [2] 
https://android.googlesource.com/platform/bionic/+/refs/heads/main/docs/32-bit-abi.md#32_bit-and
    
    Change-Id: I759c5213b5f5873fc097a6ca0e0f0f85962e421b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181899
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    Tested-by: Jenkins
    Reviewed-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com>

diff --git a/external/nss/ExternalProject_nss.mk 
b/external/nss/ExternalProject_nss.mk
index e129fba93d49..bf16d7d97e5e 100644
--- a/external/nss/ExternalProject_nss.mk
+++ b/external/nss/ExternalProject_nss.mk
@@ -77,7 +77,7 @@ $(call gb_ExternalProject_get_state_target,nss,build): \
                        CC="$(CC) $(gb_DEBUGINFO_FLAGS) \
                                $(if $(filter 
-fsanitize=undefined,$(CC)),-fno-sanitize=function) \
                                $(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)" \
+                               $(if $(filter ANDROID,$(OS)), 
-DSQLITE_DISABLE_LFS=1)" \
                        CCC="$(CXX) $(gb_DEBUGINFO_FLAGS)" \
                        $(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=$(ANDROID_API_LEVEL) 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) \
commit 38d3c9abe6c3e32b25fa15258d9c121225f37ad7
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Wed Feb 19 13:44:55 2025 +0100
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Thu Feb 20 16:28:33 2025 +0100

    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.wegh...@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+libreoff...@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+libreoff...@googlemail.com>
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    Tested-by: Jenkins

diff --git a/android/Bootstrap/Makefile.shared 
b/android/Bootstrap/Makefile.shared
index 3e4615dd3942..9d0bd80740e6 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) -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
        mkdir -p $(SODEST)

Reply via email to