我有一個獨立的工具鏈NDK13b,api19,LLVM 3.8的編譯器,臂32位,與libcpp(LLVM C++庫)缺少sync_val_compare_and_swap_1
欲取決於libgcc中,以避免,所以編譯器構建-RT。我能找到(這讓我用最少的未定義的符號是)最好的版本來自https://android.googlesource.com/platform/external/compiler-rt/
在我的鏈接線,我有:
-nodefaultlibs
避免鏈接爲libgcc和:
-lc++_static -lc++abi -lunwind -latomic -ldl -lm -lc -landroid -landroid_support -lclang_rt.builtins-arm -latomic
鏈接到所有標準庫。
當我嘗試將我的計劃,我得到以下未定義的引用:
/usr/local/google/buildbot/src/android/ndk-r13-release/external/libcxx/src/algorithm.cpp:83: error: undefined reference to '__sync_val_compare_and_swap_1' /usr/local/google/buildbot/src/android/ndk-r13-release/external/libcxx/src/ios.cpp:74: error: undefined reference to '__sync_val_compare_and_swap_1' /usr/local/google/buildbot/src/android/ndk-r13-release/external/libcxx/src/locale.cpp:53: error: undefined reference to '__sync_val_compare_and_swap_1' /usr/local/google/buildbot/src/android/ndk-r13-release/external/libcxx/src/locale.cpp:464: error: undefined reference to '__sync_val_compare_and_swap_1'
有什麼辦法通過定義自己的功能來規避這一點,例如,或者通過連接額外的圖書館嗎?
當我試圖使用從here代碼(這實際上是sync_val_compare_and_swap
沒有_1
),我得到:
../lib/builtins/sync_val_compare_and_swap_1.c ../lib/builtins/sync_val_compare_and_swap_1.c:6:16: error: conflicting types for '__sync_val_compare_and_swap_1' inline int32_t __sync_val_compare_and_swap_1(volatile int32_t* ptr, int32_t oldval, int32_t newval)
^
../lib/builtins/sync_val_compare_and_swap_1.c:6:16: note: '__sync_val_compare_and_swap_1' is a builtin with type 'char (volatile char *, char, char, ...)'