I'm in the progress of updating some code to clang in the NDK (since
they are not longer supporting GCC), and getting some ODR errors which
seem to be caused by a bad link configuration.
The generated executables / shared libraries seem to link to both the
selected standard library, and libstdc++.so (android's minimal 'system'
standard lib, not gcc's c++ standard lib). This causes multiple
definitions of new/delete, triggering ODR warnings between 'libc++abi.a'
When using the gnustl_static, there's similar issues on the members of
'std::type_info', 'std::basic_string', and 'std::shared_ptr', but this
is now between our code and 'libgnustl_static.a' (possibly a clang vs
gcc code gen difference?)
This happens in cmake 3.7.2 and cmake 3.8
Is anyone successfully using cmake + clang on android, or have an idea
of where the configuration script might be wrong?
> (in case threading doesn't work since I'm not a list member and can't
> reply to the original message:
> I'm pretty sure -Wl,--detect-odr-violations is just giving you false
> positives. Note that the warning message says "/possible/ ODR
> violation". We tried using this flag in the Android platform recently
> and found lots of false positives too.
> Those symbols are weak in libc++abi, so this is not an ODR violation
> (they're not weak in libstdc++.so, and that's a bug, but not a harmful
> one; I'm fixing it right now either way).
> FWIW, CMake shouldn't be linking libstdc++.so /and/ libc++_static.a in
> the same link either way, but this is actually something that both
> upstream CMake, the NDK's CMake toolchain file, and ndk-build all get
> wrong. It's something that we should resolve eventually, but it doesn't
> actually cause any problems so it hasn't been prioritized. Could argue
> that it has caused this problem, but this would still be firing on false
> positives if you'd added your own new/delete replacements, and this
> warning is still pretty much guaranteed to fire for libc++ because
> libandroid_support will do exactly the same thing and try to replace a
> bunch of things in libc.
Thanks, I'll move ahead with the switch, and look in to filtering out
the warnings on these symbols, rather than disabling the ODR checks