hxcpp icon indicating copy to clipboard operation
hxcpp copied to clipboard

Add an option to disable static link to libc++ on Android/Clang

Open jeremyfa opened this issue 3 years ago • 1 comments

Currently, in android-toolchain-clang.xml, flag -static-libstdc++ is used.

However, when using multiple shared libraries, it is recommended to link with libc++ dynamically (and embed libc++_shared.so in final apk) because multiple shared libraries with static link to libc++ can lead to undefined behavior. See this for reference: https://developer.android.com/ndk/guides/cpp-support

I understand that as long as we use a single .so in the final app, static link is easier, but there should be an option to disable it, like HXCPP_LIBCPP_SHARED or similar, that removes -static-libstdc++ flag from the toolchain and make it default to shared libc++. (or make -static-libstdc++ flag require HXCPP_LIBCPP_STATIC, that would work too).

jeremyfa avatar Dec 29 '20 21:12 jeremyfa

(also note that I can do a pull request with the described change if needed! 🙂)

jeremyfa avatar Jan 04 '21 14:01 jeremyfa