-
Notifications
You must be signed in to change notification settings - Fork 250
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
"pure virtual method called" when using std::thread with clang in NDK r12b #151
Comments
Which STL? |
I used the default STL, I just checked that the default is Is it recommended to use |
gnustl is a safer bet than the libc++ we have in the NDK right now. libc++ is getting closer, but we're not really to the point that I'm happy recommending it yet. It's a useful data point for reproducing the error though, and we've definitely seen cases where clang and gnustl don't get along in some of the C++11 parts of the library (typically https://llvm.org/bugs/show_bug.cgi?id=12730#c10 seems to be the really interesting piece, but according to the following messages on that bug it should be fixed... I'll do a bit of digging to make sure all those pieces are on for Android. |
Interestingly I don't see this problem if I use |
Found the issue, and it's actually one I've reported before (internally). The problem is that Clang doesn't search subarchitecture directories when linking libraries. Instead of passing Since using Clang was recently fixed upstream, so once we can update Clang this will be resolved. Unfortunately, Clang has moved to new enough Windows APIs that we can't actually build Clang until we sort some things out in our build infrastructure, so I don't know how soon that will be. To workaround this until then you can pass |
Thank you very much for finding the root cause of the issue! In the meantime, I also encountered a linker issue with this std::future example:
And the same workaround fixes that problem as well! |
Just to be pedantic, the clang fix is not in any scheduled NDK update yet. We hope to get it into a future release, but Windows issues are blocking that. |
This issue is still present with NDK r13b (considering the standalone toolchain). Do you have any updates about the Windows issues that you mentioned above? |
The Windows toolchain issues are fixed and we have an updated Clang in r14. @stephenhines should be able to confirm that we have this fix (I think we do, but I'm not 100% certain). This is available in the canary builds if you're feeling brave (although the beta should be published in a few hours, or so I'm told): https://android.googlesource.com/platform/ndk/+/master/docs/ContinuousBuilds.md |
This is likely fixed, but awaiting verification. |
I can confirm that this issue is fixed in r14. It is now safe to use clang as a standalone toolchain. I will close this issue. |
libandroid_support's definition of the byte-order for doubles on armeabi was wrongly big endian rather than following the byte order of the ABI. This was due to a missing check for __ARM_EABI__ (a bug in the upstream FreeBSD libm source that bionic did not have because it has been updated since it was fixed). I haven't pulled the full update of math_private.h since it also needs a lot of new macros for complex math support. I'll be cleaning up libandroid_support more thoroughly soon anyway. Note that this bug could surface even for arm7 when using a standalone toolchain because we still have the Clang bug where it doesn't search architecture specific lib directories, meaning that arm5 gets used instead of arm7 (http://b/26180518 and android/ndk#151). Test: ./run_tests.py --filter log2 Bug: android/ndk#204 Change-Id: I2caaeac3afe0830008b865bc124f48200ac5f4b6
I have a runtime issue with the following std::thread example (
thread.cpp
):If I compile the example with clang in NDK r12b (using a standalone toolchain):
arm-linux-androideabi-clang++ -std=c++11 -march=armv7-a thread.cpp -o thread
I get the following runtime failure on various Android devices (I tried Android 4.0, 4.4 and 6.0):
If I compile with g++ (from the same standalone toolchain):
arm-linux-androideabi-g++ -std=c++11 -march=armv7-a thread.cpp -o thread
Then I get the expected output on all devices:
Clang had a similar issue in the past: https://llvm.org/bugs/show_bug.cgi?id=12730
An incorrect g++ configuration led to the same issue on ARM: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62100
Any ideas for a fix?
The text was updated successfully, but these errors were encountered: