-
Notifications
You must be signed in to change notification settings - Fork 263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing libgcc in libc++.a breaks clang c++_static build #515
Comments
After some more digging, it seems that older Android.mk properly linked libunwindbacktrace into libc++abi on non-armeabi, but the new Android.mk and soong Android.bp is missing the link instructions. Instead a define is set but apparently it is not sufficient. |
Those platforms don't use libunwind. They use libgcc. Can you share your CMake configuration command? |
Oh that changes things. It is related to #504 and ancient android.toolchain.cmake then. It doesn't add libc++abi etc. on its own so I had to help it. However, new setup from CMake git master seems to attempt to link libunwind not libgcc after source code inspection. See: https://gitlab.kitware.com/cmake/cmake/blob/master/Modules/Platform/Android/ndk-stl-c++_static.cmake |
Another error that finally showed up on armeabi-v7a is missing __aeabi_uldivmod etc. when trying to use or . This is due to missing libgcc lin libc++.a while it is depended upon. (Note that adding -lgcc there does not work as it is not in the same directory.) Adding the linkage against the right libgcc.a per target works around it. |
It's not supposed to. Can you share your CMake configuration command? |
First, there's #105 which masks the problem as libstdc++.so contains the required symbols. Once you work around it (e.g. with -nodefaultlibs) and link like so: You will find you're missing libgcc. Adding -lgcc does not work, as it does not exist in Clang search path. Upcoming -nostdlibc++ flag will probably not link libgcc as well in the new unreleased upcoming Clang. Adding -static-libgcc does not work either. Adding something like e.g. |
Can you share your CMake configuration command? |
It is ran by gradle plugin 3.0.0-beta5, externalNativeBuild, the options are: externalNativeBuild {
cmake {
cFlags "-std=c11"
cppFlags "-std=c++14 -D_LIBCPP_STD_VER=14"
abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
arguments "-DANDROID_ARM_MODE=arm", "-DANDROID_ARM_NEON=TRUE", "-DANDROID_STL=c++_static",
"-DCMAKE_TOOLCHAIN_FILE=${android.ndkDirectory}/build/cmake/android.toolchain.cmake",
"-DANDROID_CPP_FEATURES=rtti exceptions", "-DANDROID_TOOLCHAIN=clang",
}
} The define is to force older versions of gradle plugin to actually use the right Slightly anonymized output of one of cmake_build_command.txt:
|
Works fine for me. My guess is that you're using some prebuilt libraries that need to be rebuilt. Everything reported here so far is actually things working as expected (using libgcc instead of libunwind, static libs not having libgcc symbols in them). Without a repro case there's nothing more we can do here. |
Hmm, no idea why would I need libraries to be rebuilt at all since when linking libgcc.a directly it works. The problem really shows up only with armeabi-v7a and std::chrono use (in my specific case, std::timed_mutex::wait_for(1min) with using std::chrono_literals on top) - anything else works without libgcc.a on that; without libgcc.a you get __aeabi_uldivmod etc. missing. Make sure your test result is not linked against libstdc++.so - which has all the libgcc symbols inside and obviously works. (I checked with readelf -d libproject.so.) That is issue #105 - I had to work around it as mentioned above with the two mentioned CMakeLists.txt lines. I'll produce a test project a while later. |
Closing for lack of a repro case. Will reopen if we get something actionable. |
Libunwind is missing for x86, x86_64 and arm64-v8a ABI preventing correct static linking with c++_static when exceptions are enabled.
This is caused by libc++abi directly referencing _Unwind_* symbols.
Results in errors like:
undefined reference to "_Unwind_Resume" etc.
Tested with NDK 16 beta 1, clang c++_static build of a shared library, ANDROID_CPP_FEATURES=exceptions and actually used exception handling.
Build is fine on armeabi-v7a and armeabi which provide libunwind.
Fails on x86, x86_64 and arm64-v8a. (Probably mips etc. as well but haven't checked.)
The text was updated successfully, but these errors were encountered: