ndk icon indicating copy to clipboard operation
ndk copied to clipboard

[BUG] NDK22 <atomic> fails

Open timofey-retailnext opened this issue 5 years ago • 1 comments

Description

compiling coin-or-cbc 2.10.5 for android NDK r22. builds well for target=aarch64-linux-android23, fails for target=arm-linux-androideabi19

cmd line for success:

CLANG++ -DHAVE_CONFIG_H -I. -I. -target aarch64-linux-android23 -DANDROID -D_FORTIFY_SOURCE=2 -g -O2 -DNDEBUG -Wno-deprecated-register -Wno-invalid-command-line-argument -Wno-unused-command-line-argument -Wformat -Werror=format-security -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -fPIC -std=c++14 -frtti -fexceptions -DCOINUTILS_BUILD -MT CoinBuild.lo -MD -MP -MF .deps/CoinBuild.Tpo -c CoinBuild.cpp -o CoinBuild.o

cmd line for failure:

CLANG++ -DHAVE_CONFIG_H -I. -I. -target arm-linux-androideabi19 -DANDROID -D_FORTIFY_SOURCE=2 -g -O2 -DNDEBUG -mfpu=neon -marm -Wno-deprecated-register -Wno-invalid-command-line-argument -Wno-unused-command-line-argument -Wformat -Werror=format-security -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -fPIC -std=c++14 -frtti -fexceptions -DCOINUTILS_BUILD -MT CoinBuild.lo -MD -MP -MF .deps/CoinBuild.Tpo -c CoinBuild.cpp -o CoinBuild.o In file included from CoinBuild.cpp:11: In file included from TOOLCHAIN/bin/../sysroot/usr/include/c++/v1/iostream:37: In file included from TOOLCHAIN/bin/../sysroot/usr/include/c++/v1/ios:215: In file included from TOOLCHAIN/bin/../sysroot/usr/include/c++/v1/__locale:14: In file included from TOOLCHAIN/bin/../sysroot/usr/include/c++/v1/string:504: In file included from TOOLCHAIN/bin/../sysroot/usr/include/c++/v1/string_view:175: In file included from TOOLCHAIN/bin/../sysroot/usr/include/c++/v1/__string:57: In file included from TOOLCHAIN/bin/../sysroot/usr/include/c++/v1/algorithm:643: In file included from TOOLCHAIN/bin/../sysroot/usr/include/c++/v1/memory:673: TOOLCHAIN/bin/../sysroot/usr/include/c++/v1/atomic:2759:16: error: use of undeclared identifier '__libcpp_signed_lock_free' typedef atomic<__libcpp_signed_lock_free> atomic_signed_lock_free; ^ TOOLCHAIN/bin/../sysroot/usr/include/c++/v1/atomic:2760:16: error: unknown type name '__libcpp_unsigned_lock_free'; did you mean 'atomic_signed_lock_free'? typedef atomic<__libcpp_unsigned_lock_free> atomic_unsigned_lock_free; ^ TOOLCHAIN/bin/../sysroot/usr/include/c++/v1/atomic:2759:43: note: 'atomic_signed_lock_free' declared here typedef atomic<__libcpp_signed_lock_free> atomic_signed_lock_free; ^ 2 errors generated.

Looks like it is a bug in libcpp 11 itself. see problem description in: https://github.com/ziglang/zig/issues/6573 or in https://reviews.llvm.org/D75183

Is there anything specific in arm32 vs arm64 or in api19 (vs api21+) that fails to define all 4 of: ATOMIC_LLONG_LOCK_FREE,ATOMIC_INT_LOCK_FREE,ATOMIC_SHORT_LOCK_FREE,ATOMIC_CHAR_LOCK_FREE

P.S. works fine for both arm32/api19 and arm64/api23 for NDKs r17-r21 (i.e. libcpp version <=10 )

Environment Details

Pkg.Desc = Android NDK Pkg.Revision = 22.0.7026061 Host OS: CenOS 8.3 Build system: native gnu make 4.2.1 (with redefined CC,CXX,CFLAGS,CXXFLAGS,etc) ABI: armeabi API:19

timofey-retailnext avatar Dec 25 '20 06:12 timofey-retailnext

CLANG++ -DHAVE_CONFIG_H -I. -I. -target arm-linux-androideabi19 -DANDROID -D_FORTIFY_SOURCE=2 -g -O2 -DNDEBUG -mfpu=neon -marm -Wno-deprecated-register -Wno-invalid-command-line-argument -Wno-unused-command-line-argument -Wformat -Werror=format-security -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -fPIC -std=c++14 -frtti -fexceptions -DCOINUTILS_BUILD -MT CoinBuild.lo -MD -MP -MF .deps/CoinBuild.Tpo -c CoinBuild.cpp -o CoinBuild.o

This is building for armv5. That's not an architecture we support. I can reproduce the error with a trivial #include <atomic> source file and the following command line:

$ android-ndk-r22/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ -target armv7-linux-androideabi19 -c jni/foo.cpp
In file included from jni/foo.cpp:1:
/work/src/android-ndk-r22/toolchains/llvm/prebuilt/linux-x86_64/bin/../sysroot/usr/include/c++/v1/atomic:2759:16: error: use of undeclared identifier '__libcpp_signed_lock_free'
typedef atomic<__libcpp_signed_lock_free> atomic_signed_lock_free;
               ^
/work/src/android-ndk-r22/toolchains/llvm/prebuilt/linux-x86_64/bin/../sysroot/usr/include/c++/v1/atomic:2760:16: error: unknown type name '__libcpp_unsigned_lock_free'; did you mean 'atomic_signed_lock_free'?
typedef atomic<__libcpp_unsigned_lock_free> atomic_unsigned_lock_free;
               ^
/work/src/android-ndk-r22/toolchains/llvm/prebuilt/linux-x86_64/bin/../sysroot/usr/include/c++/v1/atomic:2759:43: note: 'atomic_signed_lock_free' declared here
typedef atomic<__libcpp_signed_lock_free> atomic_signed_lock_free;
                                          ^
2 errors generated.

But using the appropriate target (armv7-linux-androideabi19) fixes it. See https://developer.android.com/ndk/guides/other_build_systems.

DanAlbert avatar Jan 26 '21 23:01 DanAlbert