I've got a few Android NDK apps out and people complain my app doesn't work on their phones. What I'd like to know is what are the compilation settings that will support most if not all ARM devices on the market?
My problem seems to be armeabi-v7a devices that have a varying amount of support for VFP, NEON, etc. I'm looking for a solution to build apps that run on the most platforms, even if that's at the cost of optimization.
I was using the default NDK build scripts for armeabi and armeabi-v7a, that specified:
-march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3
This does not work on some devices, for example on Acer A500 (CPU Nvidia Tegra2 (Dual Cortex A9)). This CPU does not implement NEON, from what I'm learning here http://wiki.debian.org/ArmHardFloatPort/VfpComparison.
The crash, specifically, is this:
F/libc (15549): Fatal signal 4 (SIGILL) at 0x5bfd9260 (code=1)
...(snip)...
I/DEBUG ( 81): #00 pc 0005b260 /data/data/com.burnsmod.oscpad/lib/libapplication.so (tanf)
Looking at libapplication.so, I see tanf is being generated as:
0005b25c <tanf>:
5b25c: ee070a90 fmsr s15, r0
5b260: eef70ae7 fcvtds d16, s15
5b264: e92d4010 push {r4, lr}
5b268: ec510b30 vmov r0, r1, d16
5b26c: ebff4b6c bl 2e024 <_ZN15ButtonUIHandler10FreeImagesEv-0x6ac>
5b270: ec410b30 vmov d16, r0, r1
5b274: eef77be0 fcvtsd s15, d16
5b278: ee170a90 fmrs r0, s15
5b27c: e8bd8010 pop {r4, pc}
So, what's the answer? vfpv2? vfp? vfpv3? vfpv3-d16?
Right now if I use readelf I find my application library's dependencies are:
MacBook:armeabi-v7a tom$ arm-linux-androideabi-readelf -A libapplication.so
Attribute Section: aeabi
File Attributes
Tag_CPU_name: "7-A"
Tag_CPU_arch: v7
Tag_CPU_arch_profile: Application
Tag_ARM_ISA_use: Yes
Tag_THUMB_ISA_use: Thumb-2
Tag_VFP_arch: VFPv3
Tag_ABI_PCS_wchar_t: 4
Tag_ABI_FP_denormal: Needed
Tag_ABI_FP_exceptions: Needed
Tag_ABI_FP_number_model: IEEE 754
Tag_ABI_align8_needed: Yes
Tag_ABI_align8_preserved: Yes, except leaf SP
Tag_ABI_enum_size: int
Tag_ABI_HardFP_use: SP and DP
VFP2: Compiling with '-mfpu=vfpv2' or '-mfpu=vfp2' isn't supported in NDK 7, both return an error message.
It turns out my problem was that I was using NDK r7b, which had bugs where VFPv3 code was included in some core libraries.
http://code.google.com/p/android/issues/detail?id=26199
It was fixed in r7c and by upgrading to r8b it looks like I fixed the issue.