Skip to content

Commit

Permalink
build-android: Use c++_shared
Browse files Browse the repository at this point in the history
https://developer.android.com/ndk/guides/cpp-support recommends using
c++_shared for applications that use more than one shared library.
If multiple libraries using c++_static are loaded you end up with
several copies of the globals in the C++ runtime. This also happens
if the same library is dlopen/dlclosed several times. Some of the
c++ runtime globals are thread_local, so each copy consumes a
TLS key. There are only 128 TLS keys allowed on android, and the
unit tests can hit this because of repeatedly loading and unloading
VVL.

See android/ndk#789 and the many issues
linked to it for more info.
  • Loading branch information
jeremyg-lunarg committed Aug 11, 2022
1 parent 3b0cb10 commit 38ce8e6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build-android/jni/Application.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
APP_ABI := armeabi-v7a arm64-v8a x86 x86_64
# APP_ABI := arm64-v8a # just build for pixel2 (don't check in)
APP_PLATFORM := android-26
APP_STL := c++_static
APP_STL := c++_shared
NDK_TOOLCHAIN_VERSION := clang
NDK_MODULE_PATH := .
2 changes: 1 addition & 1 deletion build-android/jni/shaderc/Application.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
APP_ABI := all
APP_BUILD_SCRIPT := Android.mk
APP_STL := c++_static
APP_STL := c++_shared
APP_PLATFORM := android-23

0 comments on commit 38ce8e6

Please sign in to comment.