diff options
authorStephan Bergmann <>2018-12-11 16:37:43 +0100
committerJan Holesovsky <>2019-06-05 22:19:28 +0200
commitaa448403296e35a57a17a50c9a077f63dafceb5b (patch)
parent015967e5d199ce33e6d07cc5b015a0cdab89f3fd (diff)
Switch Android armeabi-v7a to libc++/libc++abi/libunwind too
It had been left out in 4082a18406c18af7b4fcef7bd501c3679c3be56b "android: use unified headers and llvm-c++ STL (x86) with NDK 16" because "arm unfortunately crashes with llvm-c++, so keep with gnustl for now/fix that later". Making armeabi-v7a work with libc++ etc. required a number of changes, listed below, in this commit and in preceding ones. At least 32-bit x86 already worked with libc++ etc. prior to these changes in view mode, though it crashed in the experimental editing mode (enabled with strippedUIEditing in android/soruce/Makefile) as soon as one types in something, But it is not entirely clear to me why 32-bit x86 view mode didn't also fail similar to how I saw armeabi-v7a fail. (On 32-bit x86, these changes appear to neither improve nor worsen the current state, view mode still appears to work fine while editing still crashes upon typing anything. With these changes, editing mode on armeabi-v7a appears to work fine. But I tested armeabi-v7a only with a real device and 32-bit x86 only with an emulator, in case that might make a difference.) * Preceding <> "Move NSSLIBS to a more sensible place on the linker command line" plus this change's addition of -lunwind to the linker command line make sure that uses _Unwind_* functions from libunwind.a, instead of erroneously picking up the ones from libgcc.a that happen to be included in NSSLIB's nspr4 (-lgcc is automatically added to the end of the linker command line by the invoking compiler, that's how libgcc.a's _Unwind_* end up in NSSLIB's nspr4; it is neither clear to me why NSSLIB's nspr4, being a pure C library, uses _Unwind_* functions, nor why exception handling in fails when using _Unwind_* functions from libgcc.a instead of from libunwind on armeabi-v7a, nor why that would work on 32-bit x86, but that's what I observed: ModuleManager::identify (framework/source/services/modulemanager.cxx) throws a css::lang::IllegalArgumentException, which calls __cxa_throw -> _Unwind_RaiseException, which ultimately lead to odd misbehavior and std::abort during stack unwinding when using _Unwind_RaiseException from libgcc.a instead of from libunwind). (There is no libunwind.* in android-ndk-r16b for 32-bit x86 at least, so is presumably using _Unwind_* functions from libgcc.a. It doesn't appear to make a difference if it indirectly uses those _Unwind_* functions from NSSLIB's nspr4, or directly from libgcc.a included in if the $(if $(filter armeabi-v7a,$(ANDROID_APP_ABI)),-lunwind) had a ",-lgcc" else branch.) * Preceding <> "Export RTTI symbols from, for binary UNO bridge" makes sure that excpetions thrown from the binary UNO bridge can be caught by compiled catch clauses. Not sure why the corresponding state of bridges/source/cpp_uno/gcc3_linux_intel shouldn't have run into the same issue. * Preceding <> "Adapt gcc3_linux_arm __cxa_exception to NDK 18 libc++abi" makes sure that our version of __cxa_exception matches the version from libc++abi. This is clearly not relevant for 32-bit x86. (The comment there android-ndk-r18b, but the additional member is already present in android-ndk-r16b/sources/cxx-stl/llvm-libc++abi/src/cxa_exception.hpp, too.) The remainder of this change just drops old armeabi-v7a--specific workarounds that are no longer needed/no longer work. Change-Id: Ief4c2d562c5032abe6c3b94ca3b3394be6fcd4d3 Reviewed-on: Tested-by: Stephan Bergmann <> Reviewed-by: Stephan Bergmann <>
6 files changed, 1 insertions, 56 deletions
diff --git a/android/Bootstrap/Makefile.shared b/android/Bootstrap/Makefile.shared
index 2e1c8c163bd2..f77679853d39 100644
--- a/android/Bootstrap/Makefile.shared
+++ b/android/Bootstrap/Makefile.shared
@@ -59,7 +59,7 @@ WHOLELIBS = \
$(OBJLOCAL)/ : native-code.cxx $(ALL_STATIC_LIBS)
@echo "Linking $@"
mkdir -p $(OBJLOCAL)
- $(CXX) -Wl,--build-id=sha1 -Wl,--gc-sections -Wl,--version-script=../Bootstrap/ -Wl,--no-keep-files-mapped -Wl,--no-undefined -DANDROID -DDISABLE_DYNLOADING -shared -o $(OBJLOCAL)/ -I$(BUILDDIR)/config_host -I$(SRCDIR)/include native-code.cxx -L$(INSTDIR)/$(LIBO_LIB_FOLDER) $(WHOLELIBS) $(LIBS) $(if $(filter armeabi-v7a,$(ANDROID_APP_ABI)),-lgnustl_static,-lc++_static -lc++abi -landroid_support) $(addprefix -l,$(NSSLIBS)) -lGLESv2 -landroid -ljnigraphics -llog -lz
+ $(CXX) -Wl,--build-id=sha1 -Wl,--gc-sections -Wl,--version-script=../Bootstrap/ -Wl,--no-keep-files-mapped -Wl,--no-undefined -DANDROID -DDISABLE_DYNLOADING -shared -o $(OBJLOCAL)/ -I$(BUILDDIR)/config_host -I$(SRCDIR)/include native-code.cxx -L$(INSTDIR)/$(LIBO_LIB_FOLDER) $(WHOLELIBS) $(LIBS) -lc++_static -lc++abi -landroid_support $(if $(filter armeabi-v7a,$(ANDROID_APP_ABI)),-lunwind) $(addprefix -l,$(NSSLIBS)) -lGLESv2 -landroid -ljnigraphics -llog -lz
mkdir -p $(SODEST)
diff --git a/ b/
index faaed1bbe8b9..6687a8d54ff3 100644
--- a/
+++ b/
@@ -486,22 +486,14 @@ if test -n "$with_android_ndk"; then
ANDROIDCFLAGS="$ANDROIDCFLAGS -isystem $ANDROID_NDK_HOME/sysroot/usr/include/$android_gnu_prefix"
ANDROIDCFLAGS="$ANDROIDCFLAGS --sysroot=$SYSBASE -ffunction-sections -fdata-sections -Qunused-arguments"
- if test "$ANDROID_APP_ABI" = "armeabi-v7a"; then
- else
- fi
if test "$ENABLE_LTO" = TRUE; then
# -flto comes from, too, but we need to make sure it gets passed as part of
# $CC and $CXX when building external libraries
ANDROIDCFLAGS="$ANDROIDCFLAGS -flto -fuse-linker-plugin -O2"
- if test "$ANDROID_APP_ABI" = "armeabi-v7a"; then
- ANDROIDCXXFLAGS="$ANDROIDCFLAGS -I$ANDROID_NDK_HOME/sources/cxx-stl/gnu-libstdc++/4.9/include -I$ANDROID_NDK_HOME/sources/cxx-stl/gnu-libstdc++/4.9/libs/$ANDROID_APP_ABI/include -std=c++11"
- else
ANDROIDCXXFLAGS="$ANDROIDCFLAGS -I$ANDROID_NDK_HOME/sources/cxx-stl/llvm-libc++/include -I$ANDROID_NDK_HOME/sources/cxx-stl/llvm-libc++abi/include -I$ANDROID_NDK_HOME/sources/android/support/include -std=c++11"
- fi
if test -z "$CC"; then
diff --git a/external/liborcus/ b/external/liborcus/
index aa831e3aa7db..a21401011bde 100644
--- a/external/liborcus/
+++ b/external/liborcus/
@@ -27,12 +27,4 @@ $(eval $(call gb_UnpackedTarball_add_patches,liborcus,\
-# TODO: remove once switching arm to llvm-c++
-ifeq ($(ANDROID_APP_ABI),armeabi-v7a)
-$(eval $(call gb_UnpackedTarball_add_patches,liborcus,\
- external/liborcus/android-workaround.patch \
# vim: set noet sw=4 ts=4:
diff --git a/external/liborcus/android-workaround.patch b/external/liborcus/android-workaround.patch
deleted file mode 100644
index f9d047dc0559..000000000000
--- a/external/liborcus/android-workaround.patch
+++ /dev/null
@@ -1,22 +0,0 @@
-diff --git a/src/parser/sax_parser_base.cpp b/src/parser/sax_parser_base.cpp
-index 743130d..2624bd5 100644
---- a/src/parser/sax_parser_base.cpp
-+++ b/src/parser/sax_parser_base.cpp
-@@ -12,6 +12,17 @@
- #include <vector>
- #include <memory>
-+#ifdef __ANDROID__
-+namespace std
-+int stoi(const std::string& str, std::size_t* /*pos*/ = 0, int base = 10)
-+ char* end;
-+ return strtol(str.c_str(), &end, base);
- namespace orcus { namespace sax {
- malformed_xml_error::malformed_xml_error(const std::string& msg, std::ptrdiff_t offset) :
diff --git a/include/android/compatibility.hxx b/include/android/compatibility.hxx
index 27c99f4f2604..1dc403dc0fe8 100644
--- a/include/android/compatibility.hxx
+++ b/include/android/compatibility.hxx
@@ -27,12 +27,6 @@ namespace std
inline double fmax(double x, double y) { return ::fmax(x, y); }
-inline long stol(const std::string& str, std::size_t* /*pos*/ = 0, int base = 10)
- char* end;
- return strtol(str.c_str(), &end, base);
template <typename T> T round(T x) { return ::round(x); }
template <typename T> T trunc(T x) { return ::trunc(x); }
diff --git a/solenv/gbuild/platform/ b/solenv/gbuild/platform/
index bc8ad996f8df..572a7c5b1028 100644
--- a/solenv/gbuild/platform/
+++ b/solenv/gbuild/platform/
@@ -9,25 +9,14 @@
-ifeq ($(ANDROID_APP_ABI),armeabi-v7a)
-# TODO: gnustl is deprecated/will be removed in future versions of the ndk
-gb_STDLIBS := -lgnustl_static
gb_STDLIBS := \
-lc++_static \
-lc++abi \
-landroid_support \
-ifeq ($(ANDROID_APP_ABI),armeabi-v7a)
-# TODO: gnustl is deprecated/will be removed in future versions of the ndk
-gb_STDLIBS := -lgnustl_shared
gb_STDLIBS := -lc++_shared