Max
Max

Reputation: 6394

Android NDK: Hardware float point for ARMv6

I know android provides support for ARMv5TE and ARMv7a CPU. (armeabi and areabi-v7a folders) Most Android Phones's CPUs now are ARMv6 without VFP, ARMv6 with VFP and ARMv7 with VFP.

My app has physics simulation and I wish to target devices with hardware float point only. (VFP). I do not wish to support devices without VFP.

How do I configure NDK project to compile ARMEABI code to be ARMv6 with VFP instead of ARVv5TE ?

I can block old ARMv6 without VFP and ARmv5 device via Google Play interface when APK is uploaded.

Upvotes: 1

Views: 1258

Answers (1)

Andrey Kamaev
Andrey Kamaev

Reputation: 30152

NDK does not really provides any convenient way to change default build options. You can only add additional flags but not override standard options.

Default LOCAL_CFLAGS and most of other options will not work for you because NDK puts its options after yours and overrides your flags. The only solution I know is to define global APP_CFLAGS in the Application.mk. So the following should result in binaries optimized for armv6 having VFPv2:

APP_CFALGS += -march=armv6 -mno-soft-float -mfloat-abi=softfp -mfpu=vfp

Also if I remember correctly, vfp instructions on armv6 hardware require to compile your code in arm mode (not thumb). Specify LOCAL_ARM_MODE := arm for every target in Android.mk to achieve this.

By the way I think that you will not be satisfied by performance of armv6 device. Even newest hi-end armv7 processors are about 10 times slower than modern Intel Core CPUs.

Upvotes: 3

Related Questions