I see in the revisions list for 9b that it:
- Fixed Clang 3.3 to compile ARM's built-in, atomic operations such as
__atomic_fetch_add
,__atomic_fetch_sub
, and __atomic_fetch_or
.
It does properly generate the needed variety of __atomic_fetch_add_n, but:
C:/android-ndk-r9b/sources/cxx-stl/gnu-libstdc++/4.8/include\bits/atomic_base.h:614: error: undefined reference to '__atomic_fetch_add_4'
Repro: In Eclipse, make an application project called 'Test'. Add native support. Create an Application.mk:
NDK_TOOLCHAIN_VERSION := clang
APP_STL:=gnustl_shared
In Android.mk, add:
LOCAL_CPPFLAGS := -std=c++11
Replace the contents of Test.cpp with:
#include <atomic>
void test() {
std::atomic<int> a(0);
a++;
}
Build the project to observe the error. Is this a known issue? Have I done something incorrectly? I have not been able to find any mention of this particular problem.
I tried adding this to the end of Test.cpp:
typedef int I4;
I4 __atomic_fetch_add_4 (I4 *mem, I4 val, int model) {
return __sync_fetch_and_add(mem, val);
}
based on the signature
here, but I suspect something about it is wrong because clang still says its undefined. (also tried adding volatile to the first parameter and/or changing the last parameter to std::memory_model)
Any info on this would be helpful. Thanks.
Complete build log:
**** Build of configuration Default for project Test ****
C:\android-ndk-r9b\ndk-build.cmd all
Android NDK: WARNING: APP_PLATFORM android-19 is larger than android:minSdkVersion 8 in ./AndroidManifest.xml
[armeabi] Compile++ thumb: Test <= Test.cpp
[armeabi] Prebuilt : libgnustl_shared.so <= <NDK>/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi/
[armeabi] SharedLibrary : libTest.so
C:/android-ndk-r9b/sources/cxx-stl/gnu-libstdc++/4.8/include\bits/atomic_base.h:614: error: undefined reference to '__atomic_fetch_add_4'
clang++.exe: error: linker command failed with exit code 1 (use -v to see invocation)
make.exe: *** [obj/local/armeabi/libTest.so] Error 1
**** Build Finished ****