Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android NDK and LOCAL_ARM_MODE flag

In my current Android native code build setup, APP_ABI is defined to armeabi-v7a in Application.mk. For some of the libraries that I am building, I see that LOCAL_ARM_MODE is defined as arm in Android.mk.

I need to extend this setup to build for x86 as well. From another post, it appears using "APP_ABI = all" is a better solution. I am just wondering if LOCAL_ARM_MODE must be changed as well. What does this flag do anyway?

like image 466
Peter Avatar asked Feb 14 '14 22:02

Peter


2 Answers

Though this is an old post, I just want to point out that the accepted answer is not correct.

LOCAL_ARM_MODE can either be set to "arm" or "thumb" and is defaulted to "thumb". "thumb" uses 16-bit instructions while "arm" uses 32-bit instructions. The 16-bit instructions is smaller but may be slow for some performance critical apps. That's why for some libraries, people specifically set this flag to "arm" to ensure build with 32-bit instructions. Of course, this flag is only meaningful when you build for the arm architectures.

On the other hand, APP_ABI is the correct flag to toggle with when you want to build for different architectures like armeabi-* or x86 and many more.

For more information, read the documentation for Android.mk

like image 184
projectcs2103t Avatar answered Nov 15 '22 23:11

projectcs2103t


The LOCAL_ARM_MODE can be used to define the platform your application is targeting. To have your Android.mk setup also for x86 just include the required info to your Android.mk file - e.g.:

ifeq ($(TARGET_ARCH),arm)
    LOCAL_CFLAGS := -mfpu=neon -march=armv6t2 -O9
    LOCAL_SRC_FILES := engine-arm.s
endif
ifeq ($(TARGET_ARCH),x86)
    LOCAL_CFLAGS := -msse2 -m32 -masm=intel
    LOCAL_SRC_FILES := engine-x86.s
endif

For more info about different option on defining your application target, have a look in /docs/Android-mk.

Source: Compile assembly code for ARM and X86

like image 20
Avanz Avatar answered Nov 15 '22 21:11

Avanz