From 38ce8e6a4200214a3199ccff7892c6002ca9d1ac Mon Sep 17 00:00:00 2001 From: Jeremy Gebben Date: Tue, 9 Aug 2022 13:25:16 -0600 Subject: [PATCH] build-android: Use c++_shared 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 https://github.com/android/ndk/issues/789 and the many issues linked to it for more info. --- build-android/jni/Application.mk | 2 +- build-android/jni/shaderc/Application.mk | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build-android/jni/Application.mk b/build-android/jni/Application.mk index 243c28538d8..ff6a400406f 100644 --- a/build-android/jni/Application.mk +++ b/build-android/jni/Application.mk @@ -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 := . diff --git a/build-android/jni/shaderc/Application.mk b/build-android/jni/shaderc/Application.mk index 5447415eb5f..103ab5575ec 100644 --- a/build-android/jni/shaderc/Application.mk +++ b/build-android/jni/shaderc/Application.mk @@ -1,4 +1,4 @@ APP_ABI := all APP_BUILD_SCRIPT := Android.mk -APP_STL := c++_static +APP_STL := c++_shared APP_PLATFORM := android-23