From 81e80c943b5e35d21c3f5eb9398d14c086f6cd9a Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Tue, 4 Jun 2024 15:03:52 +0200 Subject: [PATCH] Exclude libgcc and libunwind from linked library on Android. As said in [1], unwinder is linked automatically by Clang and shared library must not re-export it. ndk after r23 (we are using r21) should be this. Else we must take care to not re-export it. From [2], we should pass the flags `Wl,--exclude-libs,libgcc.a` and `-Wl,--exclude-libs,libunwind.a` to avoid re-export `_Unwind_Resume` methods. Fix https://github.com/kiwix/kiwix-android/issues/3661 [1] https://android.googlesource.com/platform/ndk/+/master/docs/BuildSystemMaintainers.md#Unwinding [2] https://github.com/android/ndk/issues/889#issuecomment-464334469 --- kiwixbuild/configs/android.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kiwixbuild/configs/android.py b/kiwixbuild/configs/android.py index 93749443..b313ceec 100644 --- a/kiwixbuild/configs/android.py +++ b/kiwixbuild/configs/android.py @@ -45,7 +45,11 @@ def install_path(self): return self.ndk_builder.install_path def get_cross_config(self): - extra_libs = ["-llog"] + extra_libs = [ + "-llog", + "-Wl,--exclude-libs,libgcc.a", + "-Wl,--exclude-libs,libunwind.a", + ] extra_cflags = [ "-I{}".format(include_dir) for include_dir in self.get_include_dirs() ]